math.cpp added

This commit is contained in:
Spectre
2024-09-21 22:41:49 +07:00
parent c73cdc184b
commit c7edcf8232
4 changed files with 62 additions and 11 deletions
+41
View File
@@ -1 +1,42 @@
#include "math.h"
#include "matrix.h"
double Math::minVector(ColumnVector columnVector) {
double temp = columnVector[0];
for (int j = 0; j < columnVector.getColumns(); j++) {
if (columnVector[j] < temp) {
temp = columnVector[j];
}
}
return temp;
}
double Math::maxVector(ColumnVector columnVector) {
double temp = columnVector[0];
for (int j = 0; j < columnVector.getColumns(); j++) {
if (columnVector[j] > temp) {
temp = columnVector[j];
}
}
return temp;
}
double Math::minArray(std::vector<double> array) {
double temp = array[0];
for (size_t i = 1; i < array.size(); i++) {
if (array[i] < temp) {
temp = array[i];
}
}
return temp;
}
double Math::maxArray(std::vector<double> array) {
double temp = array[0];
for (size_t i = 1; i < array.size(); i++) {
if (array[i] > temp) {
temp = array[i];
}
}
return temp;
}