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:
sgesv_(&n, &nb, &A[0][0], &n, ipiv, B, &n, &info);
or this:
sgesv_(&n, &nb, A[0], &n, ipiv, B, &n, &info);
or even this:
sgesv_(&n, &nb, (float *)A, &n, ipiv, B, &n, &info);
Or you could just "flatten" your A array, eg
float A[n * n];
A[0 * n + 0] = a1;
A[0 * n + 1] = a2;
A[1 * n + 0] = b1;
A[1 * n + 1] = b2;
// ...
sgesv_(&n, &nb, A, &n, ipiv, B, &n, &info);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.