[−][src]Module gulali::attributes
Vector attributes
Overview
Gulali uses Rust's vector standard data type extensively. We don't reinvent yet-another data type to keep things simple and easy to use. Gulali added the following attributes to Rust's vector:
- dim: the number of dimensions of the vector.
- shape: This is a list of integers indicating the
size of the vector in each dimension.
For a matrix with
n
rows andm
columns, shape will be[n,m]
. The length of the shape is therefore the number of dimensions,dim()
. - size: the total number of elements of the vector. This is equal to the product of the elements of shape.
Examples
// Create two-dimensional vector with shape [3, 3] // filled with zeros let matrix: Vec<Vec<i32>> = Vec::two_dim(3, 3).zeros(); assert_eq!(matrix.dim(), 2); assert_eq!(matrix.shape(), [3, 3]); assert_eq!(matrix.size(), 9);
Traits
Dimension | Dimension of the vector |
Shape | A list of integers indicating the size of the vector in each dimension |
Size | Total number of elements of the vector |