This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Pivot/src/Matrix.h
2024-02-29 14:48:36 +01:00

45 lines
1.0 KiB
C++

#pragma once
#include <cmath>
#include <cstddef>
#include <string>
#include <vector>
class Matrix {
public:
typedef long double Element;
private:
std::size_t m_Raws;
std::size_t m_Columns;
std::vector<Element> m_Data;
public:
Matrix() : m_Raws(0), m_Columns(0) {}
Matrix(std::size_t raws, std::size_t columns);
Matrix(std::size_t raws, std::size_t columns, std::initializer_list<Element>&& initList);
~Matrix();
std::size_t GetRawCount() const;
std::size_t GetColumnCount() const;
void Transpose();
static Matrix Identity(std::size_t size);
void Augment(const Matrix& right);
Matrix SubMatrix(std::size_t raw_origin, std::size_t column_origin, std::size_t raw, std::size_t column) const;
bool operator==(const Matrix& other) const;
Matrix operator*(const Matrix& other) const;
Element& operator[](std::size_t index);
Element& at(std::size_t raw, std::size_t column);
Element at(std::size_t raw, std::size_t column) const;
};
template <typename T>
bool IsEqualZero(T var) {
return std::abs(var) < std::pow(10, -5);
}