Function russell_lab::matrix::mat_copy

source ·
pub fn mat_copy(b: &mut Matrix, a: &Matrix) -> Result<(), StrError>
Expand description

(dcopy) Copies matrix

b := a

See also: https://www.netlib.org/lapack/explore-html/da/d6c/dcopy_8f.html

§Examples

use russell_lab::{mat_copy, Matrix, StrError};

fn main() -> Result<(), StrError> {
    let a = Matrix::from(&[
        [1.0, 2.0, 3.0],
        [4.0, 5.0, 6.0],
    ]);
    let mut b = Matrix::from(&[
        [-1.0, -2.0, -3.0],
        [-4.0, -5.0, -6.0],
    ]);
    mat_copy(&mut b, &a)?;
    let correct = "┌       ┐\n\
                   │ 1 2 3 │\n\
                   │ 4 5 6 │\n\
                   └       ┘";
    assert_eq!(format!("{}", b), correct);
    Ok(())
}