test_IPKF

Dependencies:   mbed

Committer:
LudovicoDani
Date:
Wed Apr 20 10:03:58 2016 +0000
Revision:
0:fb6e494a7656
IPKF_Test_nucleo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
LudovicoDani 0:fb6e494a7656 1 /** @brief
LudovicoDani 0:fb6e494a7656 2 * @file matrix.h
LudovicoDani 0:fb6e494a7656 3 * @author Daniele Ludovico
LudovicoDani 0:fb6e494a7656 4 * @date 20/3/2016
LudovicoDani 0:fb6e494a7656 5 * @brief File containing the function to manipulates matrices.
LudovicoDani 0:fb6e494a7656 6 *
LudovicoDani 0:fb6e494a7656 7 */
LudovicoDani 0:fb6e494a7656 8
LudovicoDani 0:fb6e494a7656 9
LudovicoDani 0:fb6e494a7656 10 #ifndef MATRIX_H_INCLUDED
LudovicoDani 0:fb6e494a7656 11 #define MATRIX_H_INCLUDED
LudovicoDani 0:fb6e494a7656 12
LudovicoDani 0:fb6e494a7656 13
LudovicoDani 0:fb6e494a7656 14 #ifdef __cplusplus
LudovicoDani 0:fb6e494a7656 15 extern "C" {
LudovicoDani 0:fb6e494a7656 16 #endif
LudovicoDani 0:fb6e494a7656 17
LudovicoDani 0:fb6e494a7656 18 #include <stdio.h>
LudovicoDani 0:fb6e494a7656 19 #include <stdlib.h>
LudovicoDani 0:fb6e494a7656 20
LudovicoDani 0:fb6e494a7656 21 /** @brief struct matrix
LudovicoDani 0:fb6e494a7656 22 * allows to execute matrix computation
LudovicoDani 0:fb6e494a7656 23 */
LudovicoDani 0:fb6e494a7656 24 typedef struct s_matrix
LudovicoDani 0:fb6e494a7656 25 {
LudovicoDani 0:fb6e494a7656 26 int row;/**< number of row of the matrix */
LudovicoDani 0:fb6e494a7656 27 int col;/**< number of column of the matrix */
LudovicoDani 0:fb6e494a7656 28 float** element; /**< this field allows to read and write the elements of the matrix */
LudovicoDani 0:fb6e494a7656 29 }matrix;
LudovicoDani 0:fb6e494a7656 30
LudovicoDani 0:fb6e494a7656 31 /********************************************//**
LudovicoDani 0:fb6e494a7656 32 * \brief this function allows to allocate a
LudovicoDani 0:fb6e494a7656 33 * matrix in memory
LudovicoDani 0:fb6e494a7656 34 *
LudovicoDani 0:fb6e494a7656 35 * \param matrix pointer to the object to
LudovicoDani 0:fb6e494a7656 36 * allocate
LudovicoDani 0:fb6e494a7656 37 *
LudovicoDani 0:fb6e494a7656 38 * \return 0 if the allocation is done
LudovicoDani 0:fb6e494a7656 39 * correctly
LudovicoDani 0:fb6e494a7656 40 * \return 1 if there is not enough space in
LudovicoDani 0:fb6e494a7656 41 * memory to create a new matrix
LudovicoDani 0:fb6e494a7656 42 *
LudovicoDani 0:fb6e494a7656 43 ***********************************************/
LudovicoDani 0:fb6e494a7656 44
LudovicoDani 0:fb6e494a7656 45 int CreateMatrix(matrix* m);
LudovicoDani 0:fb6e494a7656 46
LudovicoDani 0:fb6e494a7656 47 /********************************************//**
LudovicoDani 0:fb6e494a7656 48 * \brief this function allows to delete from
LudovicoDani 0:fb6e494a7656 49 * memory a matrix struct
LudovicoDani 0:fb6e494a7656 50 *
LudovicoDani 0:fb6e494a7656 51 * \param matrix pointer to the object to
LudovicoDani 0:fb6e494a7656 52 * delete
LudovicoDani 0:fb6e494a7656 53 * \return void
LudovicoDani 0:fb6e494a7656 54 *
LudovicoDani 0:fb6e494a7656 55 ***********************************************/
LudovicoDani 0:fb6e494a7656 56
LudovicoDani 0:fb6e494a7656 57 void DeleteMatrix(matrix* m);
LudovicoDani 0:fb6e494a7656 58
LudovicoDani 0:fb6e494a7656 59 /********************************************//**
LudovicoDani 0:fb6e494a7656 60 * \brief this function initialize a matrix
LudovicoDani 0:fb6e494a7656 61 *
LudovicoDani 0:fb6e494a7656 62 * \param m is the pointer to the matrix to
LudovicoDani 0:fb6e494a7656 63 * initialize
LudovicoDani 0:fb6e494a7656 64 * \param row is the number of row of the matrix
LudovicoDani 0:fb6e494a7656 65 * \param col is the number of column of the matrix
LudovicoDani 0:fb6e494a7656 66 *
LudovicoDani 0:fb6e494a7656 67 * \return 0 if the allocation is done
LudovicoDani 0:fb6e494a7656 68 * correctly
LudovicoDani 0:fb6e494a7656 69 * \return 1 if there is not enough space in
LudovicoDani 0:fb6e494a7656 70 * memory to create a new matrix
LudovicoDani 0:fb6e494a7656 71 *
LudovicoDani 0:fb6e494a7656 72 ***********************************************/
LudovicoDani 0:fb6e494a7656 73
LudovicoDani 0:fb6e494a7656 74 int InitMatrix(matrix* m, int row, int col);
LudovicoDani 0:fb6e494a7656 75
LudovicoDani 0:fb6e494a7656 76 /********************************************//**
LudovicoDani 0:fb6e494a7656 77 * \brief this function allows to compute
LudovicoDani 0:fb6e494a7656 78 * the product between 2 matrices
LudovicoDani 0:fb6e494a7656 79 *
LudovicoDani 0:fb6e494a7656 80 * \param a is the first element of the product
LudovicoDani 0:fb6e494a7656 81 * \param b is the second element of the product
LudovicoDani 0:fb6e494a7656 82 * \param r is the matrix which will contain
LudovicoDani 0:fb6e494a7656 83 * the result
LudovicoDani 0:fb6e494a7656 84 *
LudovicoDani 0:fb6e494a7656 85 * \return 0 if the product is computed correctly
LudovicoDani 0:fb6e494a7656 86 * \return 1 if the number of column of a is different
LudovicoDani 0:fb6e494a7656 87 * from the row of b
LudovicoDani 0:fb6e494a7656 88 * \return 2 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 89 * from number of row of r
LudovicoDani 0:fb6e494a7656 90 * \return 3 if the number of column of b is different
LudovicoDani 0:fb6e494a7656 91 * from number of column of r
LudovicoDani 0:fb6e494a7656 92 *
LudovicoDani 0:fb6e494a7656 93 ***********************************************/
LudovicoDani 0:fb6e494a7656 94
LudovicoDani 0:fb6e494a7656 95 int MxM (matrix* a, matrix* b, matrix* r);
LudovicoDani 0:fb6e494a7656 96
LudovicoDani 0:fb6e494a7656 97 /********************************************//**
LudovicoDani 0:fb6e494a7656 98 * \brief this function allows to compute the
LudovicoDani 0:fb6e494a7656 99 * product between a scalar and a matrix
LudovicoDani 0:fb6e494a7656 100 *
LudovicoDani 0:fb6e494a7656 101 * \param m is the pointer to the matrix
LudovicoDani 0:fb6e494a7656 102 * \param a is the scalar number
LudovicoDani 0:fb6e494a7656 103 * \param r is the pointer to the result
LudovicoDani 0:fb6e494a7656 104 *
LudovicoDani 0:fb6e494a7656 105 * \return 0 if the the product is computed
LudovicoDani 0:fb6e494a7656 106 * correctly
LudovicoDani 0:fb6e494a7656 107 * \return 1 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 108 * from number of row of r
LudovicoDani 0:fb6e494a7656 109 * \return 2 if the number of col of a is different
LudovicoDani 0:fb6e494a7656 110 * from number of col of r
LudovicoDani 0:fb6e494a7656 111 *
LudovicoDani 0:fb6e494a7656 112 ***********************************************/
LudovicoDani 0:fb6e494a7656 113
LudovicoDani 0:fb6e494a7656 114 int axM (matrix* m, float a, matrix* r);
LudovicoDani 0:fb6e494a7656 115
LudovicoDani 0:fb6e494a7656 116 /********************************************//**
LudovicoDani 0:fb6e494a7656 117 * \brief this function allows to compute the
LudovicoDani 0:fb6e494a7656 118 * sum between two matrices
LudovicoDani 0:fb6e494a7656 119 *
LudovicoDani 0:fb6e494a7656 120 * \param a is the pointer to the first matrix
LudovicoDani 0:fb6e494a7656 121 * \param b is the pointer to the second matrix
LudovicoDani 0:fb6e494a7656 122 * \param c is the pointer to the result
LudovicoDani 0:fb6e494a7656 123 *
LudovicoDani 0:fb6e494a7656 124 * \return 0 if the sum is computed correctly
LudovicoDani 0:fb6e494a7656 125 * \return 1 if the number of column of a is different
LudovicoDani 0:fb6e494a7656 126 * from the column of b
LudovicoDani 0:fb6e494a7656 127 * \return 2 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 128 * from number of row of b
LudovicoDani 0:fb6e494a7656 129 * \return 3 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 130 * from number of row of r
LudovicoDani 0:fb6e494a7656 131 * \return 4 if the number of column of a is different
LudovicoDani 0:fb6e494a7656 132 * from number of column of r
LudovicoDani 0:fb6e494a7656 133 *
LudovicoDani 0:fb6e494a7656 134 ***********************************************/
LudovicoDani 0:fb6e494a7656 135
LudovicoDani 0:fb6e494a7656 136 int Sum (matrix* a, matrix* b, matrix* r);
LudovicoDani 0:fb6e494a7656 137
LudovicoDani 0:fb6e494a7656 138 /********************************************//**
LudovicoDani 0:fb6e494a7656 139 * \brief this function allows to compute the
LudovicoDani 0:fb6e494a7656 140 * subtraction between two matrices
LudovicoDani 0:fb6e494a7656 141 *
LudovicoDani 0:fb6e494a7656 142 * \param a is the pointer to the first matrix
LudovicoDani 0:fb6e494a7656 143 * \param b is the pointer to the second matrix
LudovicoDani 0:fb6e494a7656 144 * \param c is the pointer to the result
LudovicoDani 0:fb6e494a7656 145 *
LudovicoDani 0:fb6e494a7656 146 * \return 0 if the subtraction is computed correctly
LudovicoDani 0:fb6e494a7656 147 * \return 1 if the number of column of a is different
LudovicoDani 0:fb6e494a7656 148 * from the column of b
LudovicoDani 0:fb6e494a7656 149 * \return 2 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 150 * from number of row of b
LudovicoDani 0:fb6e494a7656 151 * \return 3 if the number of row of a is different
LudovicoDani 0:fb6e494a7656 152 * from number of row of r
LudovicoDani 0:fb6e494a7656 153 * \return 4 if the number of column of a is different
LudovicoDani 0:fb6e494a7656 154 * from number of column of r
LudovicoDani 0:fb6e494a7656 155 *
LudovicoDani 0:fb6e494a7656 156 ***********************************************/
LudovicoDani 0:fb6e494a7656 157
LudovicoDani 0:fb6e494a7656 158 int Sub (matrix* a, matrix* b, matrix* r);
LudovicoDani 0:fb6e494a7656 159
LudovicoDani 0:fb6e494a7656 160 /********************************************//**
LudovicoDani 0:fb6e494a7656 161 * \brief this function allows to compute the
LudovicoDani 0:fb6e494a7656 162 * traspost of a matrix
LudovicoDani 0:fb6e494a7656 163 *
LudovicoDani 0:fb6e494a7656 164 * \param m is the pointer to the matrix to
LudovicoDani 0:fb6e494a7656 165 * be trasposed
LudovicoDani 0:fb6e494a7656 166 * \param r is the pointer to the result
LudovicoDani 0:fb6e494a7656 167 *
LudovicoDani 0:fb6e494a7656 168 * \return 0 if the operation is done correctly
LudovicoDani 0:fb6e494a7656 169 * \return 1 if the number of row of m is different
LudovicoDani 0:fb6e494a7656 170 * from the column of r
LudovicoDani 0:fb6e494a7656 171 * \return 2 if the number of column of m is different
LudovicoDani 0:fb6e494a7656 172 * from the row of r
LudovicoDani 0:fb6e494a7656 173 *
LudovicoDani 0:fb6e494a7656 174 ***********************************************/
LudovicoDani 0:fb6e494a7656 175
LudovicoDani 0:fb6e494a7656 176 int Traspost(matrix* m, matrix* r);
LudovicoDani 0:fb6e494a7656 177
LudovicoDani 0:fb6e494a7656 178 /********************************************//**
LudovicoDani 0:fb6e494a7656 179 * \brief this function allows to compute the
LudovicoDani 0:fb6e494a7656 180 * inverse of a matrix using the Gauss algorithm
LudovicoDani 0:fb6e494a7656 181 *
LudovicoDani 0:fb6e494a7656 182 * \param m is the pointer to the original matrix
LudovicoDani 0:fb6e494a7656 183 * \param inv_m is the pointer to the result
LudovicoDani 0:fb6e494a7656 184 *
LudovicoDani 0:fb6e494a7656 185 * \return 0 if the inversion is done correctly
LudovicoDani 0:fb6e494a7656 186 * \return 1 if m is not a square matrix
LudovicoDani 0:fb6e494a7656 187 * \return 2 if the number of row of m is different
LudovicoDani 0:fb6e494a7656 188 * from the row of inv_m
LudovicoDani 0:fb6e494a7656 189 * \return 3 if the number of column of m is different
LudovicoDani 0:fb6e494a7656 190 * from the column of inv_m
LudovicoDani 0:fb6e494a7656 191 * \return 4 if m is not invertible
LudovicoDani 0:fb6e494a7656 192 *
LudovicoDani 0:fb6e494a7656 193 ***********************************************/
LudovicoDani 0:fb6e494a7656 194
LudovicoDani 0:fb6e494a7656 195 int Inv (matrix* m, matrix* inv_m);
LudovicoDani 0:fb6e494a7656 196
LudovicoDani 0:fb6e494a7656 197 /********************************************//**
LudovicoDani 0:fb6e494a7656 198 * \brief Computes the cross product between two vectors
LudovicoDani 0:fb6e494a7656 199 *
LudovicoDani 0:fb6e494a7656 200 * \param v is the first vector
LudovicoDani 0:fb6e494a7656 201 * \param w is the second vector
LudovicoDani 0:fb6e494a7656 202 * \param r is address to the resulting matrix
LudovicoDani 0:fb6e494a7656 203 * \return void
LudovicoDani 0:fb6e494a7656 204 *
LudovicoDani 0:fb6e494a7656 205 ***********************************************/
LudovicoDani 0:fb6e494a7656 206
LudovicoDani 0:fb6e494a7656 207 void CrossProd(matrix* v, matrix* w, matrix* r);
LudovicoDani 0:fb6e494a7656 208
LudovicoDani 0:fb6e494a7656 209 /********************************************//**
LudovicoDani 0:fb6e494a7656 210 * \brief print the matrix in the prompt
LudovicoDani 0:fb6e494a7656 211 *
LudovicoDani 0:fb6e494a7656 212 * \param m is the pointer to the matrix to print
LudovicoDani 0:fb6e494a7656 213 *
LudovicoDani 0:fb6e494a7656 214 * \return void
LudovicoDani 0:fb6e494a7656 215 *
LudovicoDani 0:fb6e494a7656 216 ***********************************************/
LudovicoDani 0:fb6e494a7656 217
LudovicoDani 0:fb6e494a7656 218 void Print_Matrix(matrix* m);
LudovicoDani 0:fb6e494a7656 219
LudovicoDani 0:fb6e494a7656 220 #ifdef __cplusplus
LudovicoDani 0:fb6e494a7656 221 }
LudovicoDani 0:fb6e494a7656 222 #endif
LudovicoDani 0:fb6e494a7656 223
LudovicoDani 0:fb6e494a7656 224 #endif // MATRIX_H_INCLUDED
LudovicoDani 0:fb6e494a7656 225
LudovicoDani 0:fb6e494a7656 226
LudovicoDani 0:fb6e494a7656 227