Last active
February 28, 2018 15:16
-
-
Save facontidavide/75267468b8a0327efd028fcb2a559297 to your computer and use it in GitHub Desktop.
Used for a programming exercise...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
template <typename T> | |
class Vector | |
{ | |
public: | |
Vector(size_t order); // constructor for squared-matrix | |
Vector(const Vector& other); // copy constructor | |
~Vector(); //destructor | |
Vector& operator=(const Vector& other); // copy operator | |
size_t size() const; | |
//mutable reference to matrux element | |
T& operator()(size_t index); | |
//unmutable reference to matrux element | |
const T& operator()(size_t index) const; | |
}; | |
// some methods might throw exception | |
template <typename T> | |
class Matrix // Note: store data in a single dynamic allocated vector, column-wise | |
{ | |
public: | |
Matrix(size_t order); // constructor for squared-matrix | |
Matrix(size_t rows, size_t columns); // constructor for rectangular matrix | |
Matrix(const Matrix& other); // copy constructor | |
~Matrix(); //destructor | |
Matrix& operator=(const Matrix& other); // copy operator | |
size_t numRows() const; | |
size_t numCols() const; | |
Matrix getTranspose() const; | |
Matrix getInverted() const; | |
Matrix getMinor() const; | |
Vector<T> getRow(size_t row_index); | |
Vector<T> getColumn(size_t column_index); | |
T calculateDeterminant() const; | |
//mutable reference to matrux element | |
T& operator()(size_t row, size_t col); | |
//unmutable reference to matrux element | |
const T& operator()(size_t row, size_t col) const; | |
// calculate multiplication R = (*this) * other | |
Matrix operator* (const Matrix& other) const; | |
// matrix vector multiplication | |
Vector<T> operator* (const Vector<T>& other) const; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment