Function rustml::ops_inplace::s_gemm [] [src]

pub fn s_gemm(alpha: f32, a: &Matrix<f32>, b: &Matrix<f32>, beta: f32, c: &mut Matrix<f32>, transa: bool, transb: bool)

Computes alpha * op(A) * op(B) + beta * C and stores the result in C. (optimized via BLAS)

If transa is true the function op(A) returns the transpose of A, otherwise A is returned. If transb is true the function op(B) returns the transpose of B, otherwise B is returned.

Panics if the dimensions of the matrices do not match.

use rustml::ops_inplace::*;
use rustml::matrix::*;

let a = mat![
    1.0f32, 2.0, 3.0;
    4.0, 5.0, 6.0
];
let b = mat![
    2.0f32, 5.0, 2.0, 3.0;
    1.0, 9.0, 5.0, 4.0;
    4.0, 6.0, 8.0, 7.0
];
let mut c = mat![
    3.0f32, 4.0, 1.0, 8.0;
    4.0, 2.0, 6.0, 6.0
];
s_gemm(2.0f32, &a, &b, 3.0f32, &mut c, false, false);
assert_eq!(
    c.buf(), 
    &vec![41.0f32, 94.0, 75.0, 88.0, 86.0, 208.0, 180.0, 166.0]
);