Compare commits

...

2 Commits

Author SHA1 Message Date
e8f843a420 Now ignoring main.cpp to keep it clean 2024-12-27 23:34:48 +01:00
a4dabb247d Adding a float now returns a Matrix 2024-12-27 23:34:27 +01:00
3 changed files with 13 additions and 9 deletions

3
.gitignore vendored
View File

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

View File

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

View File

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