00001 /* ________________________________________________________ 00002 | | 00003 | Program Name: matrix.h | 00004 |________________________________________________________| 00005 | | 00006 | description: Contains MATRIX data structure and func- | 00007 | tion declarations and descriptions for matrix.c | 00008 | | 00009 |________________________________________________________| */ 00010 00011 #include <stdlib.h> 00012 #include <IKOR/general.h> 00013 #define SVD_THRESHOLD 1.0e-6 00014 #define PrintIfBiggerThan 0.0e+0 00015 #define TINY 1.0e-20 00016 #define SV_SMALL 1.0e-6 00017 00018 void ludcmp(); /* LU decomposition */ 00019 void lubksb(); /* LU backsubstitution */ 00020 void svdcmp(float **a, int m, int n, float *w, float **v); /* Singular Value Decomposition */ 00021 void svbksb(); /* SVD backsubstitution */ 00022 void mat_free(MATRIX *m); /* Free matrix pointer */ 00023 void mat_pr(MATRIX *a); /* Print matrix (not full precision) */ 00024 void mat_prf(MATRIX *a); /* Print matrix (full precision) */ 00025 void mat_mul(MATRIX *a,MATRIX *b,MATRIX *c); /* Multiplicate two matrices */ 00026 void mat_add(MATRIX *a,MATRIX *b,MATRIX *c); /* Add two matrices */ 00027 void mat_sub(MATRIX *a,MATRIX *b,MATRIX *c); /* Subtract a matrix from another */ 00028 void mat_sca(MATRIX *a,float c); /* Scale a matrix by a factor */ 00029 void mat_LU_inv(MATRIX *a); /* Invert a matrix using LU-dec. */ 00030 void mat_pseudoinv(MATRIX *a); /* Inverse or pseudoinverse using SVD */ 00031 double mat_det(MATRIX *a); /* Determinant using SVD */ 00032 double mat_eigen(MATRIX *a); /* Max eigen value of AtA */ 00033 void mat_tra(MATRIX *a); /* Transpose a matrix */ 00034 void mat_cp(MATRIX *a,MATRIX *cpy); /* Copy a matrix into another */ 00035 00036 float mat_vec_dot(); /* Dot product two vectors: rows 0 of the two matrices */ 00037 void mat_vec_cross();/* Cross product two vectors: rows 0 of the two matrices*/ 00038 float mat_vec_abs(); /* Length (absolute value) of a vector: rows 0 a matrix */ 00039 void mat_null(MATRIX *a, int* n_rank, MATRIX* n, float* K2); 00040 00041 /* All these functions *mat_xxx2() are equivalent to their mat_xxx() function, 00042 * except that they automatically creates the return matrix by allocating 00043 * space for them, and returning the pointer to the MATRIX structure. 00044 */ 00045 00046 MATRIX *mat_malloc(int rows, int cols); /* Matrix allocation */ 00047 MATRIX *mat_mul2(MATRIX *a,MATRIX *b); 00048 MATRIX *mat_cp2(); 00049 MATRIX *mat_add2(MATRIX *a,MATRIX *b); 00050 MATRIX *mat_sub2(MATRIX *a,MATRIX *b); 00051 MATRIX *mat_tra2(MATRIX *A); /* B = mat_tra2(A); is: B = transpose of A */