use from Ernesto Palacios
Dependents: RoboticArm DXL_SDK_Porting_Test
Fork of Matrix by
Matrix.h@0:3abd8c2d7c34, 2011-09-23 (annotated)
- Committer:
- Yo_Robot
- Date:
- Fri Sep 23 21:12:17 2011 +0000
- Revision:
- 0:3abd8c2d7c34
- Child:
- 1:48f417da268e
Matrix_v1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yo_Robot | 0:3abd8c2d7c34 | 1 | |
Yo_Robot | 0:3abd8c2d7c34 | 2 | /** |
Yo_Robot | 0:3abd8c2d7c34 | 3 | * @file: Matrix.h |
Yo_Robot | 0:3abd8c2d7c34 | 4 | * @author: Ernesto Palacios |
Yo_Robot | 0:3abd8c2d7c34 | 5 | * Created on 13 de septiembre de 2011, 03:49 PM |
Yo_Robot | 0:3abd8c2d7c34 | 6 | * |
Yo_Robot | 0:3abd8c2d7c34 | 7 | * Develop Under GPL v3.0 License |
Yo_Robot | 0:3abd8c2d7c34 | 8 | * http://www.gnu.org/licenses/gpl-3.0.html |
Yo_Robot | 0:3abd8c2d7c34 | 9 | * |
Yo_Robot | 0:3abd8c2d7c34 | 10 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 11 | |
Yo_Robot | 0:3abd8c2d7c34 | 12 | #include <vector> |
Yo_Robot | 0:3abd8c2d7c34 | 13 | |
Yo_Robot | 0:3abd8c2d7c34 | 14 | #ifndef MATRIX_H |
Yo_Robot | 0:3abd8c2d7c34 | 15 | #define MATRIX_H |
Yo_Robot | 0:3abd8c2d7c34 | 16 | |
Yo_Robot | 0:3abd8c2d7c34 | 17 | /** |
Yo_Robot | 0:3abd8c2d7c34 | 18 | * @brief This class is intended to provide basic functionality to a Matrix like vector |
Yo_Robot | 0:3abd8c2d7c34 | 19 | * it's meant for float elements. |
Yo_Robot | 0:3abd8c2d7c34 | 20 | * |
Yo_Robot | 0:3abd8c2d7c34 | 21 | * IMPORTAT: Asignment "=" operator is overloaded so that it resizes the 'lefthand' Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 22 | * to acomodate the Matrix it's been passed. |
Yo_Robot | 0:3abd8c2d7c34 | 23 | * |
Yo_Robot | 0:3abd8c2d7c34 | 24 | * An example of how it works: |
Yo_Robot | 0:3abd8c2d7c34 | 25 | * @code |
Yo_Robot | 0:3abd8c2d7c34 | 26 | * Matrix myMatrix( 3, 4 ); //Declare a 3 Rows by 4 Columns Matrix. |
Yo_Robot | 0:3abd8c2d7c34 | 27 | * |
Yo_Robot | 0:3abd8c2d7c34 | 28 | * myMatrix.Fill(); // Fill the matrix using printf() and scanf(). |
Yo_Robot | 0:3abd8c2d7c34 | 29 | * myMatrix.print(); // Prints the value of the Matrix. printf() |
Yo_Robot | 0:3abd8c2d7c34 | 30 | * |
Yo_Robot | 0:3abd8c2d7c34 | 31 | * Matrix::DeleteCol( myMatrix, 2 ); //Deletes Second Column. (startin' with 1 not 0) |
Yo_Robot | 0:3abd8c2d7c34 | 32 | * myMatrix.print(); // Re-prints Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 33 | * |
Yo_Robot | 0:3abd8c2d7c34 | 34 | * Matrix anotherMatrix (3); // Squared 3x3 Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 35 | * anotherMatrix = myMatrix; // Re-Sizes 'anotherMatrix' to fit myMatrix |
Yo_Robot | 0:3abd8c2d7c34 | 36 | * anotherMatrix += myMatrix; // Adds one-by-one elements and saves to anotherMatrix |
Yo_Robot | 0:3abd8c2d7c34 | 37 | * anotherMatrix.print(); |
Yo_Robot | 0:3abd8c2d7c34 | 38 | * @endcode |
Yo_Robot | 0:3abd8c2d7c34 | 39 | * |
Yo_Robot | 0:3abd8c2d7c34 | 40 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 41 | class Matrix{ |
Yo_Robot | 0:3abd8c2d7c34 | 42 | public: |
Yo_Robot | 0:3abd8c2d7c34 | 43 | |
Yo_Robot | 0:3abd8c2d7c34 | 44 | /// Creates a nex Matrix of Size [ Row x Cols ] |
Yo_Robot | 0:3abd8c2d7c34 | 45 | Matrix( int Rows, int Cols ); |
Yo_Robot | 0:3abd8c2d7c34 | 46 | |
Yo_Robot | 0:3abd8c2d7c34 | 47 | /// Creats a Square Matrix o Size [ Roxs x Rows ] |
Yo_Robot | 0:3abd8c2d7c34 | 48 | Matrix( int Rows ); |
Yo_Robot | 0:3abd8c2d7c34 | 49 | |
Yo_Robot | 0:3abd8c2d7c34 | 50 | |
Yo_Robot | 0:3abd8c2d7c34 | 51 | /// Creates a new Matrix identical in size to an input Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 52 | Matrix( const Matrix &base ); |
Yo_Robot | 0:3abd8c2d7c34 | 53 | |
Yo_Robot | 0:3abd8c2d7c34 | 54 | |
Yo_Robot | 0:3abd8c2d7c34 | 55 | /// Reserves Memory for a New Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 56 | Matrix(); |
Yo_Robot | 0:3abd8c2d7c34 | 57 | |
Yo_Robot | 0:3abd8c2d7c34 | 58 | |
Yo_Robot | 0:3abd8c2d7c34 | 59 | |
Yo_Robot | 0:3abd8c2d7c34 | 60 | /** @brief Description: |
Yo_Robot | 0:3abd8c2d7c34 | 61 | * This is the '=' Overloaded operator. It RESIZES assigned the matrix. |
Yo_Robot | 0:3abd8c2d7c34 | 62 | * Overwrites all data. To be used Carefully! |
Yo_Robot | 0:3abd8c2d7c34 | 63 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 64 | Matrix& operator = ( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 65 | |
Yo_Robot | 0:3abd8c2d7c34 | 66 | |
Yo_Robot | 0:3abd8c2d7c34 | 67 | /**@brief Description: |
Yo_Robot | 0:3abd8c2d7c34 | 68 | * Overload opeartor for the compare Matrices |
Yo_Robot | 0:3abd8c2d7c34 | 69 | * |
Yo_Robot | 0:3abd8c2d7c34 | 70 | * @param rightM |
Yo_Robot | 0:3abd8c2d7c34 | 71 | * @return Boolean 'false' if different. |
Yo_Robot | 0:3abd8c2d7c34 | 72 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 73 | bool operator == ( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 74 | |
Yo_Robot | 0:3abd8c2d7c34 | 75 | |
Yo_Robot | 0:3abd8c2d7c34 | 76 | |
Yo_Robot | 0:3abd8c2d7c34 | 77 | /**@brief Description: |
Yo_Robot | 0:3abd8c2d7c34 | 78 | * Overload opeartor for the compare Matrices |
Yo_Robot | 0:3abd8c2d7c34 | 79 | * |
Yo_Robot | 0:3abd8c2d7c34 | 80 | * @param rightM |
Yo_Robot | 0:3abd8c2d7c34 | 81 | * @return Boolean 'true' if different |
Yo_Robot | 0:3abd8c2d7c34 | 82 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 83 | bool operator != ( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 84 | |
Yo_Robot | 0:3abd8c2d7c34 | 85 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 86 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 87 | * Overload Copmpound assignment. |
Yo_Robot | 0:3abd8c2d7c34 | 88 | * @param rightM |
Yo_Robot | 0:3abd8c2d7c34 | 89 | * @return A new Matrix to be assigned to itself. |
Yo_Robot | 0:3abd8c2d7c34 | 90 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 91 | Matrix& operator += ( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 92 | |
Yo_Robot | 0:3abd8c2d7c34 | 93 | |
Yo_Robot | 0:3abd8c2d7c34 | 94 | |
Yo_Robot | 0:3abd8c2d7c34 | 95 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 96 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 97 | * Overload Compund decrease. |
Yo_Robot | 0:3abd8c2d7c34 | 98 | * @param rightM Right hand matrix |
Yo_Robot | 0:3abd8c2d7c34 | 99 | * @return A new Matrix to be assigned to itself |
Yo_Robot | 0:3abd8c2d7c34 | 100 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 101 | Matrix& operator -= ( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 102 | |
Yo_Robot | 0:3abd8c2d7c34 | 103 | |
Yo_Robot | 0:3abd8c2d7c34 | 104 | |
Yo_Robot | 0:3abd8c2d7c34 | 105 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 106 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 107 | * Overloads the Plus, returns a new object. |
Yo_Robot | 0:3abd8c2d7c34 | 108 | * @param rightM right side Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 109 | * @return Retuns an instance of the answer. |
Yo_Robot | 0:3abd8c2d7c34 | 110 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 111 | const Matrix operator +( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 112 | |
Yo_Robot | 0:3abd8c2d7c34 | 113 | |
Yo_Robot | 0:3abd8c2d7c34 | 114 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 115 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 116 | * Overloads the Minus, returns a new object |
Yo_Robot | 0:3abd8c2d7c34 | 117 | * @param rightM |
Yo_Robot | 0:3abd8c2d7c34 | 118 | * @return Returns an instance of the asnwer |
Yo_Robot | 0:3abd8c2d7c34 | 119 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 120 | const Matrix operator -( const Matrix &rightM ); |
Yo_Robot | 0:3abd8c2d7c34 | 121 | |
Yo_Robot | 0:3abd8c2d7c34 | 122 | |
Yo_Robot | 0:3abd8c2d7c34 | 123 | |
Yo_Robot | 0:3abd8c2d7c34 | 124 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 125 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 126 | * This method extracts a Row from a Matrix. |
Yo_Robot | 0:3abd8c2d7c34 | 127 | * If Row is out of the parameters, it returns |
Yo_Robot | 0:3abd8c2d7c34 | 128 | * an empty Row and prints a warning |
Yo_Robot | 0:3abd8c2d7c34 | 129 | * @param Matrix: Matrix to extract from |
Yo_Robot | 0:3abd8c2d7c34 | 130 | * @param Row: row number of the matrix |
Yo_Robot | 0:3abd8c2d7c34 | 131 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 132 | Matrix GetRow(Matrix mat, int Row); |
Yo_Robot | 0:3abd8c2d7c34 | 133 | |
Yo_Robot | 0:3abd8c2d7c34 | 134 | |
Yo_Robot | 0:3abd8c2d7c34 | 135 | |
Yo_Robot | 0:3abd8c2d7c34 | 136 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 137 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 138 | * This method extracts a Column from a Matrix. |
Yo_Robot | 0:3abd8c2d7c34 | 139 | * If Row is out of the parameters, it returns |
Yo_Robot | 0:3abd8c2d7c34 | 140 | * an empty Column and prints a warning |
Yo_Robot | 0:3abd8c2d7c34 | 141 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 142 | Matrix GetCol(Matrix mat, int Col); |
Yo_Robot | 0:3abd8c2d7c34 | 143 | |
Yo_Robot | 0:3abd8c2d7c34 | 144 | |
Yo_Robot | 0:3abd8c2d7c34 | 145 | |
Yo_Robot | 0:3abd8c2d7c34 | 146 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 147 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 148 | * Shatters the matrix into a single Row Vector. |
Yo_Robot | 0:3abd8c2d7c34 | 149 | * Important: Returns NEW matrix, does no modify existing one. |
Yo_Robot | 0:3abd8c2d7c34 | 150 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 151 | Matrix ToPackedVector(); |
Yo_Robot | 0:3abd8c2d7c34 | 152 | |
Yo_Robot | 0:3abd8c2d7c34 | 153 | |
Yo_Robot | 0:3abd8c2d7c34 | 154 | |
Yo_Robot | 0:3abd8c2d7c34 | 155 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 156 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 157 | * Returns TRUE if the matrix is zero, FALSE otherwhise |
Yo_Robot | 0:3abd8c2d7c34 | 158 | * @param mat: Matrix to be tested |
Yo_Robot | 0:3abd8c2d7c34 | 159 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 160 | bool isZero(); |
Yo_Robot | 0:3abd8c2d7c34 | 161 | |
Yo_Robot | 0:3abd8c2d7c34 | 162 | |
Yo_Robot | 0:3abd8c2d7c34 | 163 | |
Yo_Robot | 0:3abd8c2d7c34 | 164 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 165 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 166 | * Determines weather a Matrix is a Single Column or Row. |
Yo_Robot | 0:3abd8c2d7c34 | 167 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 168 | bool isVector(); |
Yo_Robot | 0:3abd8c2d7c34 | 169 | |
Yo_Robot | 0:3abd8c2d7c34 | 170 | |
Yo_Robot | 0:3abd8c2d7c34 | 171 | |
Yo_Robot | 0:3abd8c2d7c34 | 172 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 173 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 174 | * Determines if two matrices are equal. |
Yo_Robot | 0:3abd8c2d7c34 | 175 | * @param mat1: First Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 176 | * @param mat2: Sencond Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 177 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 178 | static const bool Equals( Matrix mat1, Matrix mat2 ); |
Yo_Robot | 0:3abd8c2d7c34 | 179 | |
Yo_Robot | 0:3abd8c2d7c34 | 180 | |
Yo_Robot | 0:3abd8c2d7c34 | 181 | |
Yo_Robot | 0:3abd8c2d7c34 | 182 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 183 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 184 | * This Funcrions instanciates a new Row Matrix. Since this is a |
Yo_Robot | 0:3abd8c2d7c34 | 185 | * static function it needs to be assigned to an Empy Matrix Object |
Yo_Robot | 0:3abd8c2d7c34 | 186 | * @param Rows: Number of Rows |
Yo_Robot | 0:3abd8c2d7c34 | 187 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 188 | static Matrix CreateRowMatrix(int Rows); |
Yo_Robot | 0:3abd8c2d7c34 | 189 | |
Yo_Robot | 0:3abd8c2d7c34 | 190 | |
Yo_Robot | 0:3abd8c2d7c34 | 191 | |
Yo_Robot | 0:3abd8c2d7c34 | 192 | |
Yo_Robot | 0:3abd8c2d7c34 | 193 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 194 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 195 | * This function instanciates a new Column Matrix. Since this is a |
Yo_Robot | 0:3abd8c2d7c34 | 196 | * static function it needs to be assigned to an Empty Matrix object |
Yo_Robot | 0:3abd8c2d7c34 | 197 | * @param Cols: Number of Columns in Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 198 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 199 | static Matrix CreateColumnMatrix(int Cols); |
Yo_Robot | 0:3abd8c2d7c34 | 200 | |
Yo_Robot | 0:3abd8c2d7c34 | 201 | |
Yo_Robot | 0:3abd8c2d7c34 | 202 | |
Yo_Robot | 0:3abd8c2d7c34 | 203 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 204 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 205 | * This STATIC function Clones two Matrices. |
Yo_Robot | 0:3abd8c2d7c34 | 206 | * The Source Matrix can be any Size. |
Yo_Robot | 0:3abd8c2d7c34 | 207 | * The Receip Matrix MUST be just initialized |
Yo_Robot | 0:3abd8c2d7c34 | 208 | * as in: Matrix NewMatrix(); |
Yo_Robot | 0:3abd8c2d7c34 | 209 | * @param Source: Base Matrix to Clone. |
Yo_Robot | 0:3abd8c2d7c34 | 210 | * @param Receip: Destination shell matrix |
Yo_Robot | 0:3abd8c2d7c34 | 211 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 212 | static void Clone( const Matrix &Source, Matrix Receip ); |
Yo_Robot | 0:3abd8c2d7c34 | 213 | |
Yo_Robot | 0:3abd8c2d7c34 | 214 | |
Yo_Robot | 0:3abd8c2d7c34 | 215 | |
Yo_Robot | 0:3abd8c2d7c34 | 216 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 217 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 218 | * Static Function Deletes Row from Matrix, Static to prevent missuse |
Yo_Robot | 0:3abd8c2d7c34 | 219 | * @param Mat: Matrix to delete Row from |
Yo_Robot | 0:3abd8c2d7c34 | 220 | * @param Row: Number of Row (first Row = 1) |
Yo_Robot | 0:3abd8c2d7c34 | 221 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 222 | static void DeleteRow( Matrix &Mat, int Row ); |
Yo_Robot | 0:3abd8c2d7c34 | 223 | |
Yo_Robot | 0:3abd8c2d7c34 | 224 | |
Yo_Robot | 0:3abd8c2d7c34 | 225 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 226 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 227 | * Static Function Deletes Column from Matrix, it's Static to prevent |
Yo_Robot | 0:3abd8c2d7c34 | 228 | * missuse. |
Yo_Robot | 0:3abd8c2d7c34 | 229 | * Print error and does nothing if out of limits. |
Yo_Robot | 0:3abd8c2d7c34 | 230 | * @Mat: Matrix to delete column from |
Yo_Robot | 0:3abd8c2d7c34 | 231 | * @param Col: Number of Col to delete (first Col = 1) |
Yo_Robot | 0:3abd8c2d7c34 | 232 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 233 | static void DeleteCol( Matrix &Mat, int Col ); |
Yo_Robot | 0:3abd8c2d7c34 | 234 | |
Yo_Robot | 0:3abd8c2d7c34 | 235 | |
Yo_Robot | 0:3abd8c2d7c34 | 236 | |
Yo_Robot | 0:3abd8c2d7c34 | 237 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 238 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 239 | * Assigns a float number to the matrix in position |
Yo_Robot | 0:3abd8c2d7c34 | 240 | * |
Yo_Robot | 0:3abd8c2d7c34 | 241 | * @param number: Number to be set |
Yo_Robot | 0:3abd8c2d7c34 | 242 | * @param Row: Row of Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 243 | * @param Col: Column of Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 244 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 245 | void Add( int Row, int Col, float number ); |
Yo_Robot | 0:3abd8c2d7c34 | 246 | |
Yo_Robot | 0:3abd8c2d7c34 | 247 | |
Yo_Robot | 0:3abd8c2d7c34 | 248 | |
Yo_Robot | 0:3abd8c2d7c34 | 249 | /**@brief |
Yo_Robot | 0:3abd8c2d7c34 | 250 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 251 | * This function resizes the Matrix to fit new data. |
Yo_Robot | 0:3abd8c2d7c34 | 252 | * @param Rows: New Number of Rows |
Yo_Robot | 0:3abd8c2d7c34 | 253 | * @param Cols: New numbler of columns |
Yo_Robot | 0:3abd8c2d7c34 | 254 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 255 | void Resize( int Rows, int Cols ); |
Yo_Robot | 0:3abd8c2d7c34 | 256 | |
Yo_Robot | 0:3abd8c2d7c34 | 257 | |
Yo_Robot | 0:3abd8c2d7c34 | 258 | |
Yo_Robot | 0:3abd8c2d7c34 | 259 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 260 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 261 | * Asks user for numbers to fill the Matrix elements. One by one |
Yo_Robot | 0:3abd8c2d7c34 | 262 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 263 | void FillMatrix(); |
Yo_Robot | 0:3abd8c2d7c34 | 264 | |
Yo_Robot | 0:3abd8c2d7c34 | 265 | |
Yo_Robot | 0:3abd8c2d7c34 | 266 | |
Yo_Robot | 0:3abd8c2d7c34 | 267 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 268 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 269 | * Makes all values on Matrix object zero. |
Yo_Robot | 0:3abd8c2d7c34 | 270 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 271 | void Clear(); |
Yo_Robot | 0:3abd8c2d7c34 | 272 | |
Yo_Robot | 0:3abd8c2d7c34 | 273 | |
Yo_Robot | 0:3abd8c2d7c34 | 274 | |
Yo_Robot | 0:3abd8c2d7c34 | 275 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 276 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 277 | * Prints the entire Matrix |
Yo_Robot | 0:3abd8c2d7c34 | 278 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 279 | void print(); |
Yo_Robot | 0:3abd8c2d7c34 | 280 | |
Yo_Robot | 0:3abd8c2d7c34 | 281 | |
Yo_Robot | 0:3abd8c2d7c34 | 282 | |
Yo_Robot | 0:3abd8c2d7c34 | 283 | /** \brief |
Yo_Robot | 0:3abd8c2d7c34 | 284 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 285 | * Returns the sum of every cell in the Matrix. |
Yo_Robot | 0:3abd8c2d7c34 | 286 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 287 | float Sum(); |
Yo_Robot | 0:3abd8c2d7c34 | 288 | |
Yo_Robot | 0:3abd8c2d7c34 | 289 | |
Yo_Robot | 0:3abd8c2d7c34 | 290 | /** @brief |
Yo_Robot | 0:3abd8c2d7c34 | 291 | * Description: |
Yo_Robot | 0:3abd8c2d7c34 | 292 | * Return the number in position [Row],[Col] |
Yo_Robot | 0:3abd8c2d7c34 | 293 | * @param Row = number of row in matrix |
Yo_Robot | 0:3abd8c2d7c34 | 294 | * @param Col = number of Col in matrix |
Yo_Robot | 0:3abd8c2d7c34 | 295 | * @return Num = float number in matrix |
Yo_Robot | 0:3abd8c2d7c34 | 296 | */ |
Yo_Robot | 0:3abd8c2d7c34 | 297 | float GetNumber( int Row, int Col ); |
Yo_Robot | 0:3abd8c2d7c34 | 298 | |
Yo_Robot | 0:3abd8c2d7c34 | 299 | |
Yo_Robot | 0:3abd8c2d7c34 | 300 | |
Yo_Robot | 0:3abd8c2d7c34 | 301 | /**Retuns the number of Columns in Matrix*/ |
Yo_Robot | 0:3abd8c2d7c34 | 302 | int getCols(); |
Yo_Robot | 0:3abd8c2d7c34 | 303 | |
Yo_Robot | 0:3abd8c2d7c34 | 304 | |
Yo_Robot | 0:3abd8c2d7c34 | 305 | |
Yo_Robot | 0:3abd8c2d7c34 | 306 | /**Retruns the number of Rows in Matrix */ |
Yo_Robot | 0:3abd8c2d7c34 | 307 | int getRows(); |
Yo_Robot | 0:3abd8c2d7c34 | 308 | |
Yo_Robot | 0:3abd8c2d7c34 | 309 | |
Yo_Robot | 0:3abd8c2d7c34 | 310 | private: |
Yo_Robot | 0:3abd8c2d7c34 | 311 | |
Yo_Robot | 0:3abd8c2d7c34 | 312 | /** 2-D Vector Array*/ |
Yo_Robot | 0:3abd8c2d7c34 | 313 | vector < vector<float> > _matrix; |
Yo_Robot | 0:3abd8c2d7c34 | 314 | |
Yo_Robot | 0:3abd8c2d7c34 | 315 | /** Number of Rows in Matrix*/ |
Yo_Robot | 0:3abd8c2d7c34 | 316 | int _Rows; |
Yo_Robot | 0:3abd8c2d7c34 | 317 | |
Yo_Robot | 0:3abd8c2d7c34 | 318 | /**Number of Columns in Matrix*/ |
Yo_Robot | 0:3abd8c2d7c34 | 319 | int _Cols; |
Yo_Robot | 0:3abd8c2d7c34 | 320 | |
Yo_Robot | 0:3abd8c2d7c34 | 321 | }; |
Yo_Robot | 0:3abd8c2d7c34 | 322 | |
Yo_Robot | 0:3abd8c2d7c34 | 323 | #endif /* MATRIX_H */ |