1 /* cblas_example.c */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include "cblas.h"
6
main()7 int main ( )
8 {
9 enum CBLAS_ORDER order;
10 enum CBLAS_TRANSPOSE transa;
11
12 double *a, *x, *y;
13 double alpha, beta;
14 int m, n, lda, incx, incy, i;
15
16 order = CblasColMajor;
17 transa = CblasNoTrans;
18
19 m = 4; /* Size of Column ( the number of rows ) */
20 n = 4; /* Size of Row ( the number of columns ) */
21 lda = 4; /* Leading dimension of 5 * 4 matrix is 5 */
22 incx = 1;
23 incy = 1;
24 alpha = 1;
25 beta = 0;
26
27 a = (double *)malloc(sizeof(double)*m*n);
28 x = (double *)malloc(sizeof(double)*n);
29 y = (double *)malloc(sizeof(double)*n);
30 /* The elements of the first column */
31 a[0] = 1;
32 a[1] = 2;
33 a[2] = 3;
34 a[3] = 4;
35 /* The elements of the second column */
36 a[m] = 1;
37 a[m+1] = 1;
38 a[m+2] = 1;
39 a[m+3] = 1;
40 /* The elements of the third column */
41 a[m*2] = 3;
42 a[m*2+1] = 4;
43 a[m*2+2] = 5;
44 a[m*2+3] = 6;
45 /* The elements of the fourth column */
46 a[m*3] = 5;
47 a[m*3+1] = 6;
48 a[m*3+2] = 7;
49 a[m*3+3] = 8;
50 /* The elemetns of x and y */
51 x[0] = 1;
52 x[1] = 2;
53 x[2] = 1;
54 x[3] = 1;
55 y[0] = 0;
56 y[1] = 0;
57 y[2] = 0;
58 y[3] = 0;
59
60 cblas_dgemv( order, transa, m, n, alpha, a, lda, x, incx, beta,
61 y, incy );
62 /* Print y */
63 for( i = 0; i < n; i++ )
64 printf(" y%d = %f\n", i, y[i]);
65 free(a);
66 free(x);
67 free(y);
68 return 1;
69 }
70