File matrix.hpp

Core API objects - matrix.

Typedefs

template<typename ScalarT = double, int RowsT = Dynamic>
using Vector = Matrix<ScalarT, RowsT, 1>
using DynamicMatrix = Matrix<double, Dynamic, Dynamic>
using DynamicVector = Vector<double, Dynamic>

Functions

template<int Rows, int Cols>
static void checkSize(const int rows, const int cols)
template<typename ScalarT, int LhsRows, int LhsCols, int RhsRows, int RhsCols>
bool operator==(const Matrix<ScalarT, LhsRows, LhsCols> &lhs, const Matrix<ScalarT, RhsRows, RhsCols> &rhs)
template<typename ScalarT, int LhsRows, int LhsCols, int RhsRows, int RhsCols>
bool operator!=(const Matrix<ScalarT, LhsRows, LhsCols> &lhs, const Matrix<ScalarT, RhsRows, RhsCols> &rhs)

Variables

constexpr int Dynamic = -1
namespace slamcore

Helper conversion methods

slamcore::ImageFormat \(\leftrightarrow\) BytesPerChannel

Get information about the client library

Typedefs

template<typename ScalarT = double, int RowsT = Dynamic>
using Vector = Matrix<ScalarT, RowsT, 1>
using DynamicMatrix = Matrix<double, Dynamic, Dynamic>
using DynamicVector = Vector<double, Dynamic>

Functions

template<typename ScalarT, int LhsRows, int LhsCols, int RhsRows, int RhsCols>
bool operator==(const Matrix<ScalarT, LhsRows, LhsCols> &lhs, const Matrix<ScalarT, RhsRows, RhsCols> &rhs)
template<typename ScalarT, int LhsRows, int LhsCols, int RhsRows, int RhsCols>
bool operator!=(const Matrix<ScalarT, LhsRows, LhsCols> &lhs, const Matrix<ScalarT, RhsRows, RhsCols> &rhs)

Variables

constexpr int Dynamic = -1
template<typename ScalarT = double, int RowsT = Dynamic, int ColsT = Dynamic>
class Matrix : public Dimensions<Dynamic, Dynamic>
#include <matrix.hpp>

A column Major data representation of a matrix.

Template Parameters
  • ScalarT

  • RowsT

  • ColsT

Public Types

using IndexT = size_t
using Scalar = ScalarT
using value_type = Scalar
using Storage = detail::MatrixStorage<Scalar, CompileTimeSize>
using Dimensions = detail::Dimensions<RowsT, ColsT>

Public Functions

Matrix() = default
template<bool _IsDynamic = IsDynamic, typename std::enable_if<_IsDynamic, int>::type = 0>
inline Matrix(int rows, int cols)
template<int _RowsT, int _ColsT>
inline explicit Matrix(const Matrix<Scalar, _RowsT, _ColsT> &other)

Construct a new Matrix object from another.

Note

This is only valid for dynamic matrices as they need to be resized

Template Parameters
  • _RowsT – Compile-time rows of other matrix

  • _ColsT – Compile-time columns of other matrix

Parameters

other – matrix to construct from

inline Matrix(std::initializer_list<std::initializer_list<ScalarT>> initList)

Construct a new Matrix object and initialise it with the values in the given initializer_list.

The inner list generally represents a row, so a 2x3 matrix can be constructed as follows: Matrix<double, Dynamic, Dynamic> matrix{{1, 2, 3}, {4, 5, 6}};

Column vectors are special cased so that they can be constructed with the transpose: Matrix<double, Dynamic, 1> vector{{1, 2, 3}}; // a 3 element column vector

Parameters

initList – The elements to use to construct the matrix.

inline Scalar *begin()

Iterator to beginning of the sequence.

Note

Only valid for matrices with a dimension of 1 at compile time

inline Scalar *end()

Iterator to one-past-the-end of the sequence.

Note

Only valid for matrices with a dimension of 1 at compile time

inline const Scalar *begin() const

Const iterator to beginning of the sequence.

Note

Only valid for matrices with a dimension of 1 at compile time

inline const Scalar *end() const

Const iterator to one-past-the-end of the sequence.

Note

Only valid for matrices with a dimension of 1 at compile time

inline IndexT size() const

The number of elements in the matrix.

inline const ScalarT *data() const

Pointer to the underlying buffer.

inline ScalarT *data()

Pointer to the underlying buffer.

inline ScalarT operator()(const IndexT row, const IndexT col) const

Element accessor.

inline ScalarT &operator()(const IndexT row, const IndexT col)

Element accessor.

inline ScalarT operator[](const IndexT idx) const

Vector element accessor.

inline ScalarT &operator[](const IndexT idx)

Vector element accessor.

inline ScalarT x() const
inline ScalarT y() const
inline ScalarT z() const
inline ScalarT w() const
inline ScalarT &x()
inline ScalarT &y()
inline ScalarT &z()
inline ScalarT &w()
inline void resize(IndexT size)

Vector resize.

Parameters

size – The new size of the vector.

inline void resize(IndexT rows, IndexT cols)

Matrix resize.

Parameters
  • rows – The new number of rows.

  • cols – The new number of columns.

Public Static Attributes

static constexpr bool IsCompileTimeColumnVector = (ColsT == 1)
static constexpr bool IsCompileTimeRowVector = (RowsT == 1)
static constexpr bool IsVector = (IsCompileTimeColumnVector || IsCompileTimeRowVector)
static constexpr bool IsDynamic = (RowsT == Dynamic || ColsT == Dynamic)
static constexpr auto CompileTimeRows = RowsT
static constexpr auto CompileTimeCols = ColsT
static constexpr auto CompileTimeSize   = IsDynamic ? Dynamic : RowsT * ColsT

Private Members

Storage m_storage

Private Static Functions

template<int _RowsT, int _ColsT>
static inline void checkSize()
namespace detail

Slamcore API internal namespace

Functions

template<int Rows, int Cols>
static void checkSize(const int rows, const int cols)