Skip to content

Instantly share code, notes, and snippets.

@quantumelixir
Created January 15, 2011 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quantumelixir/780943 to your computer and use it in GitHub Desktop.
Save quantumelixir/780943 to your computer and use it in GitHub Desktop.
Demonstrate how to use cblas
#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