array
C++ library for multi-dimensional arrays
Classes | Typedefs | Functions
matrix.h File Reference

Optional matrix-specific helpers and specializations. More...

#include "array/array.h"

Go to the source code of this file.

Classes

class  shape_traits< matrix_shape< Rows, Cols > >
 

Typedefs

template<index_t Rows = dynamic, index_t Cols = dynamic>
using matrix_shape = shape< dim< dynamic, Rows >, dense_dim< dynamic, Cols >>
 
template<class T , index_t Rows = dynamic, index_t Cols = dynamic, class Alloc = std::allocator<T>>
using matrix = array< T, matrix_shape< Rows, Cols >, Alloc >
 
template<class T , index_t Rows = dynamic, index_t Cols = dynamic>
using matrix_ref = array_ref< T, matrix_shape< Rows, Cols >>
 
template<class T , index_t Rows = dynamic, index_t Cols = dynamic>
using const_matrix_ref = matrix_ref< const T, Rows, Cols >
 
template<index_t Length = dynamic>
using vector_shape = shape< dense_dim< dynamic, Length >>
 
template<class T , index_t Length = dynamic, class Alloc = std::allocator<T>>
using vector = array< T, vector_shape< Length >, Alloc >
 
template<class T , index_t Length = dynamic>
using vector_ref = array_ref< T, vector_shape< Length >>
 
template<class T , index_t Length = dynamic>
using const_vector_ref = vector_ref< const T, Length >
 
template<class T , index_t Rows, index_t Cols>
using small_matrix = array< T, matrix_shape< Rows, Cols >, auto_allocator< T, Rows *Cols >>
 
template<class T , index_t Length>
using small_vector = array< T, vector_shape< Length >, auto_allocator< T, Length >>
 

Functions

template<class Shape , class Fn >
void for_each_matrix_index (const Shape &s, Fn &&fn)
 

Detailed Description

Optional matrix-specific helpers and specializations.

Typedef Documentation

using matrix_shape = shape<dim<dynamic, Rows>, dense_dim<dynamic, Cols>>

The standard matrix notation is to refer to elements by 'row, column'. To make this efficient for typical programs, we're going to make the second dimension the dense dim. This shape has the option of making the size of the matrix compile-time constant via the template parameters.

using matrix = array<T, matrix_shape<Rows, Cols>, Alloc>

A matrix or matrix_ref is an array or array_ref with Shape = matrix_shape.

using vector_shape = shape<dense_dim<dynamic, Length>>

A vector is just a 1-d array.

using small_matrix = array<T, matrix_shape<Rows, Cols>, auto_allocator<T, Rows * Cols>>

A matrix with static dimensions Rows and Cols, with an auto_allocator.

Function Documentation

void nda::for_each_matrix_index ( const Shape &  s,
Fn &&  fn 
)

Calls fn for each index in a matrix shape s.