Matrix Library. v1.6.4
Dependents: Matrix_class Wizardsneverdie TwoTank mbed_multiplex_matrix ... more
Diff: Matrix.cpp
- Revision:
- 5:a4014ab0a8cf
- Parent:
- 4:c0c8f3edd60e
--- a/Matrix.cpp Sat Oct 22 23:19:51 2011 +0000 +++ b/Matrix.cpp Sun Oct 30 16:29:23 2011 +0000 @@ -1,10 +1,13 @@ /** - * @file Matrix.cpp + * @brief Source Code for the Matrix Class. + * @file Matrix.cpp * @author Ernesto Palacios - * @brief Source Code for the Matrix Class. * * Created on September 2011. * + * Develop Under GPL v3.0 License + * http://www.gnu.org/licenses/gpl-3.0.html + * */ #include "mbed.h" @@ -57,7 +60,7 @@ /***********************************************************************/ /// Returns true if matrix is full of zeros -bool Matrix::isZero() +bool Matrix::isZero() const { bool zero = false; for( int i = 0; i < this->_nRows; i++ ) @@ -69,7 +72,7 @@ /// Returns true if Matrix is Single Row ot Single Column. -bool Matrix::isVector() +bool Matrix::isVector() const { if( _nRows == 1 || _nCols == 1 ) return true; @@ -133,7 +136,7 @@ Matrix::AddRow( Receip, index ); //Make Room --index; - for( int i; i < Receip._nCols; i++ ) + for( int i = 0; i < Receip._nCols; i++ ) Receip._matrix[index][i] = Row._matrix[0][i]; //Copy Data. } @@ -245,7 +248,7 @@ SingleRow.Clear(); for( int j = 0; j < Mat._nCols; j++ ) - SingleRow._matrix[0][j] = Mat._matrix[row][j]; + SingleRow._matrix[0][j] = Mat._matrix[row][j]; SingleRow._pCol = SingleRow._nCols; SingleRow._pRow = 0; @@ -317,7 +320,7 @@ /// Prints out Matrix. -void Matrix::print() +void Matrix::print() const { for( int i = 0; i < _nRows; i++ ) { @@ -361,24 +364,24 @@ /// Adds all elements in matrix and returns the answer. -float Matrix::sum() +float Matrix::sum() const { - float total; + float total = 0; - for( int i = 0; i < this->_nRows; i++ ) - for( int j = 0; j < this->_nCols; j++ ) - total += this->_matrix[i][j]; + for( int i = 0; i < _nRows; i++ ) + for( int j = 0; j < _nCols; j++ ) + total += _matrix[i][j]; return total; } /// Returns the specified element. Index Starts at [1][1]. -float Matrix::getNumber( int Row, int Col ) +float Matrix::getNumber( int Row, int Col ) const { return this->_matrix[Row -1][Col - 1]; } /// Returns the number of Rows in Matrix. -int Matrix::getRows(){ return this->_nRows; } +int Matrix::getRows() const{ return this->_nRows; } /// Returns the number of Columns in Matrix. -int Matrix::getCols(){ return this->_nCols; } \ No newline at end of file +int Matrix::getCols() const{ return this->_nCols; } \ No newline at end of file