# Template Class matrix_expression

- Defined in File matrix.hpp

## Class Documentation

template<typename M>
class matrix_expression

  Base for the matrix expression templates This all uses the Curiously recurring template pattern.

  Template Parameters:

    M – The type of the derived class

  Public Functions

  inline std::size_t dim_m() const

    Return the size (dimension) in direction m.

  inline std::size_t dim_n() const

    Return the size (dimension) in direction n.

  inline bool empty() const

    Convenient way to test for empty matrices.

  inline auto &operator()(std::size_t i, std::size_t j)

    Return a reference to element [ i, j ]

  inline auto operator()(std::size_t i, std::size_t j) const

    Return the value of element [ i, j ]

  inline void swap_row(std::size_t r1, std::size_t r2)

    Swap the contents of rows r1 and r2

  inline void swap_col(std::size_t c1, std::size_t c2)

    Swap the contents of columns c1 and c2

  template<typename M2>
  inline bool operator==(const matrix_expression<M2> &m) const

    compare two matrices

  Friends

  inline friend std::ostream &operator<<(std::ostream &os, const matrix_expression &m)

    write the matrix m to std::ostream os