LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
 All Classes Files Functions Variables Typedefs Macros
example_user.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "lapacke.h"
Include dependency graph for example_user.c:

Go to the source code of this file.

Macros

#define N   5
 
#define NRHS   3
 
#define LDA   N
 
#define LDB   NRHS
 

Functions

void print_matrix (char *desc, lapack_int m, lapack_int n, double *a, lapack_int lda)
 
void print_int_vector (char *desc, lapack_int n, lapack_int *a)
 
int main ()
 

Macro Definition Documentation

#define LDA   N

Definition at line 12 of file example_user.c.

#define LDB   NRHS

Definition at line 13 of file example_user.c.

#define N   5

Definition at line 10 of file example_user.c.

#define NRHS   3

Definition at line 11 of file example_user.c.

Function Documentation

int main ( )

Definition at line 16 of file example_user.c.

16  {
17  /* Locals */
18  lapack_int n = N, nrhs = NRHS, lda = LDA, ldb = LDB, info;
19  /* Local arrays */
20  lapack_int ipiv[N];
21  double a[LDA*N] = {
22  6.80, -6.05, -0.45, 8.32, -9.67,
23  -2.11, -3.30, 2.58, 2.71, -5.14,
24  5.66, 5.36, -2.70, 4.35, -7.26,
25  5.97, -4.44, 0.27, -7.17, 6.08,
26  8.23, 1.08, 9.04, 2.14, -6.87
27  };
28  double b[LDB*N] = {
29  4.02, -1.56, 9.81,
30  6.19, 4.00, -4.09,
31  -8.22, -8.67, -4.57,
32  -7.57, 1.75, -8.61,
33  -3.03, 2.86, 8.99
34  };
35 
36  double aNorm;
37  double rcond;
38  char ONE_NORM = '1';
39  lapack_int NROWS = n;
40  lapack_int NCOLS = n;
41  lapack_int LEADING_DIMENSION_A = n;
42 
43  /* Print Entry Matrix */
44  print_matrix( "Entry Matrix A", n, n, a, lda );
45  /* Print Right Rand Side */
46  print_matrix( "Right Rand Side", n, nrhs, b, ldb );
47  printf( "\n" );
48  /* Executable statements */
49  printf( "LAPACKE_dgecon Example Program Results\n" );
50  aNorm = LAPACKE_dlange(LAPACK_ROW_MAJOR, ONE_NORM, NROWS, NCOLS, a, LEADING_DIMENSION_A);
51  info = LAPACKE_dgetrf(LAPACK_ROW_MAJOR, NROWS, NCOLS, a, LEADING_DIMENSION_A, ipiv);
52  info = LAPACKE_dgecon(LAPACK_ROW_MAJOR, ONE_NORM, n, a, LEADING_DIMENSION_A, aNorm, &rcond); // aNorm should be 35.019999999999996
53  double work[4*N];
54  int iwork[N];
55  //info = LAPACKE_dgecon_work(LAPACK_ROW_MAJOR, ONE_NORM, n, a, LEADING_DIMENSION_A, aNorm, &rcond, work, iwork); // aNorm should be 35.019999999999996
56  //dgecon_( &ONE_NORM, &n, a, &LEADING_DIMENSION_A, &aNorm, &rcond, work, iwork, &info );
57  /* Check for the exact singularity */
58  if (info == 0)
59  {
60  printf("LAPACKE_dgecon completed SUCCESSFULLY...\n");
61  }
62  else if ( info < 0 )
63  {
64  printf( "Element %d of A had an illegal value\n", -info );
65  exit( 1 );
66  }
67  else
68  {
69  printf( "Unrecognized value of INFO = %d\n", info );
70  exit( 1 );
71  }
72 
73  /* Print solution */
74  printf("LAPACKE_dlange / One-norm of A = %lf\n", aNorm);
75  printf("LAPACKE_dgecon / RCOND of A = %f\n", rcond);
76  exit( 0 );
77 } /* End of LAPACKE_dgesv Example */

Here is the call graph for this function:

void print_int_vector ( char *  desc,
lapack_int  n,
lapack_int a 
)

Definition at line 90 of file example_user.c.

90  {
91  lapack_int j;
92  printf( "\n %s\n", desc );
93  for( j = 0; j < n; j++ ) printf( " %6i", a[j] );
94  printf( "\n" );
95 }
void print_matrix ( char *  desc,
lapack_int  m,
lapack_int  n,
double *  a,
lapack_int  lda 
)

Definition at line 80 of file example_user.c.

80  {
81  lapack_int i, j;
82  printf( "\n %s\n", desc );
83  for( i = 0; i < m; i++ ) {
84  for( j = 0; j < n; j++ ) printf( " %6.2f", a[i*lda+j] );
85  printf( "\n" );
86  }
87 }

Here is the caller graph for this function: