ArrayUtil¶
-
namespace
ndarray -
namespace
arrayutil¶ Functions
-
ndarray::LL
getNumOfElementByShape(const ndarray::Shape &shape)¶ get array size or number of element by array shape.
Example: shape{2,3,4} => output 2*3*4 = 24
- Return
number of element of given array.
- Parameters
shape: vector data of array shape.
-
ndarray::Shape
getCumulativeMultiShape(const ndarray::Shape &shape, const int offset = 0)¶ get cumulative multyping shape. output size should be same as shape_size.
Example 1: shape{2,3,4} => cum_shape{12,4,1}
Example 2: shape{2,3,4,5}, offset = 2 => cun_shape{3,1}
Example 3: Shape{2,3}, offset=1 => cum_shape{1}
- Return
vector data with cumulative multyping shape likse as stride.
- Parameters
shape: vector data of array shape.offset: skip number of element from last of the shape.
-
ndarray::Shape
getMatmulOutShape(const ndarray::Shape &l_shape, const ndarray::Shape &r_shape)¶ get matmul expected output shape from two array shape. Also support broad castring. Example: l_shape{4,1,3,4}, r_shape{1,3,4,5} => out_shape{4,3,3,5}
- Return
Expected broad casted matmul shape.
- Parameters
l_shape: left array shape.r_shape: right array shape.
-
ndarray::LL
getIndexFromIndices(const ndarray::Indices &indices, const ndarray::Array &A)¶ calculate actula location of the given indices
Example: indices{0,1} of a 2D array. output will be that row and column actual location in 1D array.
- Return
actual location of that indices.
- Parameters
indices: a vector of indices. size must be same as ndarray shape size.A: a ndarray.
-
ndarray::LL
-
namespace