convert lapacke example to cxx
This commit is contained in:
parent
6017dbbfa6
commit
e399058e37
@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined HAVE_MKL_LAPACK
|
|
||||||
|
#if defined HAVE_MKL_LAPACK
|
||||||
#include <mkl_lapacke.h>
|
#include <mkl_lapacke.h>
|
||||||
#include <mkl_cblas.h>
|
#include <mkl_cblas.h>
|
||||||
#pragma message "Using Intel MKL c-lapack interface, <mkl_lapacke.h>."
|
#pragma message "Using Intel MKL c-lapack interface, <mkl_lapacke.h>."
|
||||||
@ -14,12 +15,12 @@
|
|||||||
#pragma message "Using ATLAS/SYSTEM_NATIVE C lapack interface, <clapack.h>."
|
#pragma message "Using ATLAS/SYSTEM_NATIVE C lapack interface, <clapack.h>."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void main(void)
|
int main()
|
||||||
{
|
{
|
||||||
int i,j,n=3;
|
const int n = 3;
|
||||||
double a[n*n],b[n],small = 1.0e-12;
|
|
||||||
int ierr,ipiv[n];
|
double a[n*n];
|
||||||
int roots_ok=0;
|
double b[n];
|
||||||
|
|
||||||
a[0] = 2.00;
|
a[0] = 2.00;
|
||||||
a[1] = 1.00;
|
a[1] = 1.00;
|
||||||
@ -35,18 +36,28 @@ void main(void)
|
|||||||
b[1] = 3.00;
|
b[1] = 3.00;
|
||||||
b[2] = 5.00;
|
b[2] = 5.00;
|
||||||
|
|
||||||
|
int ierr;
|
||||||
|
int ipiv[n];
|
||||||
|
|
||||||
/* MKL, OpenBLAS */
|
/* MKL, OpenBLAS */
|
||||||
#if defined HAVE_MKL_LAPACK || defined HAVE_OPENBLAS_LAPACK
|
#if defined HAVE_MKL_LAPACK || defined HAVE_OPENBLAS_LAPACK
|
||||||
ierr = LAPACKE_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
|
ierr = LAPACKE_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
|
||||||
#else /* ATLAS, SYSTEM_NATIVE */
|
#else /* ATLAS, SYSTEM_NATIVE */
|
||||||
ierr = clapack_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
|
ierr = clapack_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n);
|
||||||
#endif
|
#endif
|
||||||
if (ierr != 0) { fprintf(stderr, "\nC dgesv failure with error %d\n", ierr);}
|
if (ierr != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\ndgesv failure with error %i\n", ierr);
|
||||||
|
}
|
||||||
|
|
||||||
if (abs(b[0] + 0.500) <= small &&
|
const double small = 1.0e-12;
|
||||||
abs(b[1] - 0.250) <= small &&
|
|
||||||
abs(b[2] - 0.250) <= small) roots_ok=1;
|
|
||||||
|
|
||||||
if ( roots_ok == 1 ) {fprintf(stdout,"PASSED"); }
|
if (abs(b[0] + 0.50) <= small &&
|
||||||
else {fprintf(stderr,"\nC LAPACK dgesv failure!");}
|
abs(b[1] - 0.25) <= small &&
|
||||||
|
abs(b[2] - 0.25) <= small)
|
||||||
|
{
|
||||||
|
printf("PASSED");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user