| |
| |
| #include <stddef.h> |
| #include <stdlib.h> |
| #include <memory> |
| #include <cstring> |
| |
| |
| |
| typedef int blasint; |
| |
| extern "C" { |
| #include "tlin/cblas.h" |
| } |
| |
| #include "tlin/tlin_cblas_wrap.h" |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void sum(int n, const double *x, double *&y) |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| double *_x = const_cast<double *>(x); |
| |
| cblas_daxpy(n, 1.0, _x, 1, y, 1); |
| } |
| |
| |
| |
| void tlin::multiply(int rows, int cols, const double *A, const double *x, double *&y) |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| if (!y) { |
| y = (double *)malloc(rows * sizeof(double)); |
| memset(y, 0, rows * sizeof(double)); |
| } |
| |
| double *_A = const_cast<double *>(A); |
| double *_x = const_cast<double *>(x); |
| |
| cblas_dgemv(CblasColMajor, CblasNoTrans, rows, cols, 1.0, _A, rows, _x, 1, 1.0, y, 1); |
| } |
| |
| |
| |
| void tlin::multiply(const mat &A, const double *x, double *&y) |
| { |
| multiply(A.rows(), A.cols(), A.values(), x, y); |
| } |
| |