Function scirust::matrix::constructors::from_range_cw [] [src]

pub fn from_range_cw<T: MagmaBase + Num>(rows: usize, cols: usize, start: T, stop: T) -> Matrix<T>

Returns a matrix whose entries are picked up from a range in column wise order.

Remarks

Say you wish to create a matrix of 100 elements. If you provide a range of 80 numbers, the first 80 entries in the matrix will be filled by the numbers from the range. The remaining 20 entries will be filled with zeros. On the other hand, if you provide a range with more than 100 numbers, then only the first 100 numbers will be used to fill the matrix (off course in column major order). The remaining numbers in the range will not be used. They will also not be generated.

Examples

Constructing a 4x4 matrix of floating point numbers:

    use scirust::api::{MatrixF64, from_range_cw, Shape};
    let start  = 0.0;
    let stop = 16.0;
    let m : MatrixF64 = from_range_cw(4, 4, start, stop);
    for i in 0..16{
        let c = i >> 2;
        let r = i & 3;
        assert_eq!(m.get(r, c).unwrap(), i as f64);
    }