39 {
40
41
43 int i, j;
44
45 double *A, *b;
47
48
50
51
52 for( i = 1; i < argc; i++ ) {
53 if( strcmp( argv[i], "-n" ) == 0 ) {
55 i++;
56 }
57 if( strcmp( argv[i], "-nrhs" ) == 0 ) {
58 nrhs = atoi(argv[i+1]);
59 i++;
60 }
61 }
62
63
65 A = (
double *)malloc(
n*
n*
sizeof(
double)) ;
66 if (A==NULL){ printf("error of memory allocation\n"); exit(0); }
67 b = (
double *)malloc(
n*nrhs*
sizeof(
double)) ;
68 if (b==NULL){ printf("error of memory allocation\n"); exit(0); }
70 if (ipiv==NULL){ printf("error of memory allocation\n"); exit(0); }
71
72 for( i = 0; i <
n; i++ ) {
73 for( j = 0; j <
n; j++ ) A[i*lda+j] = ((
double) rand()) / ((double) RAND_MAX) - 0.5;
74 }
75
77 b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
78
79
81
83 printf( "\n" );
84
85 printf( "LAPACKE_dgesv (row-major, high-level) Example Program Results\n" );
86
88 b, ldb );
89
90 if( info > 0 ) {
91 printf( "The diagonal element of the triangular factor of A,\n" );
92 printf( "U(%i,%i) is zero, so that A is singular;\n", info, info );
93 printf( "the solution could not be computed.\n" );
94 exit( 1 );
95 }
96 if (info <0) exit( 1 );
97
99
101
103 exit( 0 );
104}
lapack_int LAPACKE_dgesv(int matrix_layout, lapack_int n, lapack_int nrhs, double *a, lapack_int lda, lapack_int *ipiv, double *b, lapack_int ldb)
void print_matrix_rowmajor(char *desc, lapack_int m, lapack_int n, double *mat, lapack_int ldm)
void print_vector(char *desc, lapack_int n, lapack_int *vec)