/* * Main * for LU Decomposition */ #include #include #include #include #include #include #include #include #include int LUdecomp(float **,int,int *,int *); void LUsubstitute(float **,int,int *,float *); #define DEBUG /* #define DEBUG_LU */ #define SWAP #define TEST_INVERSE /* #define TEST_SOLVING */ #define DEBUG_SWAPS enum { kAlertID = 128 }; static void Initialize(void) { InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); } void main(void) { float **A,**L,**U,**Ainv,**Aorig; float *x; float *b; int dim; int i,j,k; int *rowswaps,val; float temp; int seed; /* Initialize(); */ printf("this program generates a random matrix of nxn"); printf(" input a random number seed: "); scanf("%d",&seed); srand(seed); printf("input dimension: "); scanf("%d",&dim); rowswaps = (int *)malloc(sizeof(int)*dim); A = (float **)malloc(sizeof(float *)*dim); for (i=0; ij) L[i][j] = A[i][j]; } } printf("\nL\n"); for (i=0; ij) U[i][j] =0.0; } } printf("\nU\n"); for (i=0; i