#ifndef __APPLE__ #include #else #include #endif #include #include #include "mathlib.h" #define TINY FLT_MIN void lubksb(float **a, int n, int *indx, float b[]) // Solves the set of n linear equations A.X=B. Here a[n][n] is input, not as the matrix // A but rather as its LU decomposition determined by the routine ludcmp. indx[n] is input // as the permutation vector returned by ludcmp. b[n] is input as the right-hand side vector // B, and returns with the solution vector X. a, n and indx are not modified by this routine // and can be left in place for successive calls with different right-hand sides b. This routine takes // into account the possibility that b will begin with many zero elements, so it is efficient for use // in matrix inversion { int i,ii=-1,ip,j; float sum; for (i=0;i=0) for (j=ii;j=0;i--) { sum=b[i]; for (j=i+1;j big) big=temp; if (big == 0.0) return 1; vv[i]=1.0f/big; } for (j=0;j= big) { big=dum; imax=i; } } if (j != imax) { for (k=0;k