Global Functions
-
index_iterator make_iterator(const Lengths &len, const Strides&... strides)
Create an index_iterator from the given set of lengths and zero or more sets of strides.
std::vector<int> lengths{4, 5, 2}; std::vector<int> row_strides{10, 2, 1}; std::vector<int> col_strides{1, 4, 20}; auto it = make_iterator(lengths, row_strides, col_strides); auto row_off = 0, col_off = 0; while (it.next(row_off, col_off)) { ... }
- Parameters:
len – The lengths of each dimension. Can be any container type whose values are convertible to len_type.
strides – A parameter pack of strides. There must be exactly
Nparameters in the pack. Can be any container type whose values are convertible to stride_type. The size of each set of strides must be the same as the size oflen.
- Returns:
An index_iterator.
-
template<typename Type, int NDim, typename Allocator>
void swap(marray<Type, NDim, Allocator> &a, marray<Type, NDim, Allocator> &b) Swap the shape, data, and layout of two tensors.
- Parameters:
a – The first tensor to swap.
b – The second tensor to swap.
-
template<int N>
immutable_view cview(tensor_or_view x) Return an immutable view of the given tensor.
- Parameters:
x – The tensor to view.
- Template Parameters:
N – The number of dimensions in the resulting view or [DYNAMIC](MArray::DYNAMIC). The default is the same number of dimensions in the tensor (if fixed), or DYNAMIC (if not).
- Returns:
An immutable view.
-
template<int N>
possibly_mutable_view view(tensor_or_view x) Return a view of the given tensor.
- Parameters:
x – The tensor to view.
- Template Parameters:
N – The number of dimensions in the resulting view or [DYNAMIC](MArray::DYNAMIC). The default is the same number of dimensions in the tensor (if fixed), or DYNAMIC (if not).
- Returns:
A possibly-mutable tensor view. For a tensor ([marray](MArray::marray)), the returned view is immutable if the instance is const-qualified. For a tensor view ([marray_view](MArray::marray_view)), the returned view is mutable if the value type is not const-qualified.
-
std::ostream &operator<<(std::ostream &os, tensor_or_view x)
Write out a representation of the tensor or tensor view to the given output stream.
The format resembles the following (i.e., a valid C/C++ nested array initializer):
{ {0, 1, 2}, {3, 4, 5}, {6, 7, 9} }
- Parameters:
os – The output stream to write to.
x – The tensor or tensor view to write.
- Returns:
The output stream
os.