Skip to content

Commit 5f5086f

Browse files
Correct issue ARM-software#172 : singular matrix inversion
1 parent 03fa0e5 commit 5f5086f

35 files changed

+3672
-2892
lines changed

Source/MatrixFunctions/arm_mat_inverse_f16.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ arm_status arm_mat_inverse_f16(
155155
/* Index modifier to navigate through the columns */
156156
for(column = 0U; column < numCols; column++)
157157
{
158+
/* reset flag */
159+
flag = 0;
160+
158161
/* Check if the pivot element is zero..
159162
* If it is zero then interchange the row with non zero row below.
160163
* If there is no non zero element to replace in the rows below,

Source/MatrixFunctions/arm_mat_inverse_f32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ arm_status arm_mat_inverse_f32(
188188
/* Index modifier to navigate through the columns */
189189
for(column = 0U; column < numCols; column++)
190190
{
191+
/* reset flag */
192+
flag = 0;
193+
191194
/* Check if the pivot element is zero..
192195
* If it is zero then interchange the row with non zero row below.
193196
* If there is no non zero element to replace in the rows below,

Source/MatrixFunctions/arm_mat_inverse_f64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ arm_status arm_mat_inverse_f64(
153153
/* Index modifier to navigate through the columns */
154154
for(column = 0U; column < numCols; column++)
155155
{
156+
/* reset flag */
157+
flag = 0;
158+
156159
/* Check if the pivot element is zero..
157160
* If it is zero then interchange the row with non zero row below.
158161
* If there is no non zero element to replace in the rows below,

Testing/PatternGeneration/Matrix.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,15 @@ def writeUnaryTests(config,format):
806806
r = np.linalg.inv(ma)
807807
vals = vals + list(r.reshape(4))
808808
dims.append(2)
809+
810+
# Add matrix for testing singular matrix
811+
812+
ma = np.array([[1., 2.], [2., 4.]])
813+
inp = inp + list(ma.reshape(4))
814+
815+
r = np.array([0.,0.5,1.0,-0.5])
816+
vals = vals + list(r)
817+
dims.append(2)
809818
#
810819
config.writeInputS16(1, dims,"DimsInvert")
811820
config.writeInput(1, inp,"InputInvert")
@@ -1197,9 +1206,9 @@ def generatePatterns():
11971206
configUnaryq15.setOverwrite(False)
11981207
configUnaryq7.setOverwrite(False)
11991208

1200-
#writeUnaryTests(configUnaryf64,Tools.F64)
1201-
#writeUnaryTests(configUnaryf32,Tools.F32)
1202-
#writeUnaryTests(configUnaryf16,Tools.F16)
1209+
writeUnaryTests(configUnaryf64,Tools.F64)
1210+
writeUnaryTests(configUnaryf32,Tools.F32)
1211+
writeUnaryTests(configUnaryf16,Tools.F16)
12031212
#writeUnaryTests(configUnaryq31,Tools.Q31)
12041213
#writeUnaryTests(configUnaryq31,Tools.Q31)
12051214
#writeUnaryTests(configUnaryq15,Tools.Q15)

Testing/Patterns/DSP/Matrix/Unary/UnaryF16/DimsInvert1_s16.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
H
2-
10
2+
11
33
// 1
44
0x0001
55
// 2
@@ -20,3 +20,5 @@ H
2020
0x0010
2121
// 2
2222
0x0002
23+
// 2
24+
0x0002

Testing/Patterns/DSP/Matrix/Unary/UnaryF16/InputInvert1_f16.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
H
2-
709
2+
713
33
// 0.500000
44
0x3800
55
// 0.707107
@@ -1418,3 +1418,11 @@ H
14181418
0x4400
14191419
// 5.000000
14201420
0x4500
1421+
// 1.000000
1422+
0x3c00
1423+
// 2.000000
1424+
0x4000
1425+
// 2.000000
1426+
0x4000
1427+
// 4.000000
1428+
0x4400

Testing/Patterns/DSP/Matrix/Unary/UnaryF16/RefInvert1_f16.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
H
2-
709
2+
713
33
// 2.000000
44
0x4000
55
// 0.707107
@@ -1418,3 +1418,11 @@ H
14181418
0x3555
14191419
// 0.000000
14201420
0x0
1421+
// 0.000000
1422+
0x0
1423+
// 0.500000
1424+
0x3800
1425+
// 1.000000
1426+
0x3c00
1427+
// -0.500000
1428+
0xb800

Testing/Patterns/DSP/Matrix/Unary/UnaryF32/DimsInvert1_s16.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
H
2-
13
2+
14
33
// 1
44
0x0001
55
// 2
@@ -26,3 +26,5 @@ H
2626
0x0021
2727
// 2
2828
0x0002
29+
// 2
30+
0x0002

Testing/Patterns/DSP/Matrix/Unary/UnaryF32/InputInvert1_f32.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
W
2-
3111
2+
3115
33
// 0.500000
44
0x3f000000
55
// 0.707107
@@ -6222,3 +6222,11 @@ W
62226222
0x40800000
62236223
// 5.000000
62246224
0x40a00000
6225+
// 1.000000
6226+
0x3f800000
6227+
// 2.000000
6228+
0x40000000
6229+
// 2.000000
6230+
0x40000000
6231+
// 4.000000
6232+
0x40800000

Testing/Patterns/DSP/Matrix/Unary/UnaryF32/RefInvert1_f32.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
W
2-
3111
2+
3115
33
// 2.000000
44
0x40000000
55
// 0.707107
@@ -6222,3 +6222,11 @@ W
62226222
0x3eaaaaab
62236223
// 0.000000
62246224
0x0
6225+
// 0.000000
6226+
0x0
6227+
// 0.500000
6228+
0x3f000000
6229+
// 1.000000
6230+
0x3f800000
6231+
// -0.500000
6232+
0xbf000000

0 commit comments

Comments
 (0)