From 04c688f125069b65517b00660c31c81e210ddf3a Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 8 May 2020 21:33:24 -0700 Subject: 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. --- include/libmath.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'include') 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 -- cgit v1.2.1