1
0
forked from leto/LeMA

Sub to Substract

This commit is contained in:
Leto 2024-12-23 21:27:18 +01:00
parent 8418342bf7
commit 4f11d1e4fa

View File

@ -13,13 +13,13 @@ class Matrix{
void Set(float); void Set(float);
void Factor(float); void Multiply(float);
void Add(float); void Add(float);
void Add(Matrix*); void Add(Matrix*);
void Sub(float); void Substract(float);
void Sub(Matrix*); void Substract(Matrix*);
void Print(std::string_view); void Print(std::string_view);
@ -54,7 +54,7 @@ void Matrix::Add(Matrix* other){
} }
// Substract 2 matrices // Substract 2 matrices
void Matrix::Sub(Matrix* other){ void Matrix::Substract(Matrix* other){
// Matrices need to be the same size // Matrices need to be the same size
assertm(this->values.size() == other->values.size() && assertm(this->values.size() == other->values.size() &&
this->values[0].size() == other->values[0].size(), this->values[0].size() == other->values[0].size(),
@ -88,7 +88,7 @@ void Matrix::Add(float value){
} }
// Substract a constant value to every matrix case // Substract a constant value to every matrix case
void Matrix::Sub(float value){ void Matrix::Substract(float value){
for(int m = 0; m < this->values.size(); m++){ for(int m = 0; m < this->values.size(); m++){
for(int n = 0; n < this->values[m].size(); n++){ for(int n = 0; n < this->values[m].size(); n++){
this->values[m][n] -= value; this->values[m][n] -= value;
@ -97,7 +97,7 @@ void Matrix::Sub(float value){
} }
// Multiply every matrix case by a given factor // Multiply every matrix case by a given factor
void Matrix::Factor(float value){ void Matrix::Multiply(float value){
for(int m = 0; m < this->values.size(); m++){ for(int m = 0; m < this->values.size(); m++){
for(int n = 0; n < this->values[m].size(); n++){ for(int n = 0; n < this->values[m].size(); n++){
this->values[m][n] *= value; this->values[m][n] *= value;
@ -107,7 +107,7 @@ void Matrix::Factor(float value){
// Set a matrix to a given value // Set a matrix to a given value
void Matrix::Set(float value){ void Matrix::Set(float value){
this->Factor(0.0F); this->Multiply(0.0F);
this->Add(value); this->Add(value);
} }