Skip to content

Instantly share code, notes, and snippets.

@simonwhitaker
Created June 26, 2018 18:56
Show Gist options
  • Save simonwhitaker/ed90a1d1b7ab3c6fb3c17a4d35353f56 to your computer and use it in GitHub Desktop.
Save simonwhitaker/ed90a1d1b7ab3c6fb3c17a4d35353f56 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <Accelerate/Accelerate.h>
int main(int argc, const char * argv[]) {
double A[] = {
1.0, 2.0, 3.0,
4.0, 5.0, 6.0
};
double B[] = {
1.0, 2.0,
3.0, 4.0,
5.0, 6.0
};
double C[] = {
0.0, 0.0,
0.0, 0.0
};
cblas_dgemm(
CblasRowMajor, // Order: row-major (C) data ordering (cf. column-major (Fortran)
CblasNoTrans, // TransA: whether to transpose matrix A
CblasNoTrans, // TransB: whether to transpose matrix B
2, // M: rows in A, C
2, // N: cols in B, C
3, // K: cols in A, rows in C
1.0, // alpha: scaling factor for product of A and B
A,
3, // lda: size of first dimention of A (i.e. number of elements in first row?)
B,
2, // ldb: size of first dimension of B (i.e. number of elements in first row?)
1.0, // beta: scaling factor for matrix C
C,
2 // ldc: size of the first dimension of C
);
printf("%.2f %.2f\n", C[0], C[1]);
printf("%.2f %.2f\n", C[2], C[3]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment