pub fn matrix_add(summand0: &[Vec<i32>], summand1: &[Vec<i32>]) -> Vec<Vec<i32>> {
    // Add two matrices of identical dimensions
    let mut result: Vec<Vec<i32>> = vec![];
    if summand0.len() != summand1.len() {
        panic!("Matrix dimensions do not match");
    }
    for row in 0..summand0.len() {
        if summand0[row].len() != summand1[row].len() {
            panic!("Matrix dimensions do not match");
        }
        result.push(vec![]);
        for column in 0..summand1[0].len() {
            result[row].push(summand0[row][column] + summand1[row][column]);
        }
    }
    result
}
// Basic matrix operations using row vectors wrapped in column vectors as matrices.
// Supports i32, should be interchangeable for other types.
// Wikipedia reference: https://www.wikiwand.com/en/Matrix_(mathematics)
Basic matrix operations using row vectors wrapped in column vectors as matrices.
Supports i32, should be interchangeable for other types.
Basic matrix operations using row vectors wrapped in column vectors as matrices . Supports i32 should be interchangeable for other types .
pub fn matrix_add(summand0: &[Vec<i32>], summand1: &[Vec<i32>]) -> Vec<Vec<i32>> {
    // Add two matrices of identical dimensions
    let mut result: Vec<Vec<i32>> = vec![];
    if summand0.len() != summand1.len() {
        panic!("Matrix dimensions do not match");
    }
    for row in 0..summand0.len() {
        if summand0[row].len() != summand1[row].len() {
            panic!("Matrix dimensions do not match");
        }
        result.push(vec![]);
        for column in 0..summand1[0].len() {
            result[row].push(summand0[row][column] + summand1[row][column]);
        }
    }
    result
}
pub fn matrix_add ( summand0 : & [ Vec < i32 > ] , summand1 : & [ Vec < i32 > ] ) -> Vec < Vec < i32 > > { // Add two matrices of identical dimensions let mut result : Vec < Vec < i32 > > = vec ! [ ] ; if summand0 . len ( ) != summand1 . len ( ) { panic ! ( " " ) ; } for row in 0 .. summand0 . len ( ) { if summand0 [ row ] . len ( ) != summand1 [ row ] . len ( ) { panic ! ( " " ) ; } result . push ( vec ! [ ] ) ; for column in 0 .. summand1 [ 0 ] . len ( ) { result [ row ] . push ( summand0 [ row ] [ column ] + summand1 [ row ] [ column ] ) ; } } result }
Basic matrix operations using row vectors wrapped in column vectors as matrices.
Basic matrix operations using row vectors wrapped in column vectors as matrices .
summand0
&[Vec<i32>]
summand1
&[Vec<i32>]
summand0
&[Vec<i32>]
summand1
&[Vec<i32>]