PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
testing_zlange.c
Go to the documentation of this file.
1 
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <math.h>
20 
21 #include <plasma.h>
22 #include <cblas.h>
23 #include <lapacke.h>
24 #include <core_blas.h>
25 #include "testing_zmain.h"
26 
27 #undef REAL
28 #define COMPLEX
29 
31 char *normstr[4] = { "Max", "One", "Inf", "Fro" };
32 
33 
34 int testing_zlange(int argc, char **argv)
35 {
36  /* Check for number of arguments*/
37  if ( argc != 3) {
38  USAGE("LANGE", "M N LDA",
39  " - M : number of rows of matrices A and C\n"
40  " - N : number of columns of matrices B and C\n"
41  " - LDA : leading dimension of matrix A\n");
42  return -1;
43  }
44 
45  int M = atoi(argv[0]);
46  int N = atoi(argv[1]);
47  int LDA = atoi(argv[2]);
48  int LDAxN = LDA*N;
49  int n, u;
50  double eps;
51 
52  PLASMA_Complex64_t *A = (PLASMA_Complex64_t *)malloc(LDAxN*sizeof(PLASMA_Complex64_t));
53  double *work = (double*) malloc(max(M,N)*sizeof(double));
54  double normplasma, normlapack;
55 
56  eps = LAPACKE_dlamch_work('e');
57 
58  printf("\n");
59  printf("------ TESTS FOR PLASMA ZLANGE ROUTINE ------- \n");
60  printf(" Size of the Matrix %d by %d\n", M, N);
61  printf("\n");
62  printf(" The matrix A is randomly generated for each test.\n");
63  printf("============\n");
64  printf(" The relative machine precision (eps) is to be %e \n",eps);
65  printf(" Computational tests pass if scaled residuals are less than 10.\n");
66 
67  /*----------------------------------------------------------
68  * TESTING ZLANGE
69  */
70 
71  /* Initialize A, B, C */
72  LAPACKE_zlarnv_work(IONE, ISEED, LDAxN, A);
73 
74  /* PLASMA ZLANGE */
75  for(n=0; n<3; n++) {
76  normplasma = PLASMA_zlange(norm[n], M, N, A, LDA, work);
77  normlapack = LAPACKE_zlange_work(LAPACK_COL_MAJOR, lapack_const(norm[n]), M, N, A, LDA, work);
78 
79  printf("Lapack %e, Plasma %e\n", normlapack, normplasma);
80 
81  printf("***************************************************\n");
82  if ( abs(normlapack-normplasma) < eps ) {
83  printf(" ---- TESTING ZLANGE (%s)............... PASSED !\n", normstr[n]);
84  }
85  else {
86  printf(" - TESTING ZLANGE (%s)... FAILED !\n", normstr[n]);
87  }
88  printf("***************************************************\n");
89  }
90 
91  /* PLASMA ZLANSY */
92  for(n=0; n<3; n++) {
93  for(u=0; u<2; u++) {
94  normplasma = PLASMA_zlansy(norm[n], uplo[u], min(M,N), A, LDA, work);
95  normlapack = LAPACKE_zlansy_work(LAPACK_COL_MAJOR, lapack_const(norm[n]), lapack_const(uplo[u]), min(M,N), A, LDA, work);
96 
97  printf("Lapack %e, Plasma %e\n", normlapack, normplasma);
98 
99  printf("***************************************************\n");
100  if ( abs(normlapack-normplasma) < eps ) {
101  printf(" ---- TESTING ZLANSY (%s, %s)......... PASSED !\n", normstr[n], uplostr[u]);
102  }
103  else {
104  printf(" - TESTING ZLANSY (%s, %s)... FAILED !\n", normstr[n], uplostr[u]);
105  }
106  printf("***************************************************\n");
107  }
108  }
109 
110 #ifdef COMPLEX
111  /* PLASMA ZLANHE */
112  {
113  int j;
114  for (j=0; j<min(M,N); j++) {
115  A[j*LDA+j] -= I*cimag(A[j*LDA+j]);
116  }
117  }
118 
119  for(n=0; n<3; n++) {
120  for(u=0; u<2; u++) {
121  normplasma = PLASMA_zlanhe(norm[n], uplo[u], min(M,N), A, LDA, work);
122  normlapack = LAPACKE_zlanhe_work(LAPACK_COL_MAJOR, lapack_const(norm[n]), lapack_const(uplo[u]), min(M,N), A, LDA, work);
123 
124  printf("Lapack %e, Plasma %e\n", normlapack, normplasma);
125 
126  printf("***************************************************\n");
127  if ( abs(normlapack-normplasma) < eps ) {
128  printf(" ---- TESTING ZLANHE (%s, %s)......... PASSED !\n", normstr[n], uplostr[u]);
129  }
130  else {
131  printf(" - TESTING ZLANHE (%s, %s)... FAILED !\n", normstr[n], uplostr[u]);
132  }
133  printf("***************************************************\n");
134  }
135  }
136 #endif
137 
138  free(A); free(work);
139  return 0;
140 }