SpatiumLib
Public Member Functions | Friends | List of all members
spatium::Vector Class Reference

Vector in column-major order. More...

#include <Vector.h>

Inheritance diagram for spatium::Vector:
Inheritance graph
[legend]
Collaboration diagram for spatium::Vector:
Collaboration graph
[legend]

Public Member Functions

 Vector (size_t rows)
 Constructor. More...
 
 Vector (std::initializer_list< double > array)
 Constructor. More...
 
 Vector (const std::vector< double > &vector)
 Constructor. More...
 
 Vector (const Vector &other)
 Copy constructor. More...
 
 Vector (const Matrix &other)
 Copy constructor. More...
 
Vectoroperator= (const Vector &other)=default
 Assignment operator. More...
 
 ~Vector ()=default
 Destructor. More...
 
double operator() (size_t row) const
 Access element by value. More...
 
double & operator() (size_t row)
 Access element by reference. More...
 
Vector operator+ (const Matrix &other) const
 Add matrix to vector. More...
 
Vector operator- (const Matrix &other) const
 Subtract matrix from vector. More...
 
Vector operator * (double scalar) const
 Multiply by scalar. More...
 
Vector operator/ (double scalar) const
 Divide by scalar. More...
 
void resize (size_t rows)
 Resize. More...
 
- Public Member Functions inherited from spatium::Matrix
 Matrix (size_t rows, size_t cols)
 Constructor. More...
 
 Matrix (std::initializer_list< std::initializer_list< double >> array)
 Constructor. More...
 
bool operator== (const Matrix &other) const
 Compare operator. Is equal. More...
 
bool operator!= (const Matrix &other) const
 Compare operator. Is unequal. More...
 
size_t rows () const
 Get the number of rows. More...
 
size_t cols () const
 Get the number of columns. More...
 
std::vector< double > data () const
 Get all matrix elements. More...
 
void clear ()
 Clear all matrix elements. More...
 
Matrix transposed () const
 Get transposed matrix. More...
 
double determinant () const
 Calculate determinant. More...
 
double minor (size_t row, size_t col) const
 Calulcate minor. More...
 
Matrix omit (size_t row, size_t col) const
 Omit a given row and column. More...
 
Matrix inverse () const
 Calculate inverse of matrix. More...
 
double operator() (size_t row, size_t col) const
 Access element by value. More...
 
double & operator() (size_t row, size_t col)
 Access element by reference. More...
 
Matrix operator+ (const Matrix &other) const
 Add by matrix. More...
 
Matrix operator- (const Matrix &other) const
 Subtract by matrix. More...
 
Matrix operator * (const Matrix &other) const
 Multiply by matrix. More...
 
Matrix operator * (double scalar) const
 Multiply by scalar. More...
 
Matrix operator/ (double scalar) const
 Divide by scalar. More...
 
void resize (size_t rows, size_t cols)
 Resize. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Vector &vector)
 Output to ostream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from spatium::Matrix
static Matrix identity (size_t order)
 Construct identity matrix. More...
 
- Protected Member Functions inherited from spatium::Matrix
double determinant (const Matrix &matrix) const
 Calculate determinant. More...
 
- Protected Attributes inherited from spatium::Matrix
size_t m_rows
 
size_t m_cols
 
std::vector< double > m_data
 

Detailed Description

Vector in column-major order.

Constructor & Destructor Documentation

◆ Vector() [1/5]

spatium::Vector::Vector ( size_t  rows)
inline

Constructor.

Parameters
[in]rowsNumber of rows

◆ Vector() [2/5]

spatium::Vector::Vector ( std::initializer_list< double >  array)
inline

Constructor.

Parameters
[in]arrayInitializer list

◆ Vector() [3/5]

spatium::Vector::Vector ( const std::vector< double > &  vector)
inline

Constructor.

Parameters
[in]vectorSTD vector

◆ Vector() [4/5]

spatium::Vector::Vector ( const Vector other)
inline

Copy constructor.

Parameters
[in]otherOther vector

◆ Vector() [5/5]

spatium::Vector::Vector ( const Matrix other)
inline

Copy constructor.

Parameters
[in]otherOther matrix
Exceptions
std::out_of_rangeMatrix dimensions out of range

◆ ~Vector()

spatium::Vector::~Vector ( )
default

Destructor.

Member Function Documentation

◆ operator *()

Vector spatium::Vector::operator * ( double  scalar) const
inline

Multiply by scalar.

Parameters
[in]scalarScalar
Returns
Multiplied vector
Todo:
Use Matrix function and cast or make virtual?

◆ operator()() [1/2]

double spatium::Vector::operator() ( size_t  row) const
inline

Access element by value.

Parameters
[in]rowRow of element
Exceptions
std::out_of_rangeMatrix element out of range
Returns
Element value

◆ operator()() [2/2]

double& spatium::Vector::operator() ( size_t  row)
inline

Access element by reference.

Parameters
[in]rowRow of element
[in]colColumn of element
Exceptions
std::out_of_rangeMatrix element out of range
Returns
Element reference

◆ operator+()

Vector spatium::Vector::operator+ ( const Matrix other) const
inline

Add matrix to vector.

Parameters
[in]otherMatrix to add
Exceptions
std::out_of_rangeMatrix dimensions out of range
Returns
Added vector
Todo:
Use Matrix function and cast or make virtual? return Matrix::operator+(other);

◆ operator-()

Vector spatium::Vector::operator- ( const Matrix other) const
inline

Subtract matrix from vector.

Parameters
[in]otherMatrix to subtract
Exceptions
std::out_of_rangeMatrix dimensions out of range
Returns
Subtracted vector
Todo:
Use Matrix function and cast or make virtual?

◆ operator/()

Vector spatium::Vector::operator/ ( double  scalar) const
inline

Divide by scalar.

Parameters
[in]scalarScalar
Returns
Divided vector
Todo:
Use Matrix function and cast?

◆ operator=()

Vector& spatium::Vector::operator= ( const Vector other)
default

Assignment operator.

◆ resize()

void spatium::Vector::resize ( size_t  rows)
inline

Resize.

This will set all values to 0.

Parameters
[in]rowsNumber of rows

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Vector vector 
)
friend

Output to ostream.


The documentation for this class was generated from the following file: