sp_matrix.h
Go to the documentation of this file.
1 /*
2  J. Neira
3  J. A. Castellanos
4  Robotics and Real Time Group
5  University of Zaragoza
6 
7  sp_matrix.h
8  Implements basic MATRIX operations
9 */
10 
11 #ifndef _SP_MATRIX_H
12 #define _SP_MATRIX_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define MAX_ROWS (7)
19 #define MAX_COLS (7)
20 
21 typedef struct {
22  int rows;
23  int cols;
24  float data[MAX_ROWS][MAX_COLS];
25 } MATRIX;
26 
27 typedef struct {
28  int elements;
29  float data[MAX_ROWS];
30 } VECTOR;
31 
32 #define DOF (3)
33 
34 typedef struct {
35  int mat[DOF];
36  int range;
37 } BMAT;
38 
39 #define MROWS(m) ((m).rows)
40 #define MCOLS(m) ((m).cols)
41 #define MDATA(m,i,j) ((m).data[i][j])
42 
43 #define VELEMENTS(v) ((v).elements)
44 #define VDATA(v,i) ((v).data[i])
45 
46 #define M_SQUARE(m) ((m).rows == (m).cols)
47 #define M_COMPAT_DIM(m, n) ((m).cols == (n).rows)
48 #define M_EQUAL_DIM(m, n) (((m).rows == (n).rows) && ((m).cols == (n).cols))
49 #define V_EQUAL_DIM(v, w) (((v).elements == (w).elements))
50 #define MV_COMPAT_DIM(m, v) ((m).cols == (v).elements)
51 
52 #define FIRST(b) ((b).mat[0])
53 #define SECOND(b) ((b).mat[1])
54 #define THIRD(b) ((b).mat[2])
55 #define RANGE(b) ((b).range)
56 
57 #define SQUARE(x) ((x)*(x))
58 
59 MATRIX create_matrix (int rows, int cols);
60 void initialize_matrix (MATRIX *m, int rows, int cols);
61 void diagonal_matrix (MATRIX *m, int dim, float el1, float el2, float el3);
62 void print_matrix (char *message, MATRIX const *m);
63 VECTOR create_vector (int elements);
64 void initialize_vector (VECTOR *v, int elements);
65 void print_vector (char *message, VECTOR const *v);
66 float cross_product (MATRIX const *m, int f1, int c1, int f2, int c2);
67 int determinant (MATRIX const *m, float *result);
68 int inverse_matrix (MATRIX const *m, MATRIX *n);
69 int multiply_matrix_vector (MATRIX const *m, VECTOR const *v, VECTOR *r);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif
76 
Definition: sp_matrix.h:34
MATRIX create_matrix(int rows, int cols)
Definition: sp_matrix.c:5
float cross_product(MATRIX const *m, int f1, int c1, int f2, int c2)
Definition: sp_matrix.c:129
void initialize_matrix(MATRIX *m, int rows, int cols)
Definition: sp_matrix.c:28
int cols
Definition: sp_matrix.h:23
#define MAX_ROWS
Definition: sp_matrix.h:18
void print_matrix(char *message, MATRIX const *m)
Definition: sp_matrix.c:49
#define MAX_COLS
Definition: sp_matrix.h:19
void print_vector(char *message, VECTOR const *v)
Definition: sp_matrix.c:109
int multiply_matrix_vector(MATRIX const *m, VECTOR const *v, VECTOR *r)
Definition: sp_matrix.c:223
#define m(v1, v2)
Definition: egsl_macros.h:13
int inverse_matrix(MATRIX const *m, MATRIX *n)
Definition: sp_matrix.c:166
void initialize_vector(VECTOR *v, int elements)
Definition: sp_matrix.c:92
#define DOF
Definition: sp_matrix.h:32
int elements
Definition: sp_matrix.h:28
int rows
Definition: sp_matrix.h:22
void diagonal_matrix(MATRIX *m, int dim, float el1, float el2, float el3)
int range
Definition: sp_matrix.h:36
VECTOR create_vector(int elements)
Definition: sp_matrix.c:71
int determinant(MATRIX const *m, float *result)
Definition: sp_matrix.c:138


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23