extern crate nalgebra as na;
use na::{DMatrix, DMatrixSlice, DVector, DVectorSlice};
use std::clone::Clone;
pub trait MatrixOperations: Clone {
fn matrix_vector_prod(&self, vs: DVectorSlice<f64>) -> DVector<f64>;
fn matrix_matrix_prod(&self, mtx: DMatrixSlice<f64>) -> DMatrix<f64>;
fn diagonal(&self) -> DVector<f64>;
fn set_diagonal(&mut self, diag: &DVector<f64>);
fn cols(&self) -> usize;
fn rows(&self) -> usize;
}
impl MatrixOperations for DMatrix<f64> {
fn matrix_vector_prod(&self, vs: DVectorSlice<f64>) -> DVector<f64> {
self * vs
}
fn matrix_matrix_prod(&self, mtx: DMatrixSlice<f64>) -> DMatrix<f64> {
self * mtx
}
fn diagonal(&self) -> DVector<f64> {
self.diagonal()
}
fn set_diagonal(&mut self, diag: &DVector<f64>) {
self.set_diagonal(diag);
}
fn cols(&self) -> usize {
self.ncols()
}
fn rows(&self) -> usize {
self.nrows()
}
}