Compare commits

..

No commits in common. "e8f843a42044cc1acf6b512c3c01830240c3b2f0" and "a3db9391d3b9c4c96554bf8705b8994b1c7aa59f" have entirely different histories.

3 changed files with 9 additions and 13 deletions

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
build/* build/*
.vscode/* .vscode/*
main.cpp

View File

@ -2,12 +2,11 @@
int main() { int main() {
Matrix a(3, 3); Matrix a(3, 3);
Matrix b(3, 1); // Let's multiply by a vector
a.Print("A"); Matrix result = a * &b;
a = a.Add(0.5F); result.Print("A x B"); // Result is a 3 by 1 vector
a.Print("A + 0.5F");
return 0; return 0;
} }

View File

@ -16,7 +16,7 @@ class Matrix{
inline Matrix Swap(const Matrix*); inline Matrix Swap(const Matrix*);
inline Matrix Multiply(float); inline void Multiply(float); // TODO : Make this return a Matrix
inline Matrix Multiply(const Matrix*); inline Matrix Multiply(const Matrix*);
inline void Hadamard(const Matrix*); inline void Hadamard(const Matrix*);
@ -180,14 +180,12 @@ Matrix Matrix::Substract(float value){
} }
// Multiply every matrix case by a given factor // Multiply every matrix case by a given factor
Matrix Matrix::Multiply(float value){ void Matrix::Multiply(float value){
Matrix result = this; for(int m = 0; m < this->values.size(); m++){
for(int m = 0; m < result.values.size(); m++){ for(int n = 0; n < this->values[m].size(); n++){
for(int n = 0; n < result.values[m].size(); n++){ this->values[m][n] *= value;
result.values[m][n] *= value;
} }
} }
return result;
} }
// Set a matrix to a given value // Set a matrix to a given value