Performs a matrix multiplication by using the BLAS implementation that is linked with the binary. The complexity and performance of the operation depends on that implemenation. On failure the function returns None. # Example ``` # #[macro_use] extern crate rustml; use rustml::*; # fn main() { let a = mat![1.0f32, 2.0; 3.0, 4.0]; let b = mat![4.0f32, 2.0; 5.0, 9.0]; let c = (a * b).unwrap(); as
(self, rhs: Matrix<f64>)
| 865 | /// # } |
| 866 | /// ``` |
| 867 | fn mul(self, rhs: Matrix<f64>) -> Self::Output { |
| 868 | |
| 869 | if self.cols() != rhs.rows() { |
| 870 | return None; |
| 871 | } |
| 872 | |
| 873 | // TODO handling of NaN and stuff like this |
| 874 | let c = Matrix::fill(0.0, self.rows(), rhs.cols()); |
| 875 | unsafe { |
| 876 | cblas_dgemm(Order::RowMajor, Transpose::NoTrans, Transpose::NoTrans, |
| 877 | self.rows() as c_int, |
| 878 | rhs.cols() as c_int, |
| 879 | self.cols() as c_int, |
| 880 | 1.0 as c_double, |
| 881 | self.data.as_ptr() as *const c_double, |
| 882 | self.lead_dim() as c_int, |
| 883 | rhs.data.as_ptr() as *const c_double, |
| 884 | rhs.lead_dim() as c_int, |
| 885 | 0.0 as c_double, |
| 886 | c.data.as_ptr() as *mut c_double, |
| 887 | c.lead_dim() as c_int |
| 888 | ) |
| 889 | } |
| 890 | Some(c) |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | // TODO test |