From 783a88f8904b5758195f96c65c7e0b6e87f8a51e Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 01:00:07 -0400 Subject: Update DCLapack with the C helpers to cize stuff. --- redist/dclhelpers.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 redist/dclhelpers.h (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h new file mode 100644 index 0000000..fbaa7ec --- /dev/null +++ b/redist/dclhelpers.h @@ -0,0 +1,61 @@ +#ifndef _DCL_HELPERS_H +#define _DCL_HELPERS_H + +#define DCL_FLOAT FLT + +//XXX XXX XXX WARNING XXX XXX XXX The argument order may be changing!!! + +/* Prints matrix A of size[n][m] */ +void dclPrint( const DCL_FLOAT * A, int n, int m ); + +/* Returns the identity matrix */ +void dclIdentity( DCL_FLOAT * A, int n ); + +/* B = Transpose(A) + A is (n by m) + B is (m by n) */ +void dclTransp( const DCL_FLOAT * A, DCL_FLOAT * B, int n, int m ); + +/* Calculate L,U of a matrix A with pivot table; the pivot table is output. */ +void dclLU( const DCL_FLOAT * A, DCL_FLOAT * L, DCL_FLOAT * U, int * Piv, int n ); + +/* Pivots a matrix to a different matrix + B = Pivot(A) given table 'Piv' + A and B are (n by m) */ +void dclPivot( const DCL_FLOAT * A, DCL_FLOAT * B, int * Piv, int n, int m ); + +/* Solve LX=B for matrix X and B + L is n by n (lower triangular) + B is n by m */ +void dclLSub( const DCL_FLOAT * L, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ); + +/* Solve UX=B for matrix X and B + U is n by n (upper triangular) + B is n by m */ +void dclUSub( const DCL_FLOAT * U, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ); + +/* Inverts a matrix X (n by n) using the method of LU decomposition */ +void dclInv( const DCL_FLOAT * A, DCL_FLOAT * Ainv, int n ); + +/* Matrix Multiply C = A * B + A (n by m) + B (m by p) + C (n by p) */ +void dclMul( const DCL_FLOAT * A, const DCL_FLOAT * B, DCL_FLOAT * C, int n, int m, int p ); + +/* Matrix Multiply D = A * B + C + A (n by m) + B (m by p) + C (n by p) + D (n by p) */ +void dclMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, int n, int m, int p ); + +/* Matrix Multiply D = alpha * A * B + beta * C + A (n by m) + B (m by p) + C (n by p) + D (n by p) */ +void dclGMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); + +#endif + -- cgit v1.2.3 From 8b9a196232661bd6506a41b7ceca015d684086a8 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 01:13:28 -0400 Subject: Update variable ordering... --- redist/dclhelpers.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index fbaa7ec..4ada24a 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -11,51 +11,51 @@ void dclPrint( const DCL_FLOAT * A, int n, int m ); /* Returns the identity matrix */ void dclIdentity( DCL_FLOAT * A, int n ); -/* B = Transpose(A) +/* R = Transpose(A) A is (n by m) - B is (m by n) */ -void dclTransp( const DCL_FLOAT * A, DCL_FLOAT * B, int n, int m ); + R is (m by n) */ +void dclTransp( DCL_FLOAT * R, const DCL_FLOAT * A, int n, int m ); /* Calculate L,U of a matrix A with pivot table; the pivot table is output. */ -void dclLU( const DCL_FLOAT * A, DCL_FLOAT * L, DCL_FLOAT * U, int * Piv, int n ); +void dclLU( DCL_FLOAT * L, DCL_FLOAT * U, const DCL_FLOAT * A, int * Piv, int n ); /* Pivots a matrix to a different matrix - B = Pivot(A) given table 'Piv' - A and B are (n by m) */ -void dclPivot( const DCL_FLOAT * A, DCL_FLOAT * B, int * Piv, int n, int m ); + R = Pivot(A) given table 'Piv' + A and R are (n by m) */ +void dclPivot( DCL_FLOAT * R, const DCL_FLOAT * A, int * Piv, int n, int m ); /* Solve LX=B for matrix X and B L is n by n (lower triangular) B is n by m */ -void dclLSub( const DCL_FLOAT * L, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ); +void dclLSub( DCL_FLOAT * X, const DCL_FLOAT * L, const DCL_FLOAT * B, int n, int m ); /* Solve UX=B for matrix X and B U is n by n (upper triangular) B is n by m */ -void dclUSub( const DCL_FLOAT * U, DCL_FLOAT * X, const DCL_FLOAT * B, int n, int m ); +void dclUSub( DCL_FLOAT * X, const DCL_FLOAT * U, const DCL_FLOAT * B, int n, int m ); /* Inverts a matrix X (n by n) using the method of LU decomposition */ -void dclInv( const DCL_FLOAT * A, DCL_FLOAT * Ainv, int n ); +void dclInv( DCL_FLOAT * Ainv, const DCL_FLOAT * A, int n ); /* Matrix Multiply C = A * B A (n by m) B (m by p) C (n by p) */ -void dclMul( const DCL_FLOAT * A, const DCL_FLOAT * B, DCL_FLOAT * C, int n, int m, int p ); +void dclMul( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, int n, int m, int p ); /* Matrix Multiply D = A * B + C A (n by m) B (m by p) C (n by p) D (n by p) */ -void dclMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, int n, int m, int p ); +void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, int n, int m, int p ); /* Matrix Multiply D = alpha * A * B + beta * C A (n by m) B (m by p) C (n by p) D (n by p) */ -void dclGMulAdd( const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT * D, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); +void dclGMulAdd( DCL_FLOAT * D, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); #endif -- cgit v1.2.3 From 9bd8c4c5ed38d186c04ea318722ca54b2f9c8ea1 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 01:39:04 -0400 Subject: Fix other comments in .h file. --- redist/dclhelpers.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index 4ada24a..fd86c78 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -37,25 +37,25 @@ void dclUSub( DCL_FLOAT * X, const DCL_FLOAT * U, const DCL_FLOAT * B, int n, in /* Inverts a matrix X (n by n) using the method of LU decomposition */ void dclInv( DCL_FLOAT * Ainv, const DCL_FLOAT * A, int n ); -/* Matrix Multiply C = A * B +/* Matrix Multiply R = A * B A (n by m) B (m by p) - C (n by p) */ + R (n by p) */ void dclMul( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, int n, int m, int p ); -/* Matrix Multiply D = A * B + C +/* Matrix Multiply R = A * B + C A (n by m) B (m by p) C (n by p) - D (n by p) */ + R (n by p) */ void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, int n, int m, int p ); -/* Matrix Multiply D = alpha * A * B + beta * C +/* Matrix Multiply R = alpha * A * B + beta * C A (n by m) B (m by p) C (n by p) - D (n by p) */ -void dclGMulAdd( DCL_FLOAT * D, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); + R (n by p) */ +void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); #endif -- cgit v1.2.3 From bcf08b95ab6daa7ac7bffe1449fa8a11cad2a02a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 02:28:11 -0400 Subject: Get closer to functional. --- redist/dclhelpers.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index fd86c78..fd4e02d 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -57,5 +57,29 @@ void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const D R (n by p) */ void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); + +/******************************** + * Auxiliary functionality in C * + ********************************/ + +//Matches dgemm from lapack. +void dcldgemm( + char transA, + char transB, + int m, + int n, + int k, + DCL_FLOAT alpha, + const DCL_FLOAT* A, + int lda, //must be n + const DCL_FLOAT* B, + int ldb, //must be m + DCL_FLOAT beta, + const DCL_FLOAT * C, + int ldc //must be n + ); + + + #endif -- cgit v1.2.3 From 08eec7a6bd5edc0fd1cae7f98d7788ea3905a467 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 03:05:21 -0400 Subject: Now wrangled with ability to use submatricies. --- redist/dclhelpers.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index fd4e02d..5010e02 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -6,56 +6,56 @@ //XXX XXX XXX WARNING XXX XXX XXX The argument order may be changing!!! /* Prints matrix A of size[n][m] */ -void dclPrint( const DCL_FLOAT * A, int n, int m ); +void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ); /* Returns the identity matrix */ -void dclIdentity( DCL_FLOAT * A, int n ); +void dclIdentity( DCL_FLOAT * I, int Ic, int n ); /* R = Transpose(A) A is (n by m) R is (m by n) */ -void dclTransp( DCL_FLOAT * R, const DCL_FLOAT * A, int n, int m ); +void dclTransp( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int n, int m ); /* Calculate L,U of a matrix A with pivot table; the pivot table is output. */ -void dclLU( DCL_FLOAT * L, DCL_FLOAT * U, const DCL_FLOAT * A, int * Piv, int n ); +void dclLU( DCL_FLOAT * L, int Lc, DCL_FLOAT * U, int Uc, const DCL_FLOAT * A, int Ac, int * Piv, int n ); /* Pivots a matrix to a different matrix R = Pivot(A) given table 'Piv' A and R are (n by m) */ -void dclPivot( DCL_FLOAT * R, const DCL_FLOAT * A, int * Piv, int n, int m ); +void dclPivot( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int * Piv, int n, int m ); /* Solve LX=B for matrix X and B L is n by n (lower triangular) B is n by m */ -void dclLSub( DCL_FLOAT * X, const DCL_FLOAT * L, const DCL_FLOAT * B, int n, int m ); +void dclLSub( DCL_FLOAT * X, int Xc, const DCL_FLOAT * L, int Lc, const DCL_FLOAT * B, int Bc, int n, int m ); /* Solve UX=B for matrix X and B U is n by n (upper triangular) B is n by m */ -void dclUSub( DCL_FLOAT * X, const DCL_FLOAT * U, const DCL_FLOAT * B, int n, int m ); +void dclUSub( DCL_FLOAT * X, int Xc, const DCL_FLOAT * U, int Uc, const DCL_FLOAT * B, int Bc, int n, int m ); /* Inverts a matrix X (n by n) using the method of LU decomposition */ -void dclInv( DCL_FLOAT * Ainv, const DCL_FLOAT * A, int n ); +void dclInv( DCL_FLOAT * Ainv, int Ainvc, const DCL_FLOAT * A, int Ac, int n ); /* Matrix Multiply R = A * B A (n by m) B (m by p) R (n by p) */ -void dclMul( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, int n, int m, int p ); +void dclMul( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, int n, int m, int p ); /* Matrix Multiply R = A * B + C A (n by m) B (m by p) C (n by p) R (n by p) */ -void dclMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, int n, int m, int p ); +void dclMulAdd( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, const DCL_FLOAT * C, int Cc, int n, int m, int p ); /* Matrix Multiply R = alpha * A * B + beta * C A (n by m) B (m by p) C (n by p) R (n by p) */ -void dclGMulAdd( DCL_FLOAT * R, const DCL_FLOAT * A, const DCL_FLOAT * B, const DCL_FLOAT * C, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); +void dclGMulAdd( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, const DCL_FLOAT * B, int Bc, const DCL_FLOAT * C, int Cc, DCL_FLOAT alpha, DCL_FLOAT beta, int n, int m, int p ); /******************************** @@ -71,12 +71,12 @@ void dcldgemm( int k, DCL_FLOAT alpha, const DCL_FLOAT* A, - int lda, //must be n + int Ac, const DCL_FLOAT* B, - int ldb, //must be m + int Bc, DCL_FLOAT beta, const DCL_FLOAT * C, - int ldc //must be n + int Cc ); -- cgit v1.2.3 From f0c26bd1b0b8ffe05c0c5f04567a9b7aa47c3e6b Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 03:15:46 -0400 Subject: Update dclapack to do automatic size-of-array'ing --- redist/dclhelpers.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index 5010e02..8779e1a 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -3,8 +3,6 @@ #define DCL_FLOAT FLT -//XXX XXX XXX WARNING XXX XXX XXX The argument order may be changing!!! - /* Prints matrix A of size[n][m] */ void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ); @@ -75,7 +73,7 @@ void dcldgemm( const DCL_FLOAT* B, int Bc, DCL_FLOAT beta, - const DCL_FLOAT * C, + DCL_FLOAT * C, int Cc ); -- cgit v1.2.3 From 04bd16aeb391e67716344268cf0f43d1f31f180a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 17 Mar 2018 14:21:20 -0400 Subject: Update dcl and test. --- redist/dclhelpers.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'redist/dclhelpers.h') diff --git a/redist/dclhelpers.h b/redist/dclhelpers.h index 8779e1a..b4acec8 100644 --- a/redist/dclhelpers.h +++ b/redist/dclhelpers.h @@ -3,11 +3,17 @@ #define DCL_FLOAT FLT +//Use this macro to safely +#define DMS( m ) ((m)[0]), (sizeof((m)[0])/sizeof((m)[0][0])) + /* Prints matrix A of size[n][m] */ void dclPrint( const DCL_FLOAT * A, int Ac, int n, int m ); /* Returns the identity matrix */ -void dclIdentity( DCL_FLOAT * I, int Ic, int n ); +void dclIdentity( DCL_FLOAT * I, int Ic, int m, int n ); + +/* Returns the zero matrix */ +void dclZero( DCL_FLOAT * I, int Ic, int m, int n ); /* R = Transpose(A) A is (n by m) -- cgit v1.2.3