Commit af073f80 authored by Arťom Ňorba's avatar Arťom Ňorba
Browse files

update project

parent 114aaa33
......@@ -3,4 +3,4 @@ project(semestralka_pjc)
set(CMAKE_CXX_STANDARD 17)
add_executable(semestralka_pjc main.cpp)
add_executable(semestralka_pjc main.cpp Matrix.cpp Matrix.h MatrixHelper.cpp MatrixHelper.h)
//
// Created by Arťom Ňorba on 13.01.2022.
//
#include <iostream>
#include <iomanip>
#include "Matrix.h"
int Matrix::getRows() const{
return this->rows;
}
int Matrix::getColumns() const {
return this->columns;
}
vector<vector<double> > Matrix::getValues() {
return this->values;
}
void Matrix::setValuesBegin(vector<vector<double> > put) {
this->values = put;
}
double& Matrix::operator()(const int row, const int col) {
return this->values[row][col];
}
const double &Matrix::operator()(const int row, const int col) const {
return this->values[row][col];
}
void Matrix::changeValue(int row, int column, double value) {
if (((row + 1) > this->rows) || ((column + 1 ) > this->columns)){
cout << "u can not change that position because this position does not exist" << endl;
return;
}
this->values[row][column] = value;
}
void Matrix::printMatrix() {
cout << setprecision(2) << fixed;
cout << endl << "Your equation looks like this" << endl;
for(size_t i = 0; i < rows; i++){
for(size_t j = 0; j < columns; j++){
if (j == columns - 2){
cout << this->values[i][j] << " x" <<j << " = ";
}
else if (j == columns - 1){
cout << this->values[i][j];
}
else {
cout << this->values[i][j] << " x" <<j << " + ";
}
}
cout << endl;
}
}
vector<double> Matrix::getResultsArray() {
return this->results;
}
void Matrix::addResult(int pos, double res) {
this->results[pos] = res;
}
void Matrix::printResults() {
for(int i=0; i < results.size();i++){
cout<< "x" << i << " = " << results[i]<<"\n";
}
}
void Matrix::setResults(vector<double> res) {
this->results = res;
}
void Matrix::setResultArray() {
vector<double> resultik;
for (int i = 0; i < rows; ++i) {
resultik.push_back(0);
}
this->results = resultik;
}
//
// Created by Arťom Ňorba on 13.01.2022.
//
#ifndef SEMESTRALKA_PJC_MATRIX_H
#define SEMESTRALKA_PJC_MATRIX_H
#include <vector>
using namespace std;
class Matrix {
private:
int rows;
int columns;
vector<vector<double> > values;
vector<double> results;
public:
Matrix(int variables) : rows(variables), columns(variables + 1) {}
int getRows() const;
int getColumns() const;
vector<vector<double> > getValues();
void setValuesBegin(vector<vector<double> > put);
void changeValue(int row, int column, double value);
void printMatrix();
vector<double> getResultsArray();
void setResults(vector<double> res);
void addResult(int pos, double res);
void printResults();
void setResultArray();
double& operator()(int row, int col);
const double& operator()(int row, int col) const;
};
#endif //SEMESTRALKA_PJC_MATRIX_H
//
// Created by Arťom Ňorba on 13.01.2022.
//
#include <iostream>
#include "MatrixHelper.h"
void MatrixHelper::solveMatrix() {
for(int i=0;i<matrix.getRows();i++){
for(int j=i+1;j<matrix.getRows();j++){
if(abs(matrix(i,i)) < abs(matrix(j,i))){
for(int k=0;k<matrix.getColumns();k++){
matrix.changeValue(i, k,matrix(i,k)+matrix(j,k));
matrix.changeValue(j, k,matrix(i,k)-matrix(j,k));
matrix.changeValue(i, k,matrix(i,k)-matrix(j,k));
}
}
}
}
for(int i=0;i<matrix.getRows()-1;i++){
for(int j=i+1;j<matrix.getRows();j++){
double f = matrix(j,i) / matrix(i,i);
for(int k=0;k<matrix.getRows()+1;k++){
matrix.changeValue(j, k,matrix(j,k)-f*matrix(i,k));
}
}
}
cout << "\n here is matrix after gem";
matrix.printMatrix();
}
void MatrixHelper::printResults() {
matrix.setResultArray();
for(int i=matrix.getRows()-1;i>=0;i--){
matrix.addResult(i, matrix(i,matrix.getRows()));
for(int j=i+1;j<matrix.getRows();j++){
if(i!=j){
matrix.addResult(i, matrix.getResultsArray()[i] - matrix(i,j)*matrix.getResultsArray()[j]);
}
}
matrix.addResult(i, matrix.getResultsArray()[i] / matrix(i,i));
}
cout<<"\nHere are your results\n";
cout<<"_____________________\n";
int index = 0;
for (double number : matrix.getResultsArray()) {
cout << "x" <<index << " = " << number <<endl;
index++;
}
}
//
// Created by Arťom Ňorba on 13.01.2022.
//
#ifndef SEMESTRALKA_PJC_MATRIXHELPER_H
#define SEMESTRALKA_PJC_MATRIXHELPER_H
#include "Matrix.h"
class MatrixHelper {
private:
Matrix matrix;
public:
explicit MatrixHelper(const Matrix &matrix) : matrix(matrix) {}
void solveMatrix();
void printResults();
};
#endif //SEMESTRALKA_PJC_MATRIXHELPER_H
{
"inputs" :
[
{
"path" : "CMakeLists.txt"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.21.1/CMakeSystem.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeSystemSpecificInitialize.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Darwin-Initialize.cmake"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.21.1/CMakeCCompiler.cmake"
},
{
"isGenerated" : true,
"path" : "cmake-build-debug/CMakeFiles/3.21.1/CMakeCXXCompiler.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeSystemSpecificInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeGenericSystem.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeInitializeConfigs.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Darwin.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/UnixPaths.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeCInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeLanguageInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/AppleClang-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/GNU.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-AppleClang-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-Clang-C.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeCommonLanguageInclude.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeCXXInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeLanguageInformation.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/AppleClang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Compiler/Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-AppleClang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-Clang-CXX.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Apple-Clang.cmake"
},
{
"isCMake" : true,
"isExternal" : true,
"path" : "/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/CMakeCommonLanguageInclude.cmake"
}
],
"kind" : "cmakeFiles",
"paths" :
{
"build" : "/Users/artomnorba/Desktop/semestralka_pjc/semestralka_pjc/cmake-build-debug",
"source" : "/Users/artomnorba/Desktop/semestralka_pjc/semestralka_pjc"
},
"version" :
{
"major" : 1,
"minor" : 0
}
}
......@@ -39,7 +39,7 @@
{
"directoryIndex" : 0,
"id" : "semestralka_pjc::@6890427a1f51a3e7e1df",
"jsonFile" : "target-semestralka_pjc-Debug-ae02f3dfae1dfc9c1716.json",
"jsonFile" : "target-semestralka_pjc-Debug-95b54b8ade35c2a1a3ae.json",
"name" : "semestralka_pjc",
"projectIndex" : 0
}
......
......@@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-057c5f33733d77423b70.json",
"jsonFile" : "codemodel-v2-2fd502c5cc2fccfba1e2.json",
"kind" : "codemodel",
"version" :
{
......@@ -44,7 +44,7 @@
}
},
{
"jsonFile" : "cmakeFiles-v1-75c26d33665e5ee5d619.json",
"jsonFile" : "cmakeFiles-v1-afd644a44ae6f437b898.json",
"kind" : "cmakeFiles",
"version" :
{
......@@ -76,7 +76,7 @@
},
"cmakeFiles-v1" :
{
"jsonFile" : "cmakeFiles-v1-75c26d33665e5ee5d619.json",
"jsonFile" : "cmakeFiles-v1-afd644a44ae6f437b898.json",
"kind" : "cmakeFiles",
"version" :
{
......@@ -86,7 +86,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-057c5f33733d77423b70.json",
"jsonFile" : "codemodel-v2-2fd502c5cc2fccfba1e2.json",
"kind" : "codemodel",
"version" :
{
......
......@@ -52,7 +52,9 @@
},
"sourceIndexes" :
[
0
0,
1,
3
]
}
],
......@@ -85,7 +87,17 @@
"name" : "Source Files",
"sourceIndexes" :
[
0
0,
1,
3
]
},
{
"name" : "Header Files",
"sourceIndexes" :
[
2,
4
]
}
],
......@@ -96,6 +108,28 @@
"compileGroupIndex" : 0,
"path" : "main.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "Matrix.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "Matrix.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "MatrixHelper.cpp",
"sourceGroupIndex" : 0
},
{
"backtrace" : 1,
"path" : "MatrixHelper.h",
"sourceGroupIndex" : 1
}
],
"type" : "EXECUTABLE"
......
# ninja log v5
0 1402 1642011121261455160 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1404 1509 1642011121377049308 semestralka_pjc 88033d60ffc25d6a
3 313 1642012790752173249 CMakeFiles/semestralka_pjc.dir/matrix.cpp.o 313099488ec8d21f
1305 1411 1642091323347151625 semestralka_pjc bfe274bfcd70048c
2 133 1642083287396910736 CMakeFiles/semestralka_pjc.dir/MatrixSolver.cpp.o 57ce33c8a43b7f2e
2 1305 1642091323232319283 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
0 266 1642091420917250024 build.ninja 5b41b40d76b7bfac
4 1030 1642090875583074795 CMakeFiles/semestralka_pjc.dir/Matrix.cpp.o f9806aba2a6f6dfd
0 177 1642091420917250024 build.ninja 5b41b40d76b7bfac
2 52 1642091421004565665 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
2 1285 1642091422229814510 CMakeFiles/semestralka_pjc.dir/Matrix.cpp.o f9806aba2a6f6dfd
3 1698 1642091422644589231 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1698 1779 1642091422730622480 semestralka_pjc e23c61409220f109
4 1542 1642091509504912506 CMakeFiles/semestralka_pjc.dir/Matrix.cpp.o f9806aba2a6f6dfd
3 1986 1642091509950381038 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1986 2122 1642091510091652755 semestralka_pjc e23c61409220f109
2 487 1642091680464020191 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
2 1172 1642091681141830309 CMakeFiles/semestralka_pjc.dir/Matrix.cpp.o f9806aba2a6f6dfd
2 1603 1642091681575786502 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1603 1703 1642091681681698464 semestralka_pjc e23c61409220f109
3 435 1642091863123689582 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
2 1263 1642091863943878894 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1263 1347 1642091864039244824 semestralka_pjc e23c61409220f109
2 788 1642091934040211671 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
789 907 1642091934162338905 semestralka_pjc e23c61409220f109
2 883 1642091995344143999 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
1 1331 1642091995791649858 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1331 1396 1642091995865439529 semestralka_pjc e23c61409220f109
2 775 1642092134796913927 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
776 889 1642092134921823668 semestralka_pjc e23c61409220f109
3 883 1642092264428610428 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
3 981 1642092264530885725 CMakeFiles/semestralka_pjc.dir/Matrix.cpp.o f9806aba2a6f6dfd
2 1243 1642092264791236748 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1244 1320 1642092264874816762 semestralka_pjc e23c61409220f109
3 761 1642092297216194474 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
761 829 1642092297287504130 semestralka_pjc e23c61409220f109
2 882 1642092402365619560 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
2 1359 1642092402842534641 CMakeFiles/semestralka_pjc.dir/main.cpp.o a8f001d087801410
1359 1429 1642092402917372314 semestralka_pjc e23c61409220f109
3 830 1642092422695881050 CMakeFiles/semestralka_pjc.dir/MatrixHelper.cpp.o d6e62ab562d627c0
830 894 1642092422764729782 semestralka_pjc e23c61409220f109
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/ninja -G Ninja /Users/artomnorba/Desktop/semestralka_pjc/semestralka_pjc
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/artomnorba/Desktop/semestralka_pjc/semestralka_pjc/cmake-build-debug
Start testing: Jan 12 19:12 CET
Start testing: Jan 13 17:47 CET
----------------------------------------------------------
End testing: Jan 12 19:12 CET
End testing: Jan 13 17:47 CET
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment