sp_matrix.h
Go to the documentation of this file.
00001 /*
00002   J. Neira
00003   J. A. Castellanos
00004   Robotics and Real Time Group
00005   University of Zaragoza
00006   
00007   sp_matrix.h
00008   Implements basic MATRIX operations
00009 */
00010 
00011 #ifndef _SP_MATRIX_H
00012 #define _SP_MATRIX_H
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 #define MAX_ROWS (7)
00019 #define MAX_COLS (7)
00020 
00021 typedef struct {
00022   int   rows;
00023   int   cols;
00024   float data[MAX_ROWS][MAX_COLS];
00025 } MATRIX;
00026 
00027 typedef struct {
00028   int   elements;
00029   float data[MAX_ROWS];
00030 } VECTOR;
00031 
00032 #define DOF (3)
00033 
00034 typedef struct {
00035   int mat[DOF];
00036   int range;
00037 } BMAT;
00038 
00039 #define MROWS(m)             ((m).rows)
00040 #define MCOLS(m)             ((m).cols)
00041 #define MDATA(m,i,j)         ((m).data[i][j])
00042 
00043 #define VELEMENTS(v)         ((v).elements)
00044 #define VDATA(v,i)           ((v).data[i])
00045 
00046 #define M_SQUARE(m)          ((m).rows == (m).cols)
00047 #define M_COMPAT_DIM(m, n)   ((m).cols == (n).rows)
00048 #define M_EQUAL_DIM(m, n)    (((m).rows == (n).rows)  && ((m).cols == (n).cols))
00049 #define V_EQUAL_DIM(v, w)    (((v).elements == (w).elements))
00050 #define MV_COMPAT_DIM(m, v)  ((m).cols == (v).elements)
00051 
00052 #define FIRST(b)             ((b).mat[0])
00053 #define SECOND(b)            ((b).mat[1])
00054 #define THIRD(b)             ((b).mat[2])
00055 #define RANGE(b)             ((b).range)
00056 
00057 #define SQUARE(x)            ((x)*(x))
00058 
00059 MATRIX create_matrix (int rows, int cols);
00060 void initialize_matrix (MATRIX *m, int rows, int cols);
00061 void diagonal_matrix (MATRIX *m, int dim, float el1, float el2, float el3);
00062 void print_matrix (char *message, MATRIX const *m);
00063 VECTOR create_vector (int elements);
00064 void initialize_vector (VECTOR *v, int elements);
00065 void print_vector (char *message, VECTOR const *v);
00066 float cross_product (MATRIX const *m, int f1, int c1, int f2, int c2);
00067 int determinant (MATRIX const *m, float *result);
00068 int inverse_matrix (MATRIX const *m, MATRIX *n);
00069 int multiply_matrix_vector (MATRIX const *m, VECTOR const *v, VECTOR *r);
00070 
00071 #ifdef __cplusplus
00072 }
00073 #endif
00074 
00075 #endif
00076 


csm
Author(s): Andrea Censi
autogenerated on Fri May 17 2019 02:28:33