[−][src]Module gulali::attributes
Vector attributes
Overview
Gulali uses Rust's vector standard data structure extensively. We don't reinvent yet-another data structure to keep things simple and easy to use. Gulali add 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 withn
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
// Generate a two-dimensional vector with shape [3, 3] // filled with zeros let matrix: Vec<Vec<i32>> = Vec::two_dim() .with_shape([3, 3]) .zeros() .generate(); 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 |