Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ISR_Mini-explorer mbed
Fork of roboticLab_withclass_3_July by
Diff: myMatrix.cpp
- Revision:
- 9:1cc27f33d3e1
- Parent:
- 8:072a76960e27
- Child:
- 10:d0109d7cbe7c
diff -r 072a76960e27 -r 1cc27f33d3e1 myMatrix.cpp --- a/myMatrix.cpp Mon Jul 10 12:49:07 2017 +0000 +++ b/myMatrix.cpp Mon Jul 10 16:23:52 2017 +0000 @@ -3,7 +3,7 @@ using namespace std; myMatrix::myMatrix(int inNbRow,int inNbColumn){ - int i,j; + int i; this->nbRow=inNbRow; this->nbColumn=inNbColumn; //initialise data @@ -14,16 +14,26 @@ this->data[i] = new float[this->nbRow]; //fill with 0 + this->fillWithZeroes(); +} - for(i = 0; i < this->nbColumn; ++i) { - for(j = 0; j < this->nbRow; ++j) { +void myMatrix::fillWithZeroes(){ + for(int i = 0; i < this->nbColumn; ++i) { + for(int j = 0; j < this->nbRow; ++j) { this->data[i][j] = 0; } } - } +void myMatrix::fillByCopy(myMatrix mat1){ + for(int i = 0; i < mat1.nbRow; ++i) { + for(int j = 0; j < mat1.nbColumn; ++j) { + this->data[i][j] = mat1.data[i][j]; + } + } +} + //assume the dimensions are correct void myMatrix::fillWithTranspose(myMatrix mat1){ for(int i = 0; i < mat1.nbRow; ++i) {