Rev 966 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
968 | MikeW | 1 | /* matmatrix.c |
2 | |||
3 | The following functions are based on the Numerical Recipes. |
||
4 | |||
5 | */ |
||
6 | |||
966 | MikeW | 7 | #ifndef __MATMATH_H__ |
8 | #define __MATMATH_H__ |
||
9 | |||
10 | /***************************************************************************** |
||
11 | INCLUDES |
||
12 | **************************************************************************** */ |
||
13 | #include "math.h" |
||
14 | #include "float.h" |
||
15 | |||
16 | /***************************************************************************** |
||
17 | TYPEDEFS |
||
18 | *****************************************************************************/ |
||
19 | #define f32_t float |
||
20 | #define ui32_t unsigned int |
||
21 | #define i32_t int |
||
22 | |||
23 | #define PI 3.1415926535897932384626433832795 |
||
24 | |||
25 | #define matSetFull(matM,Row,Column,X) matM[Row+1][Column+1] = (X) |
||
26 | #define matSetDiagonal(matM,Row,Column,X) matM[Row+1][Column+1] = (X) |
||
27 | #define matGetFull(matM,Row,Column,X) *(X) = matM[Row+1][Column+1] |
||
28 | #define matGetDiagonal(matM,Row,Column,X) *(X) = matM[Row+1][Column+1] |
||
29 | |||
30 | |||
31 | /* B = A */ |
||
32 | extern void matrix_copy( f32_t **A, f32_t **B, int rows, |
||
33 | int cols ); |
||
34 | |||
35 | /* C = A + B */ |
||
36 | extern void matrix_add( f32_t **A, f32_t **B, f32_t **C, int m, int n ); |
||
37 | |||
38 | /* C = A - B */ |
||
39 | extern void matrix_sub( f32_t **A, f32_t **B, f32_t **C, int m, int n ); |
||
40 | |||
41 | /* C = A x B , A(a_rows x a_cols), B(a_cols x b_cols) */ |
||
42 | extern void matrix_mult( f32_t **A, f32_t **B, f32_t **C, |
||
43 | int a_rows, int a_cols, int b_cols ); |
||
44 | |||
45 | /* C = A x B^T, A(a_rows x a_cols), B(b_cols x a_cols) */ |
||
46 | extern void matrix_mult_transpose( f32_t **A, f32_t **B, f32_t **C, |
||
47 | int a_rows, int a_cols, int b_cols ); |
||
48 | |||
49 | /* C = A^T x B, A(a_cols x a_rows), B(a_cols x b_cols) */ |
||
50 | extern void matrix_transpose_mult( f32_t **A, f32_t **B, f32_t **C, |
||
51 | int a_rows, int a_cols, int b_cols ); |
||
52 | |||
53 | /* B = A^-1 */ |
||
54 | extern void take_inverse( f32_t **A, f32_t **B, int size); |
||
55 | extern void gaussj( f32_t **A, int n, f32_t **B); |
||
56 | |||
57 | /* Matrix allocation routines */ |
||
58 | extern f32_t **matrix(long row_low, long row_high, long column_low, long column_high); |
||
59 | |||
60 | /* Deallocation routines */ |
||
61 | extern void free_matrix(f32_t **m, long row_low, long row_high, long column_low, long column_high); |
||
62 | #endif |