6 Commits

Author SHA1 Message Date
8c004b64ed caca
All checks were successful
Linux arm64 / Build (push) Successful in 41m33s
2024-05-14 19:00:04 +02:00
a135df2e96 trop de trucs
All checks were successful
Linux arm64 / Build (push) Successful in 2m33s
2024-05-14 13:00:59 +02:00
d9e49d1319 forgot this 2024-05-13 21:30:52 +02:00
e127ff8c29 easier to debug assert 2024-05-13 21:11:40 +02:00
9b423f9c83 fix react system 2024-05-13 21:11:20 +02:00
fa7e70a437 better fill 2024-05-13 21:10:23 +02:00
25 changed files with 2619 additions and 254 deletions

4
.vscode/launch.json vendored
View File

@@ -7,8 +7,8 @@
{ {
"type": "xmake", "type": "xmake",
"request": "launch", "request": "launch",
"name": "Debug XMake target", "name": "Debug random kernel",
"target": "Pivot", "target": "test_random_kernel",
"cwd": "${workspaceFolder}/matricies", "cwd": "${workspaceFolder}/matricies",
} }
] ]

19
.vscode/settings.json vendored
View File

@@ -44,6 +44,23 @@
"stdexcept": "cpp", "stdexcept": "cpp",
"streambuf": "cpp", "streambuf": "cpp",
"cinttypes": "cpp", "cinttypes": "cpp",
"typeinfo": "cpp" "typeinfo": "cpp",
"codecvt": "cpp",
"condition_variable": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"ratio": "cpp",
"fstream": "cpp",
"future": "cpp",
"iomanip": "cpp",
"mutex": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stop_token": "cpp",
"thread": "cpp",
"chrono": "cpp",
"optional": "cpp",
"ranges": "cpp",
"span": "cpp"
} }
} }

16
imgui.ini Normal file
View File

@@ -0,0 +1,16 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
[Window][Right Top Window]
Pos=640,0
Size=640,576
[Window][Bottom Part]
Pos=0,576
Size=1280,144
[Window][Left Top Window]
Pos=0,0
Size=640,576

View File

@@ -1,49 +0,0 @@
#pragma once
#include <string>
#include <gmp.h>
/**
* \class BigInt
* \brief Représente un entier d'une taille quelconque
* \warning Prend énormément de place en mémoire. À utiliser avec précaution !
*/
class BigInt {
private:
mpz_t m_Data;
public:
BigInt(std::string&& a_Number);
BigInt(long a_Number = 0);
BigInt(const BigInt& a_Copy);
BigInt(BigInt&& a_Move);
~BigInt();
BigInt operator+(const BigInt& a_Other);
BigInt operator-(const BigInt& a_Other);
BigInt operator*(const BigInt& a_Other);
BigInt operator/(const BigInt& a_Other);
BigInt operator+=(const BigInt& a_Other);
BigInt operator-=(const BigInt& a_Other);
BigInt operator*=(const BigInt& a_Other);
BigInt operator/=(const BigInt& a_Other);
bool operator==(const BigInt& a_Other);
void operator=(const BigInt& a_Other);
const std::string ToString() const;
bool IsEqualZero() const;
};

View File

@@ -10,14 +10,10 @@
class Matrix; class Matrix;
class Vect; class Vect;
class VectAffine; class VectAffine;
class BigInt;
std::ostream& operator<<(std::ostream& stream, const Matrix& mat); std::ostream& operator<<(std::ostream& stream, const Matrix& mat);
std::istream& operator>>(std::istream& stream, Matrix& mat); std::istream& operator>>(std::istream& stream, Matrix& mat);
std::ostream& operator<<(std::ostream& stream, const BigInt& nbre);
std::istream& operator>>(std::istream& stream, BigInt& nbre);
/** /**
* \brief Charge une matrice à partir d'un fichier * \brief Charge une matrice à partir d'un fichier
* \param fileName Le chemin du fichier à charger * \param fileName Le chemin du fichier à charger

View File

@@ -10,7 +10,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "BigInt.h" #include "NR.h"
/** /**
* \class Matrix * \class Matrix
@@ -171,6 +171,6 @@ inline bool IsEqualZero(const long& var) {
} }
template <> template <>
inline bool IsEqualZero(const BigInt& var) { inline bool IsEqualZero(const NR& var) {
return var.IsEqualZero(); return var == 0;
} }

View File

@@ -3,17 +3,20 @@
#include <iostream> #include <iostream>
class NR { class NR {
public:
using Int = long long;
private: private:
int m_Numerator; Int m_Numerator;
int m_Denominator; // has to be > 0, sign is carried by the numerator Int m_Denominator; // has to be > 0, sign is carried by the numerator
public: public:
NR(); NR();
NR(int entier); NR(Int entier);
NR(int numerator, int denominator); // check if denominator != 0 NR(Int numerator, Int denominator); // check if denominator != 0
int GetNumerator() const; Int GetNumerator() const;
int GetDenominator() const; Int GetDenominator() const;
bool operator==(const NR& opNR) const; bool operator==(const NR& opNR) const;
bool operator<(const NR& opNR) const; bool operator<(const NR& opNR) const;
@@ -43,5 +46,3 @@ class NR {
private: private:
void Reduce(); void Reduce();
}; };
int PGCD(int x, int y);

BIN
matricies/core Normal file

Binary file not shown.

2067
matricies/plot.eps Normal file

File diff suppressed because it is too large Load Diff

BIN
matricies/plot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

135
matricies/plot.tex Normal file
View File

@@ -0,0 +1,135 @@
% GNUPLOT: LaTeX picture with Postscript
\begingroup
\makeatletter
\providecommand\color[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package color not loaded in conjunction with
terminal option `colourtext'%
}{See the gnuplot documentation for explanation.%
}{Either use 'blacktext' in gnuplot or load the package
color.sty in LaTeX.}%
\renewcommand\color[2][]{}%
}%
\providecommand\includegraphics[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package graphicx or graphics not loaded%
}{See the gnuplot documentation for explanation.%
}{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
\renewcommand\includegraphics[2][]{}%
}%
\providecommand\rotatebox[2]{#2}%
\@ifundefined{ifGPcolor}{%
\newif\ifGPcolor
\GPcolortrue
}{}%
\@ifundefined{ifGPblacktext}{%
\newif\ifGPblacktext
\GPblacktexttrue
}{}%
% define a \g@addto@macro without @ in the name:
\let\gplgaddtomacro\g@addto@macro
% define empty templates for all commands taking text:
\gdef\gplbacktext{}%
\gdef\gplfronttext{}%
\makeatother
\ifGPblacktext
% no textcolor at all
\def\colorrgb#1{}%
\def\colorgray#1{}%
\else
% gray or color?
\ifGPcolor
\def\colorrgb#1{\color[rgb]{#1}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
\expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
\expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
\expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
\expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
\expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
\expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
\expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
\expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
\else
% gray
\def\colorrgb#1{\color{black}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color{black}}%
\expandafter\def\csname LT1\endcsname{\color{black}}%
\expandafter\def\csname LT2\endcsname{\color{black}}%
\expandafter\def\csname LT3\endcsname{\color{black}}%
\expandafter\def\csname LT4\endcsname{\color{black}}%
\expandafter\def\csname LT5\endcsname{\color{black}}%
\expandafter\def\csname LT6\endcsname{\color{black}}%
\expandafter\def\csname LT7\endcsname{\color{black}}%
\expandafter\def\csname LT8\endcsname{\color{black}}%
\fi
\fi
\setlength{\unitlength}{0.0500bp}%
\ifx\gptboxheight\undefined%
\newlength{\gptboxheight}%
\newlength{\gptboxwidth}%
\newsavebox{\gptboxtext}%
\fi%
\setlength{\fboxrule}{0.5pt}%
\setlength{\fboxsep}{1pt}%
\definecolor{tbcol}{rgb}{1,1,1}%
\begin{picture}(7200.00,5040.00)%
\gplgaddtomacro\gplbacktext{%
\colorrgb{0.15,0.15,0.15}%%
\put(803,554){\makebox(0,0)[r]{\strut{}0}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,1141){\makebox(0,0)[r]{\strut{}0.05}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,1727){\makebox(0,0)[r]{\strut{}0.1}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,2314){\makebox(0,0)[r]{\strut{}0.15}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,2901){\makebox(0,0)[r]{\strut{}0.2}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,3488){\makebox(0,0)[r]{\strut{}0.25}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,4074){\makebox(0,0)[r]{\strut{}0.3}}%
\colorrgb{0.15,0.15,0.15}%%
\put(803,4661){\makebox(0,0)[r]{\strut{}0.35}}%
\colorrgb{0.15,0.15,0.15}%%
\put(935,334){\makebox(0,0){\strut{}0}}%
\colorrgb{0.15,0.15,0.15}%%
\put(1865,334){\makebox(0,0){\strut{}50}}%
\colorrgb{0.15,0.15,0.15}%%
\put(2795,334){\makebox(0,0){\strut{}100}}%
\colorrgb{0.15,0.15,0.15}%%
\put(3725,334){\makebox(0,0){\strut{}150}}%
\colorrgb{0.15,0.15,0.15}%%
\put(4655,334){\makebox(0,0){\strut{}200}}%
\colorrgb{0.15,0.15,0.15}%%
\put(5585,334){\makebox(0,0){\strut{}250}}%
\colorrgb{0.15,0.15,0.15}%%
\put(6515,334){\makebox(0,0){\strut{}300}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%%
\put(66,2607){\rotatebox{-270}{\makebox(0,0){\strut{}Temps d'exécution (s)}}}%
\put(3725,4){\makebox(0,0){\strut{}Taille des matrices}}%
\csname LTb\endcsname%%
\put(1922,4488){\makebox(0,0)[l]{\strut{}Echelonnage non réduit}}%
\csname LTb\endcsname%%
\put(1922,4268){\makebox(0,0)[l]{\strut{}Echelonnage réduit}}%
\csname LTb\endcsname%%
\put(1922,4048){\makebox(0,0)[l]{\strut{}Echelonnage non réduit normalisé}}%
\csname LTb\endcsname%%
\put(1922,3828){\makebox(0,0)[l]{\strut{}Echelonnage réduit normalisé}}%
\csname LTb\endcsname%%
\put(3725,4991){\makebox(0,0){/:Bold Echelonnage de matrices}}%
}%
\gplbacktext
\put(0,0){\includegraphics[width={360.00bp},height={252.00bp}]{plot}}%
\gplfronttext
\end{picture}%
\endgroup

View File

@@ -1,86 +0,0 @@
#include "BigInt.h"
#include <cassert>
BigInt::~BigInt() {
mpz_clear(m_Data);
}
BigInt::BigInt(BigInt&& a_Move) {
std::swap(m_Data, a_Move.m_Data);
}
BigInt::BigInt(std::string&& a_Number) {
mpz_init_set_str(m_Data, a_Number.c_str(), 10);
}
BigInt::BigInt(long a_Number) {
mpz_init_set_si(m_Data, a_Number);
}
BigInt::BigInt(const BigInt& a_Copy) {
mpz_init_set(m_Data, a_Copy.m_Data);
}
void BigInt::operator=(const BigInt& a_Other) {
mpz_init_set(m_Data, a_Other.m_Data);
}
BigInt BigInt::operator+(const BigInt& a_Other) {
BigInt result = *this;
result += a_Other;
return result;
}
BigInt BigInt::operator-(const BigInt& a_Other) {
BigInt result = *this;
result -= a_Other;
return result;
}
BigInt BigInt::operator*(const BigInt& a_Other) {
BigInt result = *this;
result *= a_Other;
return result;
}
BigInt BigInt::operator/(const BigInt& a_Other) {
BigInt result = *this;
result /= a_Other;
return result;
}
BigInt BigInt::operator+=(const BigInt& a_Other) {
mpz_add(m_Data, m_Data, a_Other.m_Data);
return *this;
}
BigInt BigInt::operator-=(const BigInt& a_Other) {
mpz_sub(m_Data, m_Data, a_Other.m_Data);
return *this;
}
BigInt BigInt::operator*=(const BigInt& a_Other) {
mpz_mul(m_Data, m_Data, a_Other.m_Data);
return *this;
}
BigInt BigInt::operator/=(const BigInt& a_Other) {
mpz_divexact(m_Data, m_Data, a_Other.m_Data);
return *this;
}
bool BigInt::operator==(const BigInt& a_Other) {
return mpz_cmp(m_Data, a_Other.m_Data) == 0;
}
const std::string BigInt::ToString() const {
std::string result;
result.reserve(mpz_sizeinbase(m_Data, 10) + 2);
mpz_get_str(result.data(), 10, m_Data);
return result.c_str();
}
bool BigInt::IsEqualZero() const {
return mpz_cmp_si(m_Data, 0) == 0;
}

View File

@@ -16,6 +16,10 @@ static void SwapLines(Matrix& mat, std::size_t line1, std::size_t line2) {
static void DivideLine(Matrix& mat, std::size_t line, Matrix::Element number) { static void DivideLine(Matrix& mat, std::size_t line, Matrix::Element number) {
std::transform(std::execution::par_unseq, mat.GetLineIterator(line), mat.GetLineIterator(line + 1), mat.GetLineIterator(line), std::transform(std::execution::par_unseq, mat.GetLineIterator(line), mat.GetLineIterator(line + 1), mat.GetLineIterator(line),
[number](Matrix::Element e) { return e /= number; }); [number](Matrix::Element e) { return e /= number; });
/*for (std::size_t i = 0; i < mat.GetColumnCount(); i++) {
mat.at(line, i) /= number;
}*/
} }
static int FirstNotNullElementIndexOnColumn(Matrix& mat, std::size_t column, std::size_t startLine = 0) { static int FirstNotNullElementIndexOnColumn(Matrix& mat, std::size_t column, std::size_t startLine = 0) {
@@ -38,7 +42,7 @@ static void SimplifyLine(Matrix& mat, std::size_t line, std::size_t pivot_line,
}); });
} }
static void GaussJordanReduced(Matrix& a_Matrix, bool a_Normalise) { static void GaussJordanReducedNorma(Matrix& a_Matrix) {
int indice_ligne_pivot = -1; int indice_ligne_pivot = -1;
for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) { for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) {
@@ -56,9 +60,7 @@ static void GaussJordanReduced(Matrix& a_Matrix, bool a_Normalise) {
Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j); Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j);
if (a_Normalise) { DivideLine(a_Matrix, indice_ligne_pivot, pivot);
DivideLine(a_Matrix, indice_ligne_pivot, pivot);
}
auto range = std::views::iota(static_cast<std::size_t>(0), a_Matrix.GetRawCount()); auto range = std::views::iota(static_cast<std::size_t>(0), a_Matrix.GetRawCount());
@@ -71,7 +73,7 @@ static void GaussJordanReduced(Matrix& a_Matrix, bool a_Normalise) {
} }
} }
static void GaussJordanTriangular(Matrix& a_Matrix, bool a_Normalise) { static void GaussJordanReduced(Matrix& a_Matrix) {
int indice_ligne_pivot = -1; int indice_ligne_pivot = -1;
for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) { for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) {
@@ -89,25 +91,85 @@ static void GaussJordanTriangular(Matrix& a_Matrix, bool a_Normalise) {
Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j); Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j);
if (a_Normalise) { auto range = std::views::iota(static_cast<std::size_t>(0), a_Matrix.GetRawCount());
DivideLine(a_Matrix, indice_ligne_pivot, pivot);
// On simplifie les autres lignes
std::for_each(std::execution::par_unseq, range.begin(), range.end(), [&a_Matrix, j, indice_ligne_pivot](std::size_t i) {
if (i != static_cast<std::size_t>(indice_ligne_pivot)) {
SimplifyLine(a_Matrix, i, indice_ligne_pivot, j);
}
});
}
}
static void GaussJordanTriangular(Matrix& a_Matrix) {
int indice_ligne_pivot = -1;
for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) {
int indice_ligne_pivot_trouve = FirstNotNullElementIndexOnColumn(a_Matrix, j, indice_ligne_pivot + 1);
if (indice_ligne_pivot_trouve < 0) // colonne de 0
continue; // on regarde la prochaine colonne
indice_ligne_pivot++;
if (indice_ligne_pivot_trouve != indice_ligne_pivot) {
SwapLines(a_Matrix, indice_ligne_pivot_trouve, indice_ligne_pivot);
} }
Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j);
auto range = std::views::iota(static_cast<std::size_t>(indice_ligne_pivot + 1), a_Matrix.GetRawCount()); auto range = std::views::iota(static_cast<std::size_t>(indice_ligne_pivot + 1), a_Matrix.GetRawCount());
// On simplifie les autres lignes après la ligne du pivot // On simplifie les autres lignes après la ligne du pivot
std::for_each(std::execution::par_unseq, range.begin(), range.end(), std::for_each(std::execution::par_unseq, range.begin(), range.end(),
[&a_Matrix, indice_ligne_pivot, j](std::size_t i) { [&a_Matrix, indice_ligne_pivot, j](std::size_t i) { SimplifyLine(a_Matrix, i, indice_ligne_pivot, j); });
SimplifyLine(a_Matrix, i, indice_ligne_pivot, j); }
}); }
static void GaussJordanTriangularNorma(Matrix& a_Matrix) {
int indice_ligne_pivot = -1;
for (std::size_t j = 0; j < a_Matrix.GetColumnCount(); j++) {
int indice_ligne_pivot_trouve = FirstNotNullElementIndexOnColumn(a_Matrix, j, indice_ligne_pivot + 1);
if (indice_ligne_pivot_trouve < 0) // colonne de 0
continue; // on regarde la prochaine colonne
indice_ligne_pivot++;
if (indice_ligne_pivot_trouve != indice_ligne_pivot) {
SwapLines(a_Matrix, indice_ligne_pivot_trouve, indice_ligne_pivot);
}
Matrix::Element pivot = a_Matrix.at(indice_ligne_pivot, j);
DivideLine(a_Matrix, indice_ligne_pivot, pivot);
auto range = std::views::iota(static_cast<std::size_t>(indice_ligne_pivot + 1), a_Matrix.GetRawCount());
// On simplifie les autres lignes après la ligne du pivot
std::for_each(std::execution::par_unseq, range.begin(), range.end(),
[&a_Matrix, indice_ligne_pivot, j](std::size_t i) { SimplifyLine(a_Matrix, i, indice_ligne_pivot, j); });
} }
} }
void GaussJordan(Matrix& a_Matrix, bool a_Reduite, bool a_Normalise) { void GaussJordan(Matrix& a_Matrix, bool a_Reduite, bool a_Normalise) {
if (a_Reduite) if (a_Reduite) {
GaussJordanReduced(a_Matrix, a_Normalise); if (a_Normalise) {
else GaussJordanReducedNorma(a_Matrix);
GaussJordanTriangular(a_Matrix, a_Normalise); } else {
GaussJordanReduced(a_Matrix);
}
} else {
if (a_Normalise) {
GaussJordanTriangularNorma(a_Matrix);
} else {
GaussJordanTriangular(a_Matrix);
}
}
} }
} // namespace Gauss } // namespace Gauss

View File

@@ -31,18 +31,6 @@ std::istream& operator>>(std::istream& stream, Matrix& mat) {
return stream; return stream;
} }
std::ostream& operator<<(std::ostream& stream, const BigInt& nbre) {
stream << nbre.ToString();
return stream;
}
std::istream& operator>>(std::istream& stream, BigInt& nbre) {
long value;
stream >> value;
nbre = BigInt(value);
return stream;
}
Matrix LoadMatrix(const std::string& fileName) { Matrix LoadMatrix(const std::string& fileName) {
std::ifstream in {fileName}; std::ifstream in {fileName};
if (!in) { if (!in) {

View File

@@ -71,11 +71,7 @@ Matrix Matrix::RawVector(std::initializer_list<Element>&& a_Elements) {
} }
void Matrix::Fill(Element a_Element) { void Matrix::Fill(Element a_Element) {
for (std::size_t i = 0; i < m_Raws; i++) { std::fill(GetLineIterator(0), GetLineIterator(m_Raws), a_Element);
for (std::size_t j = 0; j < m_Columns; j++) {
at(i, j) = a_Element;
}
}
} }
void Matrix::Augment(const Matrix& a_Right) { void Matrix::Augment(const Matrix& a_Right) {
@@ -158,10 +154,12 @@ bool Matrix::operator==(const Matrix& a_Other) const {
} }
Matrix::Element& Matrix::at(std::size_t a_Raw, std::size_t a_Column) { Matrix::Element& Matrix::at(std::size_t a_Raw, std::size_t a_Column) {
assert(a_Raw < m_Raws && a_Column < m_Columns);
return m_Data[a_Raw * m_Columns + a_Column]; return m_Data[a_Raw * m_Columns + a_Column];
} }
Matrix::Element Matrix::at(std::size_t a_Raw, std::size_t a_Column) const { Matrix::Element Matrix::at(std::size_t a_Raw, std::size_t a_Column) const {
assert(a_Raw < m_Raws && a_Column < m_Columns);
return m_Data[a_Raw * m_Columns + a_Column]; return m_Data[a_Raw * m_Columns + a_Column];
} }

View File

@@ -3,7 +3,7 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
int PGCD(int x, int y) { NR::Int PGCD(NR::Int x, NR::Int y) {
if (x == 0 || y == 0) if (x == 0 || y == 0)
return 1; return 1;
else if (x % y == 0) else if (x % y == 0)
@@ -14,18 +14,18 @@ int PGCD(int x, int y) {
NR::NR() : m_Numerator(0), m_Denominator(1) {} NR::NR() : m_Numerator(0), m_Denominator(1) {}
NR::NR(int entier) : m_Numerator(entier), m_Denominator(1) {} NR::NR(NR::Int entier) : m_Numerator(entier), m_Denominator(1) {}
NR::NR(int numerator, int denominator) : NR::NR(NR::Int numerator, NR::Int denominator) :
m_Numerator((denominator > 0) ? numerator : -numerator), m_Denominator(std::abs(denominator)) { m_Numerator((denominator > 0) ? numerator : -numerator), m_Denominator(std::abs(denominator)) {
assert(denominator != 0);
Reduce(); Reduce();
} }
void NR::Reduce() { void NR::Reduce() {
int divisor = PGCD(m_Denominator, m_Numerator); NR::Int divisor = PGCD(m_Denominator, m_Numerator);
m_Denominator /= divisor; m_Denominator /= divisor;
m_Numerator /= divisor; m_Numerator /= divisor;
assert(m_Denominator != 0);
} }
NR NR::Inverse() const { NR NR::Inverse() const {
@@ -33,11 +33,11 @@ NR NR::Inverse() const {
return {m_Denominator, m_Numerator}; return {m_Denominator, m_Numerator};
} }
int NR::GetNumerator() const { NR::Int NR::GetNumerator() const {
return m_Numerator; return m_Numerator;
} }
int NR::GetDenominator() const { NR::Int NR::GetDenominator() const {
return m_Denominator; return m_Denominator;
} }
@@ -66,48 +66,57 @@ bool NR::operator>=(const NR& opNR) const {
} }
std::ostream& operator<<(std::ostream& os, const NR& opNR) { std::ostream& operator<<(std::ostream& os, const NR& opNR) {
os << opNR.GetNumerator() << "/" << opNR.GetDenominator(); os << opNR.GetNumerator();
if (opNR.GetDenominator() != 1)
os << "/" << opNR.GetDenominator();
return os; return os;
} }
std::istream& operator>>(std::istream& is, NR& opNR) { std::istream& operator>>(std::istream& is, NR& opNR) {
char slash; char slash;
is >> opNR.m_Numerator >> slash >> opNR.m_Denominator; is >> opNR.m_Numerator >> slash;
if (slash != '/') {
// on revient un charactère en arrière
is.seekg(is.tellg() - static_cast<std::streampos>(1));
opNR.m_Denominator = 1;
} else {
is >> opNR.m_Denominator;
}
opNR.Reduce(); opNR.Reduce();
return is; return is;
} }
NR NR::operator+(const NR& opNR) const { NR NR::operator+(const NR& opNR) const {
int num, den; Int num, den;
num = m_Numerator * opNR.GetDenominator(); num = m_Numerator * opNR.GetDenominator();
den = m_Denominator * opNR.GetDenominator(); den = m_Denominator * opNR.GetDenominator();
num += (opNR.GetNumerator() * m_Denominator); num += (opNR.GetNumerator() * m_Denominator);
NR result(num, den); NR result(num, num == 0 ? 1 : den);
return result; return result;
} }
NR NR::operator-(const NR& opNR) const { NR NR::operator-(const NR& opNR) const {
int num, den; Int num, den;
num = m_Numerator * opNR.GetDenominator(); num = m_Numerator * opNR.GetDenominator();
den = m_Denominator * opNR.GetDenominator(); den = m_Denominator * opNR.GetDenominator();
num -= (opNR.GetNumerator() * m_Denominator); num -= (opNR.GetNumerator() * m_Denominator);
NR result(num, den); NR result(num, num == 0 ? 1 : den);
return result; return result;
} }
NR NR::operator*(const NR& opNR) const { NR NR::operator*(const NR& opNR) const {
int num, den; Int num, den;
num = m_Numerator * opNR.GetNumerator(); num = m_Numerator * opNR.GetNumerator();
den = m_Denominator * opNR.GetDenominator(); den = m_Denominator * opNR.GetDenominator();
NR result(num, den); NR result(num, num == 0 ? 1 : den);
return result; return result;
} }
NR NR::operator/(const NR& opNR) const { NR NR::operator/(const NR& opNR) const {
int num, den; Int num, den;
num = m_Numerator * opNR.GetDenominator(); num = m_Numerator * opNR.GetDenominator();
den = m_Denominator * opNR.GetNumerator(); den = m_Denominator * opNR.GetNumerator();
NR result(num, den); NR result(num, num == 0 ? 1 : den);
return result; return result;
} }

View File

@@ -25,7 +25,7 @@ Vect Solver::Kernel(Matrix&& a_Matrix) const {
a_Matrix.Transpose(); a_Matrix.Transpose();
a_Matrix.Augment(Matrix::Identity(a_Matrix.GetRawCount())); a_Matrix.Augment(Matrix::Identity(a_Matrix.GetRawCount()));
Gauss::GaussJordan(a_Matrix, false, false); Gauss::GaussJordan(a_Matrix, false, true);
a_Matrix.Transpose(); a_Matrix.Transpose();
// nombre de colonnes non nulles // nombre de colonnes non nulles
@@ -45,14 +45,21 @@ VectAffine Solver::RectangularSystem(Matrix&& a_MatrixA, const Matrix& a_VectorB
Vect noyau = solver.Kernel(std::move(a_MatrixA)); Vect noyau = solver.Kernel(std::move(a_MatrixA));
Matrix origin = mat.SubMatrix(0, mat.GetColumnCount() - 1, mat.GetRawCount(), 1); Matrix origin = mat.SubMatrix(0, mat.GetColumnCount() - 1, mat.GetRawCount(), 1);
// on rajoute des 0 si il faut // on calcule le vecteur qui dirige l'espace affine
Matrix fullOrigin {mat.GetColumnCount() - 1, 1}; Matrix fullOrigin {mat.GetColumnCount() - 1, 1};
for (std::size_t i = 0; i < mat.GetRawCount(); i++) { for (std::size_t i = 0; i < mat.GetRawCount(); i++) {
int pivot_index = FirstNotNullElementIndexOnLine(mat, i); int pivot_index = FirstNotNullElementIndexOnLine(mat, i);
if(pivot_index >= 0){
fullOrigin.at(pivot_index, 0) = origin.at(i, 0); if (static_cast<std::size_t>(pivot_index) == mat.GetColumnCount() - 1) {
// on a une ligne du type 0 = n. Aucune solution !
return {Matrix {}, Matrix::ColumnVector({0})};
} }
// ligne entière de 0
if (pivot_index < 0)
continue;
fullOrigin.at(pivot_index, 0) = origin.at(i, 0);
} }
return {noyau, fullOrigin}; return {noyau, fullOrigin};

View File

@@ -14,7 +14,7 @@ static bool IsColumnNull(Matrix& mat, std::size_t column) {
Vect::Vect(Matrix&& a_Matrix) : m_Data(std::move(a_Matrix)) { Vect::Vect(Matrix&& a_Matrix) : m_Data(std::move(a_Matrix)) {
m_Data.Transpose(); m_Data.Transpose();
Gauss::GaussJordan(m_Data, false, false); Gauss::GaussJordan(m_Data, false, true);
m_Data.Transpose(); m_Data.Transpose();
Simplify(); Simplify();
} }

View File

@@ -3,6 +3,7 @@
#include "Matrix.h" #include "Matrix.h"
#include "Solver.h" #include "Solver.h"
#include <imgui.h> #include <imgui.h>
#include <sstream>
static std::string equationsResultImage; static std::string equationsResultImage;
@@ -16,6 +17,12 @@ static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) {
return result; return result;
} }
static std::string ElementToString(Matrix::Element e) {
std::stringstream ss;
ss << e;
return ss.str();
}
static std::string PrintVect(const Vect& vect) { static std::string PrintVect(const Vect& vect) {
if (vect.GetCardinal() == 0) if (vect.GetCardinal() == 0)
return "{0}"; return "{0}";
@@ -25,11 +32,13 @@ static std::string PrintVect(const Vect& vect) {
Matrix vector = vect.GetVector(i); Matrix vector = vect.GetVector(i);
result += " ("; result += " (";
for (std::size_t j = 0; j < vect.GetDimension(); j++) { for (std::size_t j = 0; j < vect.GetDimension(); j++) {
result += std::to_string(static_cast<int>(vector.at(j, 0))) + ", "; result += ElementToString(vector.at(j, 0)) + ", ";
} }
result = result.substr(0, result.size() - 2);
result += " ), "; result += " ), ";
} }
result += " )"; result = result.substr(0, result.size() - 2);
result += " )";
return result; return result;
} }
@@ -43,6 +52,8 @@ void PivotGui::Render() {
static int matrixSizeY = 4; static int matrixSizeY = 4;
static Solver solver; static Solver solver;
static bool refresh = true;
// divisions des fenetres // divisions des fenetres
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f); ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f); ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
@@ -59,13 +70,15 @@ void PivotGui::Render() {
ImGui::Text("Matrice initiale:"); ImGui::Text("Matrice initiale:");
ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY); if (ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY))
refresh = true;
matrixSizeY = std::max(1, matrixSizeY); matrixSizeY = std::max(1, matrixSizeY);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Lignes"); ImGui::Text("Lignes");
ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX); if (ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX))
refresh = true;
matrixSizeX = std::max(1, matrixSizeX); matrixSizeX = std::max(1, matrixSizeX);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Colonnes"); ImGui::Text("Colonnes");
@@ -76,13 +89,13 @@ void PivotGui::Render() {
// Resize matrixValues and initialize new elements to 0 // Resize matrixValues and initialize new elements to 0
matrixValues.resize(matrixSizeY); if (refresh) {
for (auto& row : matrixValues) { matrixValues.resize(matrixSizeY);
row.resize(matrixSizeX, 0); for (auto& row : matrixValues) {
row.resize(matrixSizeX, 0);
}
} }
bool refresh = false;
for (int y = 0; y < matrixSizeY; y++) { for (int y = 0; y < matrixSizeY; y++) {
for (int x = 0; x < matrixSizeX; x++) { for (int x = 0; x < matrixSizeX; x++) {
if (x > 0) if (x > 0)
@@ -136,7 +149,7 @@ void PivotGui::Render() {
for (size_t i = 0; i < linearSystem.GetRawCount(); ++i) { for (size_t i = 0; i < linearSystem.GetRawCount(); ++i) {
for (size_t j = 0; j < linearSystem.GetColumnCount(); ++j) { for (size_t j = 0; j < linearSystem.GetColumnCount(); ++j) {
equationsResultImage += equationsResultImage +=
std::to_string(static_cast<int>(linearSystem.at(i, j))) + "*" + std::string {static_cast<char>('a' + j)} + " + "; ElementToString(linearSystem.at(i, j)) + "*" + std::string {static_cast<char>('a' + j)} + " + ";
} }
equationsResultImage = equationsResultImage.substr(0, equationsResultImage.size() - 3) + " = 0\n"; equationsResultImage = equationsResultImage.substr(0, equationsResultImage.size() - 3) + " = 0\n";
} }
@@ -146,6 +159,7 @@ void PivotGui::Render() {
PrintVect(image); PrintVect(image);
} }
refresh = false;
ImGui::End(); // End fenetre bas ImGui::End(); // End fenetre bas
} }

View File

@@ -6,6 +6,7 @@
*/ */
#include <iostream> #include <iostream>
#include <stdexcept>
/** /**
* \def TEST_SUCCESSFUL * \def TEST_SUCCESSFUL
@@ -37,6 +38,5 @@
if (!static_cast<bool>(__VA_ARGS__)) { \ if (!static_cast<bool>(__VA_ARGS__)) { \
std::cout << __FILE__ << ":" << __LINE__ << ": " << __FUNCTION_NAME__ << ": Assertion failed !\n"; \ std::cout << __FILE__ << ":" << __LINE__ << ": " << __FUNCTION_NAME__ << ": Assertion failed !\n"; \
std::cout << " " << __LINE__ << " |\t" << #__VA_ARGS__ << std::endl; \ std::cout << " " << __LINE__ << " |\t" << #__VA_ARGS__ << std::endl; \
std::exit(TEST_FAILED); \ throw std::runtime_error("Assertion failed !"); \
} }

View File

@@ -2,6 +2,12 @@
#include "Matrix.h" #include "Matrix.h"
#include "test_assert.h" #include "test_assert.h"
#include <chrono>
#include <iostream>
static constexpr int MATRIX_MAX_SIZE = 300;
static constexpr int EXECUTION_COUNT = 1;
struct Test { struct Test {
Matrix mat; Matrix mat;
Matrix res; Matrix res;
@@ -30,6 +36,22 @@ static const std::vector<Test> TEST_MATRICES = {
}}} }}}
}; };
static unsigned int GetRandomInt() {
return rand() % MATRIX_MAX_SIZE + 1;
}
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
Matrix matrix {a_Raw, a_Column};
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
matrix.at(i, j) = GetRandomInt();
}
}
return matrix;
}
void test() { void test() {
for (Test test : TEST_MATRICES) { for (Test test : TEST_MATRICES) {
Gauss::GaussJordan(test.mat, true, true); Gauss::GaussJordan(test.mat, true, true);
@@ -37,7 +59,26 @@ void test() {
} }
} }
void gaussTest() {
auto start = std::chrono::system_clock::now();
for (int i = 0; i < EXECUTION_COUNT; i++) {
Matrix mat = GetRandomMatrix(500, 500);
Gauss::GaussJordan(mat, false, false);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "\tgauss jordan elapsed time : " << elapsed_seconds.count() << "s" << std::endl;
}
void speedTest() {
gaussTest();
// gaussColumnTest();
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
test(); test();
speedTest();
return 0; return 0;
} }

109
test/test_plot.cpp Normal file
View File

@@ -0,0 +1,109 @@
#include <algorithm>
#include <chrono>
#include <cmath>
#include <execution>
#include <future>
#include <matplot/matplot.h>
#include "Gauss.h"
#include "Matrix.h"
#include "Solver.h"
static constexpr int EXECUTION_COUNT = 100;
static constexpr int MATRIX_MAX_SIZE = 300;
static unsigned int GetRandomInt() {
return rand() % MATRIX_MAX_SIZE + 1;
}
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
Matrix matrix {a_Raw, a_Column};
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) {
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
matrix.at(i, j) = GetRandomInt();
}
}
return matrix;
}
std::vector<double> GaussJordan(const std::vector<double>& x) {
std::vector<double> y;
std::for_each(x.begin(), x.end(), [&y](double size) {
auto start = std::chrono::system_clock::now();
for (int j = 0; j < EXECUTION_COUNT; j++) {
Matrix mat = GetRandomMatrix(size, size);
Gauss::GaussJordan(mat, false, false);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "S " << size << "\n";
y.push_back(elapsed_seconds.count() / static_cast<double>(EXECUTION_COUNT));
});
return y;
}
std::vector<double> GaussJordanReduite(const std::vector<double>& x) {
std::vector<double> y;
std::for_each(x.begin(), x.end(), [&y](double size) {
auto start = std::chrono::system_clock::now();
for (int j = 0; j < EXECUTION_COUNT; j++) {
Matrix mat = GetRandomMatrix(size, size);
Gauss::GaussJordan(mat, true, false);
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "R " << size << "\n";
y.push_back(elapsed_seconds.count() / static_cast<double>(EXECUTION_COUNT));
});
return y;
}
int main() {
srand(time(0));
int start = 1;
std::vector<double> x = matplot::linspace(start, MATRIX_MAX_SIZE, MATRIX_MAX_SIZE - start + 1);
//std::vector<double> x = {5000};
std::vector<double> y, y1, y2, y3;
// y2.resize(x.size());
{
auto result1 = std::async(std::launch::async, &GaussJordan, x);
auto result2 = std::async(std::launch::async, &GaussJordanReduite, x);
y = result1.get();
y1 = result2.get();
}
std::cout << "Fini !\n";
// std::transform(x.begin(), x.end(), y2.begin(), [](double x) { return 1.0 / (100.0 * 100.0) * 0.6 * x * x; });
matplot::title("Echelonnage de matrices");
matplot::xlabel("Taille des matrices");
matplot::ylabel("Temps d'exécution (s)");
matplot::hold(matplot::on);
matplot::plot(x, y);
matplot::plot(x, y1);
auto l = matplot::legend({"Echelonnage non réduit", "Echelonnage réduit", "Echelonnage non réduit normalisé", "Echelonnage réduit normalisé"});
l->location(matplot::legend::general_alignment::topleft);
matplot::show();
return 0;
}

View File

@@ -6,13 +6,23 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
static constexpr int EXECUTION_COUNT = 10; static constexpr int EXECUTION_COUNT = 1000;
static constexpr int KERNEL_CHECKS = 100; static constexpr int KERNEL_CHECKS = 100;
static constexpr int MATRIX_MAX_SIZE = 10; static constexpr int MATRIX_MAX_SIZE = 9;
static const Solver solver; static const Solver solver;
static unsigned int GetRandomInt() { static int GetRandomInt() {
return rand() % 11 - 5;
}
#define print_time(i) \
end = std::chrono::system_clock::now(); \
elapsed_seconds = end - start; \
std::cout << "elapsed time " << i << " : " << elapsed_seconds.count() << "s" << std::endl; \
start = std::chrono::system_clock::now()
static unsigned int GetRandomSize() {
return rand() % MATRIX_MAX_SIZE + 1; return rand() % MATRIX_MAX_SIZE + 1;
} }
@@ -28,46 +38,76 @@ static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
return matrix; return matrix;
} }
static void Test() { static bool Test() {
Matrix matrix = GetRandomMatrix(GetRandomInt(), GetRandomInt()); auto start = std::chrono::system_clock::now();
auto begin = start;
auto end = start;
std::chrono::duration<double> elapsed_seconds = end - start;
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) { std::cout << "Begin\n";
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) {
matrix.at(i, j) = GetRandomInt(); Matrix matrix = GetRandomMatrix(GetRandomSize(), GetRandomSize());
}
} print_time(1);
Matrix copy = matrix; Matrix copy = matrix;
Vect kernel = solver.Kernel(std::move(copy)); Vect kernel = solver.Kernel(std::move(copy));
print_time(2);
Matrix nullVector {matrix.GetRawCount(), 1}; Matrix nullVector {matrix.GetRawCount(), 1};
nullVector.Fill(0.0); nullVector.Fill(0.0);
for (std::size_t i = 0; i < kernel.GetCardinal(); i++) { for (std::size_t i = 0; i < kernel.GetCardinal(); i++) {
test_assert(matrix * kernel.GetVector(i) == nullVector); Matrix result = matrix * kernel.GetVector(i);
if(!(result == nullVector)) {
test_assert(false);
}
} }
print_time(3);
for (std::size_t i = 0; i < KERNEL_CHECKS; i++) { for (std::size_t i = 0; i < KERNEL_CHECKS; i++) {
Matrix vector = GetRandomMatrix(kernel.GetDimension(), 1); Matrix vector = GetRandomMatrix(kernel.GetDimension(), 1);
test_assert(kernel.IsElementOf(vector) == (matrix * vector == nullVector)); test_assert(kernel.IsElementOf(vector) == (matrix * vector == nullVector));
} }
Vect kernel2 = solver.Kernel(kernel.GetLinearSystem()); print_time(4);
Matrix linearSystem = kernel.GetLinearSystem();
print_time(5);
Vect kernel2 = solver.Kernel(std::move(linearSystem));
test_assert(kernel == kernel2); test_assert(kernel == kernel2);
print_time(6);
elapsed_seconds = end - begin;
std::cout << "final elapsed time: " << elapsed_seconds.count() << "s" << std::endl;
std::cout << "End\n";
return true;
} }
int main() { int main() {
srand(time(0)); srand(time(0));
std::vector<std::future<void>> results; std::vector<std::future<bool>> results;
// appelle la fonction Test() en parallèle // appelle la fonction Test() en parallèle
for (int i = 0; i < EXECUTION_COUNT; i++) { for (int i = 0; i < EXECUTION_COUNT; i++) {
auto handle = std::async(std::launch::async, &Test); auto handle = std::async(std::launch::async, &Test);
results.push_back(std::move(handle)); results.push_back(std::move(handle));
// Test();
}
for (auto& result : results) {
if (!result.get())
return EXIT_FAILURE;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@@ -8,21 +9,23 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
const static int EXECUTION_COUNT = 100; const static int EXECUTION_COUNT = 10000;
static constexpr int MATRIX_MAX_SIZE = 5; static constexpr int MATRIX_MAX_SIZE = 7;
static unsigned int GetRandomInt() { static int GetRandomSize() {
return rand() % MATRIX_MAX_SIZE + 1; return rand() % MATRIX_MAX_SIZE + 1;
} }
static int GetRandomInt() {
return GetRandomSize();
}
static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) { static Matrix GetRandomMatrix(std::size_t a_Raw, std::size_t a_Column) {
Matrix matrix {a_Raw, a_Column}; Matrix matrix {a_Raw, a_Column};
for (std::size_t i = 0; i < matrix.GetRawCount(); i++) { std::generate(matrix.GetLineIterator(0), matrix.GetLineIterator(a_Raw), []() {
for (std::size_t j = 0; j < matrix.GetColumnCount(); j++) { return GetRandomInt();
matrix.at(i, j) = GetRandomInt(); });
}
}
return matrix; return matrix;
} }
@@ -34,25 +37,18 @@ void TestRectangular(const Matrix& system, const Matrix& origin) {
for (std::size_t i = 0; i < solution.GetBase().GetCardinal(); i++) { for (std::size_t i = 0; i < solution.GetBase().GetCardinal(); i++) {
Matrix vector = solution.GetBase().GetVector(i) + solution.GetOrigin(); Matrix vector = solution.GetBase().GetVector(i) + solution.GetOrigin();
for (std::size_t j = 0; j < system.GetRawCount(); j++) { Matrix product = system * vector;
Matrix line = system.SubMatrix(j, 0, 1, system.GetColumnCount()); test_assert(product == origin);
test_assert(line * vector == origin.SubMatrix(j, 0, 1, 1));
}
} }
} }
void RandomRectangular() { void RandomRectangular() {
for (int i = 0; i < EXECUTION_COUNT; i++) { for (int i = 0; i < EXECUTION_COUNT; i++) {
Matrix system = GetRandomMatrix(GetRandomInt(), GetRandomInt()); Matrix system = GetRandomMatrix(GetRandomSize(), GetRandomSize());
if (system.GetColumnCount() == system.GetRawCount())
continue;
Matrix origin = GetRandomMatrix(system.GetRawCount(), 1); Matrix origin = GetRandomMatrix(system.GetRawCount(), 1);
std::cout << "PIPI\n";
TestRectangular(system, origin); TestRectangular(system, origin);
} }
} }
@@ -85,6 +81,7 @@ void TestKernelImage() {
} }
int main() { int main() {
srand(time(0));
TestKernelImage(); TestKernelImage();
RandomRectangular(); RandomRectangular();
return 0; return 0;

View File

@@ -2,17 +2,19 @@ add_rules("mode.debug", "mode.release")
add_requires("libsdl 2.28.3", {configs = {sdlmain = false}}) add_requires("libsdl 2.28.3", {configs = {sdlmain = false}})
add_requires("imgui", {configs = {sdl2_no_renderer = true, opengl3 = true}}) add_requires("imgui", {configs = {sdl2_no_renderer = true, opengl3 = true}})
add_requires("gmp");
set_languages("c++20") set_languages("c++20")
set_warnings("all") set_warnings("all")
add_includedirs("include") add_includedirs("include")
add_packages("gmp")
add_requires("matplotplusplus")
-- Solver Library -- Solver Library
target("Pivot") target("Pivot")
set_kind("static") set_kind("static")
add_files("src/*.cpp") add_files("src/*.cpp")
add_cxxflags("-ffast-math")
set_optimize("fastest")
remove_files("src/main.cpp") remove_files("src/main.cpp")
@@ -51,6 +53,7 @@ for _, file in ipairs(os.files("test/test_*.cpp")) do
set_default(false) set_default(false)
add_deps("Pivot") add_deps("Pivot")
add_packages("matplotplusplus")
add_tests("compile_and_run") add_tests("compile_and_run")
end end