Created
January 15, 2011 14:32
-
-
Save quantumelixir/780943 to your computer and use it in GitHub Desktop.
Demonstrate how to use cblas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cblas.h> | |
double m[] = { | |
3, 1, 3, | |
1, 5, 9, | |
2, 6, 5 | |
}; | |
double x[] = { | |
-1, -1, 1 | |
}; | |
double y[] = { | |
0, 0, 0 | |
}; | |
int | |
main() | |
{ | |
int i, j; | |
for (i=0; i<3; ++i) { | |
for (j=0; j<3; ++j) printf("%5.1f", m[i*3+j]); | |
putchar('\n'); | |
} | |
cblas_dgemv(CblasRowMajor, CblasNoTrans, 3, 3, 1.0, m, 3, | |
x, 1, 0.0, y, 1); | |
for (i=0; i<3; ++i) printf("%5.1f\n", y[i]); | |
return 0; | |
} | |
// gcc -L/opt/local/lib -lcblas -I/usr/include/malloc/ -o testblas testblas.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment