format project
This commit is contained in:
@@ -7,6 +7,8 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
PointerAlignment: Left
|
||||
SortIncludes: true
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SeparateDefinitionBlocks: Always
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
UseTab: Always
|
||||
MaxEmptyLinesToKeep: 5
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ Matrix::Matrix(const std::string& fileNameInput) {
|
||||
Matrix::Matrix(std::size_t lignes, std::size_t colonnes) : m_Lignes(lignes), m_Colonnes(colonnes) {
|
||||
m_Data.resize(m_Lignes * m_Colonnes);
|
||||
}
|
||||
|
||||
Matrix::Matrix(std::size_t lignes, std::size_t colonnes, std::initializer_list<long double>&& initList) :
|
||||
m_Lignes(lignes), m_Colonnes(colonnes) {
|
||||
m_Data = initList;
|
||||
@@ -69,7 +70,7 @@ void Matrix::Insert() {
|
||||
}
|
||||
|
||||
void Matrix::Save(const std::string& fileName) {
|
||||
std::ofstream out{fileName};
|
||||
std::ofstream out {fileName};
|
||||
if (!out) {
|
||||
std::cerr << "Impossible de sauvegarder la matrice !\n";
|
||||
return;
|
||||
@@ -78,7 +79,7 @@ void Matrix::Save(const std::string& fileName) {
|
||||
}
|
||||
|
||||
void Matrix::Load(const std::string& filename) {
|
||||
std::ifstream in{filename};
|
||||
std::ifstream in {filename};
|
||||
if (!in) {
|
||||
std::cerr << "Impossible de charger la matrice !\n";
|
||||
return;
|
||||
@@ -87,7 +88,7 @@ void Matrix::Load(const std::string& filename) {
|
||||
}
|
||||
|
||||
void Matrix::Transpose() {
|
||||
Matrix result{m_Colonnes, m_Lignes};
|
||||
Matrix result {m_Colonnes, m_Lignes};
|
||||
for (std::size_t i = 0; i < m_Lignes; i++) {
|
||||
for (std::size_t j = 0; j < m_Colonnes; j++) {
|
||||
result.at(j, i) = at(i, j);
|
||||
@@ -106,7 +107,7 @@ void Matrix::Identity() {
|
||||
}
|
||||
|
||||
Matrix Matrix::Identity(std::size_t taille) {
|
||||
Matrix id{taille, taille};
|
||||
Matrix id {taille, taille};
|
||||
id.Identity();
|
||||
return id;
|
||||
}
|
||||
@@ -126,7 +127,7 @@ bool Matrix::IsInversed() const {
|
||||
|
||||
void Matrix::Augmenter(const Matrix& droite) {
|
||||
assert(droite.m_Lignes == m_Lignes);
|
||||
Matrix temp{m_Lignes, m_Colonnes + droite.m_Colonnes};
|
||||
Matrix temp {m_Lignes, m_Colonnes + droite.m_Colonnes};
|
||||
|
||||
for (std::size_t i = 0; i < m_Lignes; i++) {
|
||||
for (std::size_t j = 0; j < m_Colonnes; j++) {
|
||||
@@ -245,7 +246,7 @@ std::size_t Matrix::GetColumnCount() const {
|
||||
|
||||
Matrix Matrix::SubMatrix(std::size_t origine_ligne, std::size_t origine_colonne, std::size_t ligne, std::size_t colonne) const {
|
||||
assert(m_Lignes >= ligne && m_Colonnes >= colonne);
|
||||
Matrix result{ligne, colonne};
|
||||
Matrix result {ligne, colonne};
|
||||
|
||||
for (std::size_t i = 0; i < ligne; i++) {
|
||||
for (std::size_t j = 0; j < colonne; j++) {
|
||||
|
||||
2
src/NR.h
2
src/NR.h
@@ -7,6 +7,8 @@ class NR {
|
||||
|
||||
public:
|
||||
NR() : m_Numerator(0), m_Denominator(1) {}
|
||||
|
||||
NR(int entier) : m_Numerator(entier), m_Denominator(1) {}
|
||||
|
||||
NR(int numerator, int denominator) : m_Numerator(numerator), m_Denominator(denominator) {}
|
||||
};
|
||||
@@ -29,7 +29,7 @@ VectAffine Solver::SystemeTriangulaire() const {
|
||||
Matrix mat = m_Matrix;
|
||||
mat.GaussJordan(true);
|
||||
|
||||
Solver solver{mat.SubMatrix(0, 0, mat.GetRawCount(), mat.GetColumnCount() - 1)};
|
||||
Solver solver {mat.SubMatrix(0, 0, mat.GetRawCount(), mat.GetColumnCount() - 1)};
|
||||
|
||||
Vect noyau = solver.Noyau();
|
||||
Matrix origin = mat.SubMatrix(0, mat.GetColumnCount() - 1, mat.GetRawCount(), 1);
|
||||
|
||||
@@ -8,6 +8,7 @@ class Solver {
|
||||
|
||||
public:
|
||||
Solver(const Matrix& mat);
|
||||
|
||||
~Solver() {}
|
||||
|
||||
Vect Image() const;
|
||||
|
||||
@@ -58,7 +58,7 @@ Matrix Vect::GetLinearSystem() const {
|
||||
Matrix vect = m_Data;
|
||||
vect.Transpose();
|
||||
|
||||
Solver solver{vect};
|
||||
Solver solver {vect};
|
||||
vect = solver.Noyau().m_Data;
|
||||
vect.Transpose();
|
||||
return vect;
|
||||
|
||||
@@ -38,7 +38,6 @@ class Vect {
|
||||
void Simplify();
|
||||
};
|
||||
|
||||
|
||||
class VectAffine {
|
||||
private:
|
||||
Vect m_Base;
|
||||
|
||||
@@ -16,10 +16,10 @@ void test() {
|
||||
mat.Print();
|
||||
// mat.Save("matrice4x4echelonne.mat"); */
|
||||
|
||||
Matrix mat2{"matrice4x4.mat"};
|
||||
Matrix mat2 {"matrice4x4.mat"};
|
||||
mat2.Print();
|
||||
|
||||
Solver solver{mat2};
|
||||
Solver solver {mat2};
|
||||
|
||||
Vect image = solver.Image();
|
||||
Vect noyau = solver.Noyau();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#error "Il faut être en debug mode ! xmake f -m debug"
|
||||
#endif
|
||||
|
||||
struct Test{
|
||||
struct Test {
|
||||
Matrix mat;
|
||||
Matrix res;
|
||||
};
|
||||
|
||||
@@ -14,15 +14,15 @@ int main() {
|
||||
|
||||
std::cout << "Opening " << fileName << " ...\n";
|
||||
|
||||
std::ifstream in{fileName};
|
||||
std::ifstream in {fileName};
|
||||
|
||||
Matrix mat{1, 1}, imageMat{1, 1}, noyauMat{1, 1};
|
||||
Matrix mat {1, 1}, imageMat {1, 1}, noyauMat {1, 1};
|
||||
in >> mat >> imageMat >> noyauMat;
|
||||
|
||||
Vect image{imageMat};
|
||||
Vect noyau{noyauMat};
|
||||
Vect image {imageMat};
|
||||
Vect noyau {noyauMat};
|
||||
|
||||
Solver solver{mat};
|
||||
Solver solver {mat};
|
||||
|
||||
assert(solver.Image() == image);
|
||||
assert(solver.Noyau() == noyau);
|
||||
|
||||
Reference in New Issue
Block a user