elimination added
This commit is contained in:
@@ -2,6 +2,26 @@
|
|||||||
#include "tools/matrix.h"
|
#include "tools/matrix.h"
|
||||||
#include "tools/math.h"
|
#include "tools/math.h"
|
||||||
|
|
||||||
|
Matrix createGeneralMatrix(Matrix& A, ColumnVector& C, ColumnVector& b) {
|
||||||
|
Matrix generalMatrix(A.getRows() + 1, A.getColumns() + 1);
|
||||||
|
for (int i = 0; i < A.getColumns(); i++) {
|
||||||
|
generalMatrix[0][i] = C[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
generalMatrix[0][A.getColumns()] = 0;
|
||||||
|
for (int j = 0; j < A.getRows(); j++) {
|
||||||
|
generalMatrix[j + 1][A.getColumns()] = b[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < A.getRows(); i++) {
|
||||||
|
for (int j = 0; j < A.getColumns(); j++) {
|
||||||
|
generalMatrix[i + 1][j] = A[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return generalMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int n, m;
|
int n, m;
|
||||||
std::cin >> n;
|
std::cin >> n;
|
||||||
@@ -12,13 +32,18 @@ int main() {
|
|||||||
ColumnVector b(n);
|
ColumnVector b(n);
|
||||||
double eps;
|
double eps;
|
||||||
double eps_default;
|
double eps_default;
|
||||||
|
std::cin >> C;
|
||||||
std::cin >> A;
|
std::cin >> A;
|
||||||
|
std::cin >> b;
|
||||||
|
|
||||||
std::cout << "Вектор C: " << C << std::endl;
|
std::cout << "Вектор C: " << C << std::endl;
|
||||||
|
std::cout << "Вектор b: " << b << std::endl;
|
||||||
|
|
||||||
std::cout << "Матрица A: " << A << std::endl;
|
std::cout << "Матрица A: " << A << std::endl;
|
||||||
|
|
||||||
Matrix B(2, 2);
|
Matrix E = createGeneralMatrix(A, C, b);
|
||||||
std::cout << B << std::endl;
|
|
||||||
|
std::cout << "Новая матрица:" << E << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "elimination.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
|
Matrix createGeneralMatrix(Matrix& A, ColumnVector& C, ColumnVector& b) {
|
||||||
|
Matrix generalMatrix(A.getRows() + 1, A.getColumns() + 1);
|
||||||
|
for (int i = 0; i < A.getColumns(); i++) {
|
||||||
|
generalMatrix[0][i] = C[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
generalMatrix[0][A.getColumns()] = 0;
|
||||||
|
for (int j = 0; j < A.getRows(); j++) {
|
||||||
|
generalMatrix[j + 1][A.getColumns()] = b[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < A.getRows(); i++) {
|
||||||
|
for (int j = 0; j < A.getColumns(); j++) {
|
||||||
|
generalMatrix[i + 1][j] = A[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return generalMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix elimination(Matrix A, ColumnVector C, ColumnVector b, int pivot_column_index, int pivot_row_index, double eps) {
|
||||||
|
Matrix generalMatrix = createGeneralMatrix(A, C, b);
|
||||||
|
|
||||||
|
|
||||||
|
return generalMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef ELIMINATION_H
|
||||||
|
#define ELIMINATION_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Elimination {
|
||||||
|
public:
|
||||||
|
Matrix elimination(Matrix A, ColumnVector C, ColumnVector b, int pivot_column_index, int pivot_row_index, double eps);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //ELIMINATION_H
|
||||||
@@ -1 +0,0 @@
|
|||||||
#include "gauss_jordan.h"
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef GAUSS_JORDAN_H
|
|
||||||
#define GAUSS_JORDAN_H
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class gauss_jordan {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //GAUSS_JORDAN_H
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class ColumnVector;
|
class ColumnVector;
|
||||||
|
class Matrix;
|
||||||
|
|
||||||
class Math {
|
class Math {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user