NdArray::NdArray()

Construct an NdArray object with the given shape, filling with the given element.

Synopsis

NdArray(const Shape<N> &shape, const T &val)

Arguments

shape: shape of NdArray.

val: value of element.

NdArray::NdArray()

Construct an NdArray object with the given shape, filling with an array of type T.

Synopsis

NdArray(

const Shape<N> &shape,

const T *data,

size_t sz)

Arguments

shape: shape of NdArray.

data: an array of elements.

sz: size of elements.

NdArray::NdArray()

Construct an NdArray object with the given shape and the filling function.

Synopsis

NdArray(const Shape<N> &shape)

Arguments

shape: shape of NdArray.

NdArray::Clone()

Clone NdArray object.

Synopsis

NdArray<T, N> Clone()

Return

new NdArray object.

NdArray::Diagonal()

Get diagonals of NdArray object.

Synopsis

NdArray<T, N - 1> Diagonal(

int offset,

int axis1,

int axis2)

Arguments

offset: offset of the diagonal from the main diagonal. Can be positive or negative.

axis1: 1st axis of NdArray.

axis2: 2nd axis of NdArray.

Return

(N-1)-dimensional diagonals.

NdArray::Expand()

Expand shape of NdArray object.

Synopsis

NdArray<T, N + 1> Expand(int axis)

Arguments

axis: axis of NdArray.

Return

NdArray object in (N+1)-dimensions.

NdArray::Fill()

Fill NdArray object with given value.

Synopsis

void Fill(const T &val)

Arguments

val: new value.

NdArray::Flatten()

Flatten an NdArray object to a 1-dimensional shape.

Synopsis

NdArray<T, 1> Flatten()

Return

An NdArray object collapsed into one dimension.

NdArray::GetDim()

Get i-th dimension of NdArray object.

Synopsis

size_t GetDim(int i)

Arguments

i: index of dimension

Return

i-th dimension.

NdArray::GetND()

Get number of dimensions of NdArray object.

Synopsis

int GetND()

Return

number of dimensions.

NdArray::GetShape()

Get shape of NdArray object.

Synopsis

const Shape<N> &GetShape()

Return

shape object.

NdArray::GetSize()

Get size of NdArray object.

Synopsis

size_t GetSize()

Return

number of elements.

NdArray::Item()

Get element of given index from NdArray object.

Synopsis

T &Item(size_t idx)

Arguments

idx: index of element.

Return

value of element.

NdArray::operator[]()

Get element of given index from NdArray object.

Synopsis

T &operator[](size_t idx)

Arguments

idx: index of element.

Return

value of element.

NdArray::operator[]()

Get constraints of given view from NdArray object.

Synopsis

NdArray<T, N> operator[](const View &view)

Arguments

view: view of multi-dimensional array.

Return

new NdArray object.

NdArray::Represent()

String representation of NdArray object.

Synopsis

std::string Represent(size_t maxlen)

Arguments

maxlen: max length of representation.

Return

string object.

NdArray::Reshape()

Reshape NdArray object to new shape.

Synopsis

template <int M> NdArray<T, M> Reshape(const Shape<M> &shape)

Arguments

shape: new shape of M-dimensions.

Return

M-dimensional NdArray object.

NdArray::SetItem()

Set element of given index to NdArray object.

Synopsis

void SetItem(size_t idx, const T &val)

Arguments

idx: index of element.

val: value of element.

NdArray::Squeeze()

Remove axis of length 1 from shape of NdArray object.

Synopsis

NdArray<T, N - 1> Squeeze(int axis)

Arguments

axis: axis of NdArray, where the length is 1.

Return

(N-1)-dimensional NdArray object.

NdArray::Sum()

Sum of all elements in NdArray object.

Synopsis

template <class Ta> NdArray<Ta, 0> Sum()

Return

sum in zero dimension.

NdArray::Sum()

Sum of elements at given axis of NdArray object.

Synopsis

template <class Ta> NdArray<Ta, N - 1> Sum(int axis)

Arguments

axis: axis of NdArray.

Return

(N-1)-dimensional NdArray object.

NdArray::Transpose()

Perform matrix transpose of NdArray object.

Synopsis

NdArray<T, N> Transpose()

Return

transposed NdArray object.