implement Vect
This commit is contained in:
26
src/Vect.cpp
26
src/Vect.cpp
@@ -1,20 +1,32 @@
|
|||||||
#include "Vect.h"
|
#include "Vect.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
Vect::Vect(const Matrix& mat) {
|
Vect::Vect(const Matrix& mat) : m_Data(mat) {
|
||||||
for (std::size_t i = 0; i < mat.GetColumnCount(); i++) {
|
Simplify();
|
||||||
std::size_t j;
|
}
|
||||||
for (j = 0; j < mat.GetRawCount(); j++) {
|
|
||||||
|
void Vect::Simplify() {
|
||||||
|
Matrix mat = m_Data;
|
||||||
|
for (std::size_t j = 0; j < mat.GetColumnCount(); j++) {
|
||||||
|
std::size_t i;
|
||||||
|
for (i = 0; i < mat.GetRawCount(); i++) {
|
||||||
if (!IsEqualZero(mat.at(i, j)))
|
if (!IsEqualZero(mat.at(i, j)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j == mat.GetRawCount()) {
|
if (i == mat.GetRawCount()) {
|
||||||
m_Data = mat.SubMatrix(0, 0, mat.GetRawCount(), j);
|
m_Data = mat.SubMatrix(0, 0, mat.GetRawCount(), j);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Data = mat;
|
m_Data = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
void Vect::Print() const {
|
void Vect::Print() const {
|
||||||
|
std::cout << "Espace vectoriel de dimension " << m_Data.GetColumnCount() << " de base :\n\n";
|
||||||
|
for (std::size_t i = 0; i < m_Data.GetRawCount(); i++) {
|
||||||
|
for (std::size_t j = 0; j < m_Data.GetColumnCount(); j++) {
|
||||||
|
printf("[ %.3f ]\t", static_cast<float>(m_Data.at(i, j)));
|
||||||
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
// espace vectoriel
|
// espace vectoriel
|
||||||
class Vect {
|
class Vect {
|
||||||
private:
|
private:
|
||||||
Matrix m_Data{0, 0};
|
Matrix m_Data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -19,4 +19,7 @@ class Vect {
|
|||||||
* \brief Affiche la base de l'espace vectoriel dans la console
|
* \brief Affiche la base de l'espace vectoriel dans la console
|
||||||
*/
|
*/
|
||||||
void Print() const;
|
void Print() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Simplify();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user