MCPcopy Create free account
hub / github.com/Axect/Peroxide / cgemm

Function cgemm

src/complex/matrix.rs:2558–2596  ·  view source on GitHub ↗

GEMM wrapper for Matrixmultiply # Examples ```rust #[macro_use] extern crate peroxide; use peroxide::fuga::*; use peroxide::complex::matrix::*; let a = ml_cmatrix("1.0+1.0i 2.0+2.0i; 0.0+0.0i 1.0+1.0i"); let b = ml_cmatrix("1.0+1.0i 0.0+0.0i; 2.0+2.0i 1.0+1.0i"); let mut c1 = ml_cmatrix("1.0+1.0i 1.0+1.0i; 1.0+1.0i 1.0+1.0i"); let mul_val = ml_cmatrix("-10.0+10.0i -4.0+4.0i; -4.0+4.0i -2.0+2.0i

(alpha: C64, a: &ComplexMatrix, b: &ComplexMatrix, beta: C64, c: &mut ComplexMatrix)

Source from the content-addressed store, hash-verified

2556/// cgemm(C64::new(1.0, 1.0), &a, &b, C64::new(0.0, 0.0), &mut c1);
2557/// assert_eq!(c1, mul_val);
2558pub fn cgemm(alpha: C64, a: &ComplexMatrix, b: &ComplexMatrix, beta: C64, c: &mut ComplexMatrix) {
2559 let m = a.row;
2560 let k = a.col;
2561 let n = b.col;
2562 let (rsa, csa) = match a.shape {
2563 Shape::Row => (a.col as isize, 1isize),
2564 Shape::Col => (1isize, a.row as isize),
2565 };
2566 let (rsb, csb) = match b.shape {
2567 Shape::Row => (b.col as isize, 1isize),
2568 Shape::Col => (1isize, b.row as isize),
2569 };
2570 let (rsc, csc) = match c.shape {
2571 Shape::Row => (c.col as isize, 1isize),
2572 Shape::Col => (1isize, c.row as isize),
2573 };
2574
2575 unsafe {
2576 matrixmultiply::zgemm(
2577 // Requires crate feature "cgemm"
2578 CGemmOption::Standard,
2579 CGemmOption::Standard,
2580 m,
2581 k,
2582 n,
2583 [alpha.re, alpha.im],
2584 a.ptr() as *const _,
2585 rsa,
2586 csa,
2587 b.ptr() as *const _,
2588 rsb,
2589 csb,
2590 [beta.re, beta.im],
2591 c.mut_ptr() as *mut _,
2592 rsc,
2593 csc,
2594 )
2595 }
2596}
2597
2598/// General Matrix-Vector multiplication
2599pub fn cgemv(alpha: C64, a: &ComplexMatrix, b: &[C64], beta: C64, c: &mut [C64]) {

Callers 1

cmatmulFunction · 0.85

Calls 2

ptrMethod · 0.45
mut_ptrMethod · 0.45

Tested by

no test coverage detected