Skip to content

Commit

Permalink
Correct issue #172 : singular matrix inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe0606 committed Jun 12, 2024
1 parent 03fa0e5 commit 5f5086f
Show file tree
Hide file tree
Showing 35 changed files with 3,672 additions and 2,892 deletions.
3 changes: 3 additions & 0 deletions Source/MatrixFunctions/arm_mat_inverse_f16.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ arm_status arm_mat_inverse_f16(
/* Index modifier to navigate through the columns */
for(column = 0U; column < numCols; column++)
{
/* reset flag */
flag = 0;

/* Check if the pivot element is zero..
* If it is zero then interchange the row with non zero row below.
* If there is no non zero element to replace in the rows below,
Expand Down
3 changes: 3 additions & 0 deletions Source/MatrixFunctions/arm_mat_inverse_f32.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ arm_status arm_mat_inverse_f32(
/* Index modifier to navigate through the columns */
for(column = 0U; column < numCols; column++)
{
/* reset flag */
flag = 0;

/* Check if the pivot element is zero..
* If it is zero then interchange the row with non zero row below.
* If there is no non zero element to replace in the rows below,
Expand Down
3 changes: 3 additions & 0 deletions Source/MatrixFunctions/arm_mat_inverse_f64.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ arm_status arm_mat_inverse_f64(
/* Index modifier to navigate through the columns */
for(column = 0U; column < numCols; column++)
{
/* reset flag */
flag = 0;

/* Check if the pivot element is zero..
* If it is zero then interchange the row with non zero row below.
* If there is no non zero element to replace in the rows below,
Expand Down
15 changes: 12 additions & 3 deletions Testing/PatternGeneration/Matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,15 @@ def writeUnaryTests(config,format):
r = np.linalg.inv(ma)
vals = vals + list(r.reshape(4))
dims.append(2)

# Add matrix for testing singular matrix

ma = np.array([[1., 2.], [2., 4.]])
inp = inp + list(ma.reshape(4))

r = np.array([0.,0.5,1.0,-0.5])
vals = vals + list(r)
dims.append(2)
#
config.writeInputS16(1, dims,"DimsInvert")
config.writeInput(1, inp,"InputInvert")
Expand Down Expand Up @@ -1197,9 +1206,9 @@ def generatePatterns():
configUnaryq15.setOverwrite(False)
configUnaryq7.setOverwrite(False)

#writeUnaryTests(configUnaryf64,Tools.F64)
#writeUnaryTests(configUnaryf32,Tools.F32)
#writeUnaryTests(configUnaryf16,Tools.F16)
writeUnaryTests(configUnaryf64,Tools.F64)
writeUnaryTests(configUnaryf32,Tools.F32)
writeUnaryTests(configUnaryf16,Tools.F16)
#writeUnaryTests(configUnaryq31,Tools.Q31)
#writeUnaryTests(configUnaryq31,Tools.Q31)
#writeUnaryTests(configUnaryq15,Tools.Q15)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H
10
11
// 1
0x0001
// 2
Expand All @@ -20,3 +20,5 @@ H
0x0010
// 2
0x0002
// 2
0x0002
10 changes: 9 additions & 1 deletion Testing/Patterns/DSP/Matrix/Unary/UnaryF16/InputInvert1_f16.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H
709
713
// 0.500000
0x3800
// 0.707107
Expand Down Expand Up @@ -1418,3 +1418,11 @@ H
0x4400
// 5.000000
0x4500
// 1.000000
0x3c00
// 2.000000
0x4000
// 2.000000
0x4000
// 4.000000
0x4400
10 changes: 9 additions & 1 deletion Testing/Patterns/DSP/Matrix/Unary/UnaryF16/RefInvert1_f16.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H
709
713
// 2.000000
0x4000
// 0.707107
Expand Down Expand Up @@ -1418,3 +1418,11 @@ H
0x3555
// 0.000000
0x0
// 0.000000
0x0
// 0.500000
0x3800
// 1.000000
0x3c00
// -0.500000
0xb800
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H
13
14
// 1
0x0001
// 2
Expand All @@ -26,3 +26,5 @@ H
0x0021
// 2
0x0002
// 2
0x0002
10 changes: 9 additions & 1 deletion Testing/Patterns/DSP/Matrix/Unary/UnaryF32/InputInvert1_f32.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
W
3111
3115
// 0.500000
0x3f000000
// 0.707107
Expand Down Expand Up @@ -6222,3 +6222,11 @@ W
0x40800000
// 5.000000
0x40a00000
// 1.000000
0x3f800000
// 2.000000
0x40000000
// 2.000000
0x40000000
// 4.000000
0x40800000
10 changes: 9 additions & 1 deletion Testing/Patterns/DSP/Matrix/Unary/UnaryF32/RefInvert1_f32.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
W
3111
3115
// 2.000000
0x40000000
// 0.707107
Expand Down Expand Up @@ -6222,3 +6222,11 @@ W
0x3eaaaaab
// 0.000000
0x0
// 0.000000
0x0
// 0.500000
0x3f000000
// 1.000000
0x3f800000
// -0.500000
0xbf000000
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
H
13
14
// 1
0x0001
// 2
Expand All @@ -26,3 +26,5 @@ H
0x0021
// 2
0x0002
// 2
0x0002
14 changes: 11 additions & 3 deletions Testing/Patterns/DSP/Matrix/Unary/UnaryF64/InputInvert1_f64.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
D
3111
3115
// 0.500000
0x3fe0000000000000
// 0.707107
0x3fe6a09e667f3bcd
// 0.707107
0x3fe6a09e667f3bcc
0x3fe6a09e667f3bcd
// -0.707107
0xbfe6a09e667f3bcc
0xbfe6a09e667f3bcd
// 0.707107
0x3fe6a09e667f3bcd
// 0.804738
Expand Down Expand Up @@ -6222,3 +6222,11 @@ D
0x4010000000000000
// 5.000000
0x4014000000000000
// 1.000000
0x3ff0000000000000
// 2.000000
0x4000000000000000
// 2.000000
0x4000000000000000
// 4.000000
0x4010000000000000
Loading

0 comments on commit 5f5086f

Please sign in to comment.