elimination added
This commit is contained in:
@@ -2,6 +2,26 @@
|
||||
#include "tools/matrix.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 n, m;
|
||||
std::cin >> n;
|
||||
@@ -12,13 +32,18 @@ int main() {
|
||||
ColumnVector b(n);
|
||||
double eps;
|
||||
double eps_default;
|
||||
std::cin >> C;
|
||||
std::cin >> A;
|
||||
std::cin >> b;
|
||||
|
||||
std::cout << "Вектор C: " << C << std::endl;
|
||||
std::cout << "Вектор b: " << b << std::endl;
|
||||
|
||||
std::cout << "Матрица A: " << A << std::endl;
|
||||
|
||||
Matrix B(2, 2);
|
||||
std::cout << B << std::endl;
|
||||
Matrix E = createGeneralMatrix(A, C, b);
|
||||
|
||||
std::cout << "Новая матрица:" << E << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user