sp_matrix.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27 /*
28  J. Neira
29  J. A. Castellanos
30  Robotics and Real Time Group
31  University of Zaragoza
32 
33  sp_matrix.h
34  Implements basic MATRIX operations
35 */
36 /*
37  * This program is free software; you can redistribute it and/or modify
38  * it under the terms of the GNU General Public License as published by
39  * the Free Software Foundation; either version 2 of the License, or
40  * (at your option) any later version.
41  *
42  * This program is distributed in the hope that it will be useful,
43  * but WITHOUT ANY WARRANTY; without even the implied warranty of
44  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  * GNU General Public License for more details.
46  *
47  * You should have received a copy of the GNU General Public License
48  * along with this program; if not, write to the Free Software
49  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50  *
51  */
52 
58 #ifndef _SP_MATRIX_H
59 #define _SP_MATRIX_H
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #define MAX_ROWS (7)
66 #define MAX_COLS (7)
67 
68 typedef struct {
69  int rows;
70  int cols;
71  float data[MAX_ROWS][MAX_COLS];
72 } MATRIX;
73 
74 typedef struct {
75  int elements;
76  float data[MAX_ROWS];
77 } VECTOR;
78 
79 #define DOF (3)
80 
81 typedef struct {
82  int mat[DOF];
83  int range;
84 } BMAT;
85 
86 #define MROWS(m) ((m).rows)
87 #define MCOLS(m) ((m).cols)
88 #define MDATA(m,i,j) ((m).data[i][j])
89 
90 #define VELEMENTS(v) ((v).elements)
91 #define VDATA(v,i) ((v).data[i])
92 
93 #define M_SQUARE(m) ((m).rows == (m).cols)
94 #define M_COMPAT_DIM(m, n) ((m).cols == (n).rows)
95 #define M_EQUAL_DIM(m, n) (((m).rows == (n).rows) && ((m).cols == (n).cols))
96 #define V_EQUAL_DIM(v, w) (((v).elements == (w).elements))
97 #define MV_COMPAT_DIM(m, v) ((m).cols == (v).elements)
98 
99 #define FIRST(b) ((b).mat[0])
100 #define SECOND(b) ((b).mat[1])
101 #define THIRD(b) ((b).mat[2])
102 #define RANGE(b) ((b).range)
103 
104 #define SQUARE(x) ((x)*(x))
105 
106 MATRIX create_matrix (int rows, int cols);
107 void initialize_matrix (MATRIX *m, int rows, int cols);
108 void diagonal_matrix (MATRIX *m, int dim, float el1, float el2, float el3);
109 void print_matrix (char *message, MATRIX const *m);
110 VECTOR create_vector (int elements);
111 void initialize_vector (VECTOR *v, int elements);
112 void print_vector (char *message, VECTOR const *v);
113 float cross_product (MATRIX const *m, int f1, int c1, int f2, int c2);
114 int determinant (MATRIX const *m, float *result);
115 int inverse_matrix (MATRIX const *m, MATRIX *n);
116 int multiply_matrix_vector (MATRIX const *m, VECTOR const *v, VECTOR *r);
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif
123 
Definition: sp_matrix.h:81
MATRIX create_matrix(int rows, int cols)
Definition: sp_matrix.c:53
float cross_product(MATRIX const *m, int f1, int c1, int f2, int c2)
Definition: sp_matrix.c:177
void initialize_matrix(MATRIX *m, int rows, int cols)
Definition: sp_matrix.c:76
int cols
Definition: sp_matrix.h:70
#define MAX_ROWS
Definition: sp_matrix.h:65
void print_matrix(char *message, MATRIX const *m)
Definition: sp_matrix.c:97
#define MAX_COLS
Definition: sp_matrix.h:66
void print_vector(char *message, VECTOR const *v)
Definition: sp_matrix.c:157
int multiply_matrix_vector(MATRIX const *m, VECTOR const *v, VECTOR *r)
Definition: sp_matrix.c:271
int inverse_matrix(MATRIX const *m, MATRIX *n)
Definition: sp_matrix.c:214
void initialize_vector(VECTOR *v, int elements)
Definition: sp_matrix.c:140
#define DOF
Definition: sp_matrix.h:79
int elements
Definition: sp_matrix.h:75
int rows
Definition: sp_matrix.h:69
void diagonal_matrix(MATRIX *m, int dim, float el1, float el2, float el3)
int range
Definition: sp_matrix.h:83
VECTOR create_vector(int elements)
Definition: sp_matrix.c:119
int determinant(MATRIX const *m, float *result)
Definition: sp_matrix.c:186


lidar_egomotion
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:10