LazyExpr#

template<typename Op, typename Lhs, typename Rhs>
class BinaryExpr<Op, Lhs, Rhs, std::enable_if_t<std::is_arithmetic<Rhs>::value>>#

Public Functions

inline BinaryExpr(const Lhs &lhs, const Rhs &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const noexcept#
inline auto rows() const -> std::pair<std::size_t, std::size_t>#
inline auto cols() const -> std::pair<std::size_t, std::size_t>#

Private Members

Lhs lhs#
Rhs rhs#
Op op#
template<typename Op, typename Lhs, typename Rhs>
class BinaryExpr<Op, Lhs, Rhs, std::enable_if_t<std::is_arithmetic<Lhs>::value>>#

Public Functions

inline BinaryExpr(const Lhs &lhs, const Rhs &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const noexcept#
inline auto rows() const -> std::pair<std::size_t, std::size_t>#
inline auto cols() const -> std::pair<std::size_t, std::size_t>#

Private Members

Lhs lhs#
Rhs rhs#
Op op#
namespace lm#
template<typename Op, typename Lhs, typename Rhs, typename = void>
class BinaryExpr#
#include <LazyExpr.hpp>

Template functor for binary expressions. Contains an abstract representation of binary ops and an API for recursively calling eval via operator() overload.

Template Parameters:
  • Op – Operator type specified in LazyOps.hpp

  • Lhs – Left hand side of the expr.

  • Rhs – Righ hand side of the expr.

Public Functions

inline BinaryExpr(const Lhs &lhs, const Rhs &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const noexcept#
inline auto rows() const -> std::pair<std::size_t, std::size_t>#
inline auto cols() const -> std::pair<std::size_t, std::size_t>#

Private Members

Lhs lhs#
Rhs rhs#
Op op#
template<typename Op, typename T, std::size_t Rows1, std::size_t Cols1, std::size_t Rows2, std::size_t Cols2>
class BinaryExpr<Op, Matrix<T, Rows1, Cols1>, Matrix<T, Rows2, Cols2>>#

Public Functions

inline BinaryExpr(const Matrix<T, Rows1, Cols1> &lhs, const Matrix<T, Rows2, Cols2> &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const noexcept#
inline auto rows() const -> std::pair<std::size_t, std::size_t>#

Private Members

const Matrix<T, Rows1, Cols1> &lhs#
const Matrix<T, Rows2, Cols2> &rhs#
Op op#
template<typename Op, typename Lhs, typename Rhs> value > >

Public Functions

inline BinaryExpr(const Lhs &lhs, const Rhs &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const noexcept#
inline auto rows() const -> std::pair<std::size_t, std::size_t>#
inline auto cols() const -> std::pair<std::size_t, std::size_t>#

Private Members

Lhs lhs#
Rhs rhs#
Op op#
template<typename Op, typename Lhs, typename Rhs> value > >

Public Functions

inline BinaryExpr(const Lhs &lhs, const Rhs &rhs)
inline auto operator()(std::size_t i, std::size_t j) const noexcept
inline auto rows() const -> std::pair<std::size_t, std::size_t>
inline auto cols() const -> std::pair<std::size_t, std::size_t>

Private Members

Lhs lhs
Rhs rhs
Op op
template<typename Op, typename Expr>
class UnaryExpr#
#include <LazyExpr.hpp>

Template functor for unary expressions. Contains an abstract representation of unary ops and an API for recursively calling eval via operator() overload.

Template Parameters:
  • Op – Operator type specified in LazyOps.hpp

  • Expr – Unary expression

Public Functions

inline UnaryExpr(const Expr &expr)#
inline auto operator()(std::size_t i, std::size_t j) const#
inline auto rows() const#
inline auto cols() const#

Private Members

Expr expr#
Op op#
template<typename Lhs, typename Rhs>
class MatMulExpr#
#include <LazyExpr.hpp>

Template functor for matrix multiplication expressions. Contains an operator() for evaluating the expression lazily. Works with matmul(Expr, Expr) types to represent MatMulExpr<Ops,Ops> computation *.

Template Parameters:
  • Lhs – Left hand side of the expr.

  • Rhs – Right hand side of the expr.

Public Functions

inline MatMulExpr(const Lhs &lhs, const Rhs &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const#
inline auto rows() const -> std::size_t#
inline auto cols() const -> std::size_t#

Private Members

Lhs m_lhs#
Rhs m_rhs#
template<typename T, std::size_t Rows1, std::size_t Cols1, std::size_t Rows2, std::size_t Cols2>
class MatMulExpr<Matrix<T, Rows1, Cols1>, Matrix<T, Rows2, Cols2>>#

Public Functions

inline MatMulExpr(const Matrix<T, Rows1, Cols1> &lhs, const Matrix<T, Rows2, Cols2> &rhs)#
inline auto operator()(std::size_t i, std::size_t j) const#
inline auto rows() const -> std::size_t#
inline auto cols() const -> std::size_t#

Private Members

const Matrix<T, Rows1, Cols1> &m_lhs#
const Matrix<T, Rows2, Cols2> &m_rhs#

LazyMatrix#

namespace lm
template<typename T, std::size_t Rows, std::size_t Cols>
class Matrix#

Public Types

using iterator = typename std::vector<T>::iterator#
using const_iterator = typename std::vector<T>::const_iterator#

Public Functions

inline Matrix()#
inline Matrix(const std::vector<T> &data)#
inline Matrix(std::initializer_list<std::initializer_list<T>> t_list)#
inline constexpr auto operator()(std::size_t i, std::size_t j) const -> T#
inline constexpr auto operator()(std::size_t i, std::size_t j) -> T&#
inline constexpr auto rows() const -> std::size_t#
inline constexpr auto cols() const -> std::size_t#
inline constexpr auto begin() -> iterator#
inline constexpr auto end() -> iterator#
inline constexpr auto cbegin() const -> const_iterator#
inline constexpr auto cend() const -> const_iterator#
template<typename Expr>
inline auto operator=(const Expr &expr) -> Matrix&#

Private Members

std::vector<T> m_data#

LazyOps#

namespace lm

Functions

template<typename T, std::size_t Row, std::size_t Col>
constexpr auto operator==(const Matrix<T, Row, Col> &lhs, const Matrix<T, Row, Col> &rhs) -> bool#
template<typename T, std::size_t Row, std::size_t Col>
constexpr auto operator!=(const Matrix<T, Row, Col> &lhs, const Matrix<T, Row, Col> &rhs) -> bool#
template<typename Lhs, typename Rhs>
constexpr auto operator+(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<std::plus<>, Lhs, Rhs>#
template<typename Lhs, typename Rhs>
constexpr auto operator-(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<std::minus<>, Lhs, Rhs>#
template<typename Lhs, typename Rhs>
constexpr auto operator*(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<std::multiplies<>, Lhs, Rhs>#
template<typename Lhs, typename Rhs>
constexpr auto operator/(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<std::divides<>, Lhs, Rhs>#
template<typename Lhs, typename Rhs>
constexpr auto matmul(const Lhs &lhs, const Rhs &rhs) -> MatMulExpr<Lhs, Rhs>#
template<typename Lhs, typename Rhs>
constexpr auto operator%(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<ModOp, Lhs, Rhs>#
template<typename Lhs, typename Rhs, typename = typename std::enable_if_t<std::is_arithmetic_v<Rhs>>>
constexpr auto pow(const Lhs &lhs, const Rhs &rhs) -> BinaryExpr<PowOp, Lhs, Rhs>#
template<typename Expr>
constexpr auto operator-(const Expr &expr) -> UnaryExpr<std::negate<>, Expr>#
template<typename Expr>
auto log(const Expr &expr) -> UnaryExpr<LogOp, Expr>#
template<typename Expr>
auto log10(const Expr &expr) -> UnaryExpr<Log10Op, Expr>#
template<typename Expr>
auto log2(const Expr &expr) -> UnaryExpr<Log2Op, Expr>#
template<typename Expr>
auto exp(const Expr &expr) -> UnaryExpr<ExpOp, Expr>#
template<typename Expr>
auto exp2(const Expr &expr) -> UnaryExpr<Exp2Op, Expr>#
template<typename Expr>
auto sqrt(const Expr &expr) -> UnaryExpr<SqrtOp, Expr>#
template<typename Expr>
auto cbrt(const Expr &expr) -> UnaryExpr<CbrtOp, Expr>#
template<typename Expr>
auto sin(const Expr &expr) -> UnaryExpr<SinOp, Expr>#
template<typename Expr>
auto cos(const Expr &expr) -> UnaryExpr<CosOp, Expr>#
template<typename Expr>
auto tan(const Expr &expr) -> UnaryExpr<TanOp, Expr>#
template<typename Expr>
auto asin(const Expr &expr) -> UnaryExpr<ASinOp, Expr>#
template<typename Expr>
auto acos(const Expr &expr) -> UnaryExpr<ACosOp, Expr>#
template<typename Expr>
auto atan(const Expr &expr) -> UnaryExpr<ATanOp, Expr>#
template<typename Expr>
auto sinh(const Expr &expr) -> UnaryExpr<SinhOp, Expr>#
template<typename Expr>
auto cosh(const Expr &expr) -> UnaryExpr<CoshOp, Expr>#
template<typename Expr>
auto tanh(const Expr &expr) -> UnaryExpr<TanhOp, Expr>#
template<typename Expr>
auto asinh(const Expr &expr) -> UnaryExpr<ASinhOp, Expr>#
template<typename Expr>
auto acosh(const Expr &expr) -> UnaryExpr<ACoshOp, Expr>#
template<typename Expr>
auto atanh(const Expr &expr) -> UnaryExpr<ATanhOp, Expr>#
template<typename Expr>
auto to_deg(const Expr &expr) -> UnaryExpr<ToDeg, Expr>#
template<typename Expr>
auto to_rad(const Expr &expr) -> UnaryExpr<ToRad, Expr>#
template<typename Expr>
auto erf(const Expr &expr) -> UnaryExpr<ErfOp, Expr>#
template<typename Expr>
auto erfc(const Expr &expr) -> UnaryExpr<ErfcOp, Expr>#
template<typename Expr>
auto tgamma(const Expr &expr) -> UnaryExpr<TGammaOp, Expr>#
template<typename Expr>
auto lgamma(const Expr &expr) -> UnaryExpr<LGammaOp, Expr>#
template<typename Expr>
auto ceil(const Expr &expr) -> UnaryExpr<CeilOp, Expr>#
template<typename Expr>
auto floor(const Expr &expr) -> UnaryExpr<FloorOp, Expr>#
struct ModOp#

Public Functions

template<typename Lhs, typename Rhs>
inline auto operator()(Lhs l, Rhs r) const#
struct PowOp#

Public Functions

template<typename Lhs, typename Rhs>
inline auto operator()(Lhs l, Rhs r) const#
struct LogOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct Log10Op#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct Log2Op#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ExpOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct Exp2Op#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct SqrtOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct CbrtOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct SinOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct CosOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct TanOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ASinOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ACosOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ATanOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct SinhOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct CoshOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct TanhOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ASinhOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ACoshOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ATanhOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ToDeg#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ToRad#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ErfOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct ErfcOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct TGammaOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct LGammaOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct CeilOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#
struct FloorOp#

Public Functions

template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
inline auto operator()(T t) const#

Utils#

namespace lm

Functions

template<typename T, std::size_t Row, std::size_t Col, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
auto make_matrix(std::reference_wrapper<std::mt19937> prng) -> Matrix<T, Row, Col>#

Returns a random matrix given by prng. This implements an std::array base and aligns the matrix in memory.

Template Parameters:
  • T – Type of the matrix; constrained to types supported by prng.

  • Row – Specifies the size of the row.

  • Col – Specifies the size of col.

Parameters:

prng – function wrapper for prng, defaults to std::mt19937

Returns:

Matrix<T, Row, Col> random matrix described by prng.

template<typename T, std::size_t Row, std::size_t Col, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
auto make_vmatrix(std::reference_wrapper<std::mt19937> prng) -> Matrix<T, Row, Col>#

Returns a random matrix given by prng. This implements std::vector base to hold for larger size matrices that goes beyond the stack limit of std::array.

Template Parameters:
  • T – Type of the matrix; constrained to types supported by prng.

  • Row – Specifies the size of the row.

  • Col – Specifies the size of col.

Parameters:

prng – function wrapper for prng, defaults to std::mt19937

Returns:

Matrix<T, Row, Col> random matrix described by prng.

template<typename T, std::size_t Row, std::size_t Col>
auto operator<<(std::ostream &os, const lm::Matrix<T, Row, Col> &matrix) -> std::ostream&#

Operator overload to display the matrix in std::cout.

Template Parameters:
  • T – Type of the matrix.

  • Row – Specifies the size of the row.

  • Col – Specifies the size of the col.

Parameters:
  • osstd::ostream that records the buffer to be printed.

  • matrix – matrix to be registered in the output buffer.

Returns:

std::ostream& reference output buffer

template<typename T, std::size_t Row>
auto operator<<(std::ostream &os, const std::array<T, Row> &v) -> std::ostream&#

Operator overload to display the vector of type std::array.

Template Parameters:
  • T – Type of the vector

  • Row – Specifies the size of the row.

Parameters:
  • osstd::ostream that records the buffer to be printed.

  • v – vector to be registered in the output buffer

Returns:

std::ostream& reference to the output buffer

class Timer#
#include <Utils.hpp>

Serves as a simple timer utility used for benchmarking performance.

Public Functions

inline explicit Timer()#

Construct a new Timer object.

inline explicit Timer(std::size_t t_iterations)#

Construct a new Timer object.

Parameters:

t_iterations – specifies the number of iterations

inline ~Timer()#
inline auto start() -> void#

Function for setting a start point of the timer. End time is taken in the destructor.

Private Members

std::chrono::high_resolution_clock::time_point start_time#
std::size_t m_iterations = {}#