cancel
Showing results for 
Search instead for 
Did you mean: 

CMSIS DSP matrix inverse

dario
Associate II
Posted on June 08, 2013 at 01:32

Hi,

i realized a test source code for matrix inversion. I used the CMSIS DSP library which include arm_mat_inverse_f

I also took a look at arm_matrix_example_fc...

but i had 1 problem and 1 question.

float32_t AT_f32[16];

const

float32_t A_f32[16] =

{

1.0, 0, 4.0, 0,

1.0, 0, 0, 20,

1.0, 0, 4.0, 0,

1.0, 0, 0, 10,

};

arm_matrix_instance_f32 A;

/* Matrix A Instance */

arm_matrix_instance_f32 AT;

/* Matrix AT(A transpose) instance */

uint32_t srcRows, srcColumns;

/* Temporary variables */

arm_status status;

srcRows = 4;

srcColumns = 4;

arm_mat_init_f32(&A, srcRows, srcColumns, (float32_t *)A_f32);

arm_mat_init_f32(&AT, srcRows, srcColumns, AT_f32);

QUESTION:

Why

A_f32 it's converted in float32_t pointer???

And why

AT_f32 that is the same variable type it's treated in a different manner?

PROBLEM:

This is MY code:

#include ''arm_math.h''

float32_t matrix[4] ={5,0,0,2};

float32_t matrix2[4];

int

main(

void

)

{

arm_matrix_instance_f32 mat;

arm_matrix_instance_f32 mat2;

arm_mat_init_f32(&mat,2,2,(float32_t *)matrix);

arm_mat_init_f32(&mat2,2,2,matrix2);

arm_status state;

while

(1)

{

state = arm_mat_inverse_f32(&mat,&mat2);

}

}

BUT what happens?

The first inversion put the inverse of

matin

mat2 taht put the inverse

of

matrix in

matrix2.This is right!

But unfortunately the state become ARM_MATH_SINGULAR and matrix becomes IDENTITY MATRIX!!! And also with the identity matrix in the second cicle the state remains ARM_MATH_SINGULAR....

Does anyone have suggestion/solutions?

Thanks!!!

#matrix-inverse-dsp-cmsis

2 REPLIES 2
zzdz2
Associate II
Posted on June 08, 2013 at 10:34

Why A_f32 it's converted in float32_t pointer???

And why AT_f32 that is the same variable type it's treated in a different manner?

It's not the same type, one is (float32_t *), the other is (const float32_t *).

I think it's typecasted to avoid compiler warning.

BUT what happens?

The first inversion put the inverse of mat in mat2 taht put the inverse of matrix inmatrix2.

 

This is right!

But unfortunately the state become ARM_MATH_SINGULAR and matrix becomes IDENTITY MATRIX!!! And also with the identity matrix in the second cicle the state remains ARM_MATH_SINGULAR....

I don't know this library but it looks like  ARM_MATH_SINGULAR is some kind of error, matrix non-invertible. 

dariomangoni
Associate
Posted on June 14, 2013 at 18:05

Problem solved.

The (float32_t *) it's only for avoiding eventual compiler errors. In general the correct syntax is

float32_t matrix2[4];
arm_matrix_instance_f32 mat2;
arm_mat_init_f32( &mat2 , 2, 2, matrix2 );

arm_mat_inverse_f32 use directly the source matrix for Gauss_Jordan algorithm that, at the end of the process, brings the initial matrix to the identity matrix. All runs correctly but it seems to be in error when you give it an identity matrix.... The function exit with ARM_MATH_SINGULAR status only because it didn't do anything because the matrix was already inverted. So, if you need to preserve the initial matrix also after inversion, you need to make a backup of the initial matrix.