I need to get the solution of an equation system. For this purpose i use the function sgesv_().
Everything works great, and it retur me the right results of the solution.
But i get an strange Warning.
warning: passing argument 3 of ‘sgesv_’ from incompatible pointer type
I am using the function as Apple use it on the WWDC video.
What am I doing wrong?
a1,a2,b1,b2,c1,c2 are floats
__CLPK_integer info;
__CLPK_integer n=2;
__CLPK_integer nb=1;
__CLPK_integer ipiv[n];
float A[n][n];
A[0][0]=a1;
A[0][1]=a2;
A[1][0]=b1;
A[1][1]=b2;
float B[n];
B[0]=-c1;
B[1]=-c2;
sgesv_(&n, &nb, A, &n, ipiv, B, &n, &info);
The third parameter is meant to be a
float *but you’re passing a 2D array of float. It just so happens that these floats are in the right order. To get rid of the warning you can do this:or this:
or even this:
Or you could just “flatten” your A array, e.g.