merge (inapropriately) detached2 to main
This commit is contained in:
@@ -12,7 +12,7 @@ FracturedMatrix& FracturedMatrix::operator=(const FracturedMatrix& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
DestroyMatrix destroyGeneralMatrix(Matrix& generalMatrix) {
|
||||
DestroyMatrix disassembleGeneralMatrix(Matrix& generalMatrix) {
|
||||
int rows = generalMatrix.getRows();
|
||||
int cols = generalMatrix.getColumns();
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ struct DestroyMatrix {
|
||||
Vector b;
|
||||
};
|
||||
|
||||
DestroyMatrix destroyGeneralMatrix(Matrix& generalMatrix);
|
||||
DestroyMatrix disassembleGeneralMatrix(Matrix& generalMatrix);
|
||||
void elimination(Matrix&, int pivot_row_index, int pivot_column_index);
|
||||
Matrix createGeneralMatrix(Matrix& A, Vector& C, Vector& b);
|
||||
|
||||
|
||||
@@ -1,5 +1,47 @@
|
||||
#include "matrix.h"
|
||||
|
||||
void showMatrix(Matrix matrix) {
|
||||
int maxNumberLength = 1;
|
||||
for (size_t y = 0; y < matrix.getRows(); y++) {
|
||||
for (size_t x = 0; x < matrix.getColumns(); x++) {
|
||||
if (std::to_string(matrix[y][x]).length() > maxNumberLength) {
|
||||
maxNumberLength = std::to_string(matrix[y][x]).length();
|
||||
}
|
||||
}
|
||||
}
|
||||
//std::cout << maxNumberLength << std::endl;
|
||||
std::cout << std::endl;
|
||||
for (size_t y = 0; y < matrix.getRows(); y++) {
|
||||
std::string row = "";
|
||||
for (size_t x = 0; x < matrix.getColumns(); x++) {
|
||||
std::string strNumber = std::to_string(matrix[y][x]);
|
||||
bool spaceRight = true;
|
||||
while (strNumber.length() < maxNumberLength) {
|
||||
if (spaceRight) {
|
||||
strNumber += " ";
|
||||
}
|
||||
else {
|
||||
strNumber = " " + strNumber;
|
||||
}
|
||||
spaceRight = !spaceRight;
|
||||
strNumber = "" + strNumber;
|
||||
|
||||
}
|
||||
if (matrix[y][x] == 0) {
|
||||
row += "[\033[0m" + strNumber + "\033[0m] ";
|
||||
}
|
||||
else if(matrix[y][x] > 0) {
|
||||
row += "[\033[32m" + strNumber + "\033[0m] ";
|
||||
}else {
|
||||
row += "[\033[31m" + strNumber + "\033[0m] ";
|
||||
}
|
||||
|
||||
}
|
||||
std::cout << row << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
Vector::Vector(int n) {
|
||||
rows = n;
|
||||
columns = 1;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
* Vector is a class to represent
|
||||
* a column vector with n rows.
|
||||
*/
|
||||
|
||||
|
||||
class Vector {
|
||||
protected:
|
||||
// Number of rows in vector
|
||||
@@ -95,4 +97,6 @@ public:
|
||||
friend std::ostream& operator<<(std::ostream& cout, Matrix& matrixObj);
|
||||
};
|
||||
|
||||
void showMatrix(Matrix);
|
||||
|
||||
#endif // TOOLS_MATRIX_H
|
||||
|
||||
Reference in New Issue
Block a user