Skip to content

Instantly share code, notes, and snippets.

View shautvast's full-sized avatar

Sander Hautvast shautvast

View GitHub Profile
@shautvast
shautvast / gist:dd6c84ed94b943015924feba0126cdf5
Created March 3, 2023 15:35
matrix add with broadcast like in numpy
use core::ops::Add;
use std::fmt::Debug;
use std::ops::AddAssign;
use nalgebra::DMatrix;
/// matrix add with broadcasting
/// like the numpy add operation
/// not sure I even need it anymore, after fixing inconsistencies with the matrix shapes
/// TODO see if it's still needed, or that standard matrix addition suffices
pub fn add<T>(v1: DMatrix<T>, v2: DMatrix<T>) -> Result<DMatrix<T>, String>