Class ModelArraySlice

Class Documentation

class ModelArraySlice

A class to provide slicing of ModelArray data arrays.

Public Types

using Slice = ArraySlicer::Slice
using SliceIter = ArraySlicer::SliceIter
using iterator = MASIter

Public Functions

ModelArraySlice() = delete
inline ModelArraySlice(ModelArray &ma, const Slice &sl)
ModelArraySlice &operator=(ModelArray &ma)

Assigns data to this slice from a ModelArray.

Parameters:

ma – The ModelArray object to read the data from

Returns:

A reference to the updated ModelArraySlice object

ModelArraySlice &operator=(ModelArraySlice &other)

Copies data from another ModelArraySlice.

Parameters:

other – The ModelArraySlice object to read the data from

Returns:

A reference to the updated ModelArraySlice object.

ModelArraySlice &operator=(FloatType v)

Assigns a value to the entire slice, based on the given scalar value.

Parameters:

v – The value to which to set the slice.

Returns:

A reference to the updated ModelArraySlice.

template<typename T>
inline ModelArraySlice &operator=(const T &buffer)

Assigns the contents of a buffer to the slice. This function copies the entire buffer.

Parameters:

buffer – The buffer to copy the data from. Can be of any type which provides a forward iterator. The provided object must have the same number of elements as the slice.

Returns:

A reference to the updated ModelArraySlice object.

ModelArraySlice &operator=(const ModelArray::DataType &dataBuffer)

Assigns to a slice from a instance of ModelArray::DataType.

Fills the slice with data from an instance of ModelArray::DataType. The data source should be sufficiently sized that the data is copied without being indexed out-of-bounds. The number of components of the slice ModelArray and the size of the second dimension of the source array should match. The spatial dimensions of the slice will copy from the first dimension of the source array, treating it as a flattened one-dimensional version of the slice, with the first spatial dimension of the slice varying fastest.

@params dataBuffer The source of the data to be copied into the slice.

operator ModelArray::DataType() const

Returns the contents of this slice as an instance of ModelArray::DataType.

Creates an instance of ModelArray::DataType with the contents of the slice, including all components. Current ModelArray::DataType is Eigen::Array. In this case all spatial dimensions are flattened to one dimension, as they are internally in ModelArray, and occupy the first dimension of the Eigen::Array. Any components of the sliced array take up the second dimension. That is, a 4 x 5 slice with 3 components will create a (20, 3) Eigen::Array.

ModelArray &copyToModelArray(ModelArray &target) const

Copies the contents of a slice to a ModelArray with an equal number of elements.

Parameters:

target – The ModelArray object to copy the contents of the slice to.

Returns:

A reference to the updated ModelArray object.

template<typename T>
inline T &copyToBuffer(T &buffer)

Copies the contents of the slice to a buffer.

Parameters:

buffer – The target of the copying. The buffer type must provide a forward operator. The buffer object must provide at least as many elements as exist in the slice.

Returns:

A reference to the updated buffer object.

template<typename T>
inline const ModelArraySlice &copyToSlicedBuffer(T &target, SliceIter &targetIter) const

Copies data from the slice to a slice of a buffer.

Parameters:
  • target – The target buffer. The buffer type must be one that can be indexed by the Eigen::seqN function.

  • targetIter – An instance of SliceIter created from the desired slice of the buffer and the dimensions of the target object.

Returns:

A reference to this ModelArraySlice (not the updated buffer).

template<typename S>
inline ModelArraySlice &copyFromSlicedBuffer(const S &source, SliceIter &sourceIter)

Copies data to the slice from a slice of a buffer.

Parameters:
  • source – The source buffer.The buffer type must be one that can be indexed by the Eigen::seqN function.

  • sourceIter – An instance of SliceIter created from the desired slice of the buffer and the dimensions of the source object.

Returns:

A reference to the updated ModelArraySlice object.

iterator begin()

Returns a forward iterator pointing to the start of the slice.

iterator end()

Returns a forward iterator pointing to one past the end of the slice.

Public Members

Slice slice

The slice this object represents. Updating this invalidates all current iterators.

friend MASIter
friend ConstModelArraySlice
friend Halo