diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-05-08 21:33:24 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-05-08 21:33:24 -0700 |
commit | 04c688f125069b65517b00660c31c81e210ddf3a (patch) | |
tree | 5a92bd41181ae1c8c586f7da701c4c1115bd5dd5 /include/libmath.h | |
parent | 327ca20a2a89d2408b53ff7854982560304cb76c (diff) |
Adding strided computation to blas kernels.
I started implementing LQ factorization and immediately realized I needed strided views.
For simplicity, I will just implement them in the most portable, C native way (no vectorization).
Speed can come later.
Diffstat (limited to 'include/libmath.h')
-rw-r--r-- | include/libmath.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/include/libmath.h b/include/libmath.h index b0ae434..1da414a 100644 --- a/include/libmath.h +++ b/include/libmath.h @@ -148,11 +148,13 @@ typedef uint32 blas·Flag; void blas·rot(int len, double *x, double *y, double cos, double sin); void blas·rotg(double *a, double *b, double *cos, double *sin); error blas·rotm(int len, double *x, double *y, double p[5]); -void blas·scale(int len, double *x, double a); +void blas·scale(int len, double a, double *x); void blas·copy(int len, double *x, double *y); void blas·swap(int len, double *x, double *y); void blas·axpy(int len, double a, double *x, double *y); -double blas·dot(int len, double *x, double *y); +double blas·dot(int len, double *x, int incx, double *y, int incy); +double blas·norm(int len, double *x); +double blas·sum(int len, double *x); int blas·argmax(int len, double *x); int blas·argmin(int len, double *x); @@ -172,25 +174,19 @@ void blas·trsm(blas·Flag f, int nrow, int ncol, double a, double *m1, double // ----------------------------------------------------------------------- // higher level linear algebra -struct linalg·Header -{ - void *h; - mem·Allocator heap; - - double *data; -}; - typedef struct math·Vector { - int len; - struct linalg·Header; + double *data; + int len; } math·Vector; +#define math·slicev(vec, lo, hi) (struct math·Vector){.len=((hi)-(lo)), .data=((vec).data + (lo))} + typedef struct math·Matrix { - int dim[2]; + double *data; blas·Flag kind; - struct linalg·Header; + int dim[2]; } math·Matrix; // TODO: tensor ala numpy |