# Matrix Matrix offers two template classes of fixed N-dimensional matrices of any given type: a "normal" Matrix class and a CompressedMatrix class. The CompressedMatrix class offers compression by using ranges of identical neighbouring values. Additionally Matrix offers a DynamicMatrix class which is N-dimensional, and the dimensionality is variable during runtime. Note: the CompressedMatrix class actually only compresses when many neighbouring values are identical! Matrices can be in row-major (C-style) or column-major(FORTRAN/Matlab-style) addressing modes. ## Interface ### Fixed Dimensionality In the following table, one may read CompressedMatrix for Matrix. The exact definition is:
    template <typename T, unsigned Dimensions>
    class Matrix;
      value_type
| The type of the values in the Matrix.
      iterator
| The iterator type of this Matrix.
      const_iterator
| The const_iterator type of this Matrix, for read-only access.
      Matrix(bool colMajor = false)
| Default Constructor
      template <typename Iterator>
      Matrix(Iterator extentsIt)
| Constructor, dimensions as prescribed in the range indicated by "extentsIt".
      template <typename Iterator>
      Matrix(Iterator extentsIt, const T value, bool colMajor = false)
| Constructor, dimensions as prescribed in the range indicated by "extentsIt", filled with "value". Parameter colMajor allows one to use colums-major addressing in stead of row-major addressing.
      template <typename Iterator1, typename Iterator2>
      Matrix(const Iterator1 extentsIt,
    	 const Iterator2 beginData, const Iterator2 endData,
    	 bool colMajor = false)
| Constructor, dimensions as prescribed in the range indicated by "extentsIt". The Matrix is filled with values from the range beginData to endData. Parameter colMajor allows one to use colums-major addressing in stead of row-major addressing.
      unsigned size() const
| Number of elements in the Matrix.
      std::tr1::array<std::size_t, D>::const_iterator extents() const
| Extents, i.e. sizes in all dimensions.
      template <typename Iterator>
      void resize(Iterator extentsIt)
| Change the size and shape of the Matrix according to the extents given in the range indicated by "extentsIt".
      Matrix<T, Dimensions-1>
      &operator[] (const unsigned index)
| Returns a reference to a Matrix with one less dimension.
      const Matrix<T, Dimensions-1>
      &operator[] (const unsigned index) const
| Returns a reference to a const Matrix with one less dimension.
      iterator begin()
| Iterator pointing to the first element.
      iterator end()
| Iterator pointing to the non-existing end element.
      const_iterator begin() const
| const_iterator pointing to the first element.
      const_iterator end() const
| const_iterator pointing to the non-existing end element.
      void changeMajor()
| Change between row-major and column-major addressing.
      bool colMajor()
| Return true if matrix is in column-major addressing mode, false if the matrix is in row-major mode.
      void clear()
| Completely empty the matrix.
### Dynamic Dimensionality The DynamicMatrix can have any dimension chosen during runtime, and the dimensionality can be changed during runtime if desired.
      value_type
| The type of the values in the Matrix.
      iterator
| The iterator type of this Matrix.
      const_iterator
| The const_iterator type of this Matrix, for read-only access.
      slice_type
| .
      template <typename It>
      DynamicMatrix(It extentsBegin, It extentsEnd)
| .
      template <typename It>
      DynamicMatrix(It extentsBegin, It extentsEnd, T value)
| .
      unsigned size() const
| Returns the number of elements in the entire matrix.
      unsigned dimensions() const
| Returns the current number of dimensions of the matrix.
      std::vector<unsigned>::const_iterator extents() const
| .
      slice_type &operator[](unsigned index)
| .
      const slice_type &operator[](unsigned index) const
| .
      template <typename It>
      void resize(It extentsBegin, It extentsEnd, bool preserve = false)
| .
      iterator begin()
| Begin iterator over all elements.
      iterator end()
| End iterator over all elements.
      const_iterator begin() const
| Begin read-only iterator over all elements.
      const_iterator end() const
| End read-only iterator over all elements.
      void clear()
| Completely empty the matrix, set to zero all extents in all dimensions.
### SymmetricMatrix A SymmetricMatrix is an n-by-n 2-dimensional matrix where that is equal to its transpose, i.e. an element at (x, y) is the same as the element at (y, x).
      value_type
| The type of the values in the Matrix.
      iterator
| The iterator type of this Matrix.
      const_iterator
| The const_iterator type of this Matrix, for read-only access.
      SymmetricMatrix(const std::size_t rank = 0)
| Construct a SymmetricMatrix with rank rows and columns.
      unsigned size() const
| Returns the number of elements in the entire matrix.
      unsigned rank() const
| Returns the number of rows, which is equal to the number of columns.
      void resize(const std::size_t rank)
| Resize to an rank-by-rank matrix.
      iterator begin()
| Begin iterator over all elements.
      iterator end()
| End iterator over all elements.
      const_iterator begin() const
| Begin read-only iterator over all elements.
      const_iterator end() const
| End read-only iterator over all elements.
      iterator begin()
| Begin iterator over all elements.
      iterator end()
| End iterator over all elements.
      const_iterator begin() const
| Begin read-only iterator over all elements.
      const_iterator end() const
| End read-only iterator over all elements.