From 5d4f4068ae265271d0840ca1bddd7dfcddd948e9 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sat, 17 Mar 2018 10:33:14 -0600 Subject: Made naming follow conventions --- redist/dclapack.h | 278 +++++++++++++++++++++++++++++------------------------- 1 file changed, 149 insertions(+), 129 deletions(-) (limited to 'redist') diff --git a/redist/dclapack.h b/redist/dclapack.h index af5035b..2823c5d 100644 --- a/redist/dclapack.h +++ b/redist/dclapack.h @@ -19,130 +19,151 @@ #define _(AM,O,P) AM[O][P] #endif - /* - * Prints a matrix A (n by m) (with witdth Ac) + * Prints a matrix A (m by n) (with witdth Ac) */ -#define PRINT(A,n,m) { \ - int i,j; \ - printf(#A "\n"); \ - for (i=0; i _ABS(_(U,max,i))) { max = j; } \ - } \ - _tempi=Piv[i]; Piv[i]=Piv[max]; Piv[max]=_tempi; \ - for (k=i; k _ABS(_(U, max, _i))) { \ + max = _j; \ + } \ + } \ + _tempi = Piv[_i]; \ + Piv[_i] = Piv[max]; \ + Piv[max] = _tempi; \ + for (_k = _i; _k < (n); _k++) { \ + _tempf = _(U, _i, _k); \ + _(U, _i, _k) = _(U, max, _k); \ + _(U, max, _k) = _tempf; \ + } \ + for (_k = 0; _k < _i; _k++) { \ + _tempf = _(L, _i, _k); \ + _(L, _i, _k) = _(L, max, _k); \ + _(L, max, _k) = _tempf; \ + } \ + \ + FLOAT invDiag = 1.0 / _(U, _i, _i); \ + for (_j = _i + 1; _j < (n); _j++) { \ + FLOAT scale = _(U, _j, _i) * invDiag; \ + _(U, _j, _i) = 0.0; \ + for (_k = _i + 1; _k < (n); _k++) { \ + _(U, _j, _k) -= _(U, _i, _k) * scale; \ + } \ + _(L, _j, _i) = scale; \ + } \ + } \ + } /* * Pivots a matrix to a different matrix * R = Pivot(A) given table 'Piv' - * A and R are (n by m) + * A and R are (m by n) */ -#define PIVOT(R,A,Piv,n,m) { \ - int i,j; \ - for (j=0; j=0; j--) { \ - float sum=0.0; \ - for (k=n-1; k>j; k--) { sum += _(U,j,k)*_(X,k,i); } \ - _(X,j,i) = (_(B,j,i) - sum) / _(U,j,j); \ - } \ - } \ -} +#define U_SUB(X, U, B, m, n) \ + { \ + for (int _i = 0; _i < (n); _i++) { \ + for (int _j = m - 1; _j >= 0; _j--) { \ + float sum = 0.0; \ + for (int _k = n - 1; _k > _j; _k--) { \ + sum += _(U, _j, _k) * _(X, _k, _i); \ + } \ + _(X, _j, _i) = (_(B, _j, _i) - sum) / _(U, _j, _j); \ + } \ + } \ + } /* * Inverts a matrix X (n by n) using the method of LU decomposition @@ -187,55 +208,54 @@ PRINT(Ainv,n,n); \ /* * Matrix Multiply R = A * B * R (n by p) - * A (n by m) + * A (m by n) * B (m by p) */ -#define MUL(R,A,B,n,m,p) { \ - int i,j,k; \ - for (i=0; i