/**
@file slvSysC.c
@author Mitch Richling <http://www.mitchr.me/>
@Copyright Copyright 1998 by Mitch Richling. All rights reserved.
@brief Demonstrate LAPACK's sgesv functions.@EOL
@Keywords claback cblas sgesv numerical linear algebra
@Std C99
*/
#include <stdio.h> /* I/O lib ISOC */
#include <stdlib.h> /* Standard Lib ISOC */
#ifdef __APPLE__
#include <vecLib/cblas.h> /* C BLAS APPLE */
#include <vecLib/clapack.h> /* C LAPACK APPLE */
#else
#include <cblas.h> /* C BLAS BLAS */
#include <vecLib/clapack.h> /* C LAPACK APPLE */
#endif
#include "blaio.h" /* Basic Linear Algebra I/O */
int main(int argc, char **argv) {
__CLPK_doublereal a[4*4] = { 1, 2, 3, 4,
6, 7, 9, 9,
11,12,19,14,
16,17,18,12,
};
__CLPK_doublereal b[4] = {1, 3, 5, 6};
__CLPK_integer pivs[4], inf;
__CLPK_integer n=4, lda=4, nrhs=1, ldb=4;
char tbuf[1024];
int i;
sprintf(tbuf, " a[%dx%d]= ", 4, 4);
printMatrix(CblasColMajor, 4, 4, a, 15, 10, NULL, NULL, NULL, NULL, NULL, tbuf);
sprintf(tbuf, " b[%dx%d]= ", 1, 4);
printMatrix(CblasColMajor, 1, 4, b, 15, 10, NULL, NULL, NULL, NULL, NULL, tbuf);
//sgesv_(&n, &nrhs, a, &lda, pivs, b, &ldb, &inf);
dgesv_(&n, &nrhs, a, &lda, pivs, b, &ldb, &inf);
if(inf == 0) {
printf("Successful Solution\n");
} else if(inf < 0) {
printf("Illegal value at: %d\n", -(int)inf);
exit(1);
} else if(inf > 0) {
printf("Matrix was singular\n");
exit(1);
} else {
printf("Unknown Result (Can't happen!)\n");
exit(1);
} /* end if/else */
sprintf(tbuf, "a'[%dx%d]= ", 4, 4);
printMatrix(CblasColMajor, 4, 4, a, 15, 10, NULL, NULL, NULL, NULL, NULL, tbuf);
sprintf(tbuf, "b'[%dx%d]= ", 1, 4);
printMatrix(CblasColMajor, 1, 4, b, 15, 10, NULL, NULL, NULL, NULL, NULL, tbuf);
printf("PIV=");
for(i=0;i<4;i++)
printf("%4d ", (int)(pivs[i]));
printf("\n");
// * IPIV (output) INTEGER array, dimension (N)
// * The pivot indices that define the permutation matrix P;
// * row i of the matrix was interchanged with row IPIV(i).
// *
return 0;
} /* end func main */
Generated by GNU enscript 1.6.4.