From dde0e82eb7a5a5500e27071e344e8afe4e336049 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 11 Mar 2017 22:45:31 -0500 Subject: Update with almost working poser information stuff. This has been long stream to live. Goobye. --- redist/dclapack.h | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ redist/linmath.h | 1 + redist/lintest.c | 3 +- 3 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 redist/dclapack.h (limited to 'redist') diff --git a/redist/dclapack.h b/redist/dclapack.h new file mode 100644 index 0000000..4e209d3 --- /dev/null +++ b/redist/dclapack.h @@ -0,0 +1,225 @@ +#ifndef __DCLAPACK_H__ +#define __DCLAPACK_H__ + +#ifndef ORDER +#define ORDER 50 +#endif + +#ifndef FLOAT +#define FLOAT float +#endif + +#include + +#define _ABS(a) ( (a)<=0 ? 0-(a) : (a) ) + +/* + * Prints a matrix A (n by m) + */ +#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=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]; \ + } \ + } \ +} + +/* + * Inverts a matrix X (n by n) using the method of LU decomposition + */ +#define INV(A,Ainv,n) { \ + FLOAT Ipiv[ORDER][ORDER]; \ + FLOAT L[ORDER][ORDER]; \ + FLOAT U[ORDER][ORDER]; \ + FLOAT I[ORDER][ORDER]; \ + FLOAT C[ORDER][ORDER]; \ + int Piv[ORDER]; \ + IDENTITY(I,n); \ + LU(A,L,U,Piv,n); \ + PIVOT(I,Ipiv,Piv,n,n); \ + L_SUB(L,C,Ipiv,n,n); \ + U_SUB(U,Ainv,C,n,n); \ +} + +/* +PRINT(A,n,n); \ +PRINT(L,n,n); \ +PRINT(U,n,n); \ +MUL(L,U,LU,n,n,n);\ +PRINT(LU,n,n);\ +PRINT(C,n,n); \ +PRINT(Ainv,n,n); \ +*/ + +/* + * Matrix Multiply C = A * B + * A (n by m) + * B (m by p) + * C (n by p) + */ +#define MUL(A,B,C,n,m,p) { \ + int i,j,k; \ + for (i=0; i