MCPcopy Create free account
hub / github.com/daniel-e/rustml / mul_vec_minus_vec

Method mul_vec_minus_vec

src/ops.rs:449–475  ·  view source on GitHub ↗
(&self, v: &[f64], y: &[f64])

Source from the content-addressed store, hash-verified

447impl MatrixVectorMul<f64> for Matrix<f64> {
448
449 fn mul_vec_minus_vec(&self, v: &[f64], y: &[f64]) -> Vec<f64> {
450
451 if self.cols() != v.len() || self.rows() != y.len() {
452 panic!("Invalid dimensions.");
453 }
454
455 // this will be modified by cblas_dgemv
456 let targets = y.to_vec();
457
458 unsafe {
459 cblas_dgemv(
460 Order::RowMajor,
461 Transpose::NoTrans,
462 self.rows() as c_int,
463 self.cols() as c_int,
464 1.0 as c_double,
465 self.buf().as_ptr() as *const c_double,
466 self.cols() as c_int,
467 v.as_ptr() as *const c_double,
468 1 as c_int,
469 -1.0 as c_double, // beta
470 targets.as_ptr() as *mut c_double,
471 1 as c_int
472 );
473 }
474 targets
475 }
476
477 fn mul_dgemv(&self, trans: bool, alpha: f64, x: &[f64], beta: f64, y: &[f64]) -> Vec<f64> {
478

Callers 2

errorMethod · 0.80
derivativesMethod · 0.80

Calls 5

colsMethod · 0.80
rowsMethod · 0.80
lenMethod · 0.45
to_vecMethod · 0.45
bufMethod · 0.45

Tested by

no test coverage detected