pub unsafe fn mmul2_apple(
        &self,
        other: &Matrix,
        transpose_self: u8,
        transpose_other: u8,
    ) -> Result<Matrix, String> {
        // TODO check if the matrices can be multiplied
        let transpose_a = transpose_self;
        let transpose_b = transpose_other;
        let mat_a = &self.data;
        let mat_b = &other.data;
        let alpha = 1.;
        let beta = 1.;

        // m is nrows of Op(A) and nrows matrix C
        let m = if transpose_self == TRANSPOSE {
            // We're transposing self aka the a matrix
            self.ncols as i32
        } else {
            self.nrows as i32
        };

        // n is ncols of Op(b) and ncols of matrix c
        let n = if transpose_other == TRANSPOSE {
            other.nrows as i32
        } else {
            other.ncols as i32
        };

        // k is ncols of op(A), and nrows of op(B)
        let k = if transpose_self == TRANSPOSE && transpose_other == TRANSPOSE {
            let ncols_op_a = self.nrows; // cos it's transposed
            let nrows_op_b = other.ncols; // cos it's transposed
            assert_eq!(ncols_op_a, nrows_op_b);

            ncols_op_a as i32
        } else if transpose_self == TRANSPOSE {
            let ncols_op_a = self.nrows; // cos it's transposed
            let nrows_op_b = other.nrows; // cos it's NOT transposed
            assert_eq!(ncols_op_a, nrows_op_b);

            ncols_op_a as i32
        } else if transpose_other == TRANSPOSE {
            let ncols_op_a = self.ncols; // cos it's NOT transposed
            let nrows_op_b = other.ncols; // cos it's transposed
            assert_eq!(ncols_op_a, nrows_op_b);

            ncols_op_a as i32
        } else {
            let ncols_op_a = self.ncols; // cos it's NOT transposed
            let nrows_op_b = other.nrows; // cos it's NOT transposed
            assert_eq!(ncols_op_a, nrows_op_b);

            ncols_op_a as i32
        };

        let c_nrows = m;
        let c_ncols = n;

        let mut mat_c = vec![0.; (c_nrows * c_ncols) as usize];

        let lda = if transpose_self == NO_TRANSPOSE {
            self.nrows as i32
        } else {
            self.ncols as i32
        };

        let ldb = if transpose_other == NO_TRANSPOSE {
            other.nrows as i32
        } else {
            other.ncols as i32
        };

        let ldc = if transpose_self == NO_TRANSPOSE {
            self.nrows as i32
        } else {
            self.ncols as i32
        };

        // let lda = self.nrows as i32;
        // let ldb = other.nrows as i32;
        // let ldc = self.nrows as i32;

        // DGEMM: C = alpha * op(A) * op(B) + beta * C.  Note: C gets overwritten with this.

        dgemm(
            transpose_a,
            transpose_b,
            m,
            n,
            k,
            alpha,
            mat_a,
            lda,
            mat_b,
            ldb,
            beta,
            &mut mat_c,
            ldc,
        );

        Matrix::from_data(c_nrows as usize, c_ncols as usize, mat_c)
    }
// See the above comment about this string of identical functions with different names.  It's
// for profiling but eventually you will need to get rid of them.
See the above comment about this string of identical functions with different names.  It's
for profiling but eventually you will need to get rid of them.
See the above comment about this string of identical functions with different names . It ' s for profiling but eventually you will need to get rid of them .
pub unsafe fn mmul2_apple(
        &self,
        other: &Matrix,
        transpose_self: u8,
        transpose_other: u8,
    ) -> Result<Matrix, String> {
        // TODO check if the matrices can be multiplied
        let transpose_a = transpose_self;
        let transpose_b = transpose_other;
        let mat_a = &self.data;
        let mat_b = &other.data;
        let alpha = 1.;
        let beta = 1.;
        // m is nrows of Op(A) and nrows matrix C
        let m = if transpose_self == TRANSPOSE {
            // We're transposing self aka the a matrix
            self.ncols as i32
        } else {
            self.nrows as i32
        };
        // n is ncols of Op(b) and ncols of matrix c
        let n = if transpose_other == TRANSPOSE {
            other.nrows as i32
        } else {
            other.ncols as i32
        };
        // k is ncols of op(A), and nrows of op(B)
        let k = if transpose_self == TRANSPOSE && transpose_other == TRANSPOSE {
            let ncols_op_a = self.nrows; // cos it's transposed
            let nrows_op_b = other.ncols; // cos it's transposed
            assert_eq!(ncols_op_a, nrows_op_b);
            ncols_op_a as i32
        } else if transpose_self == TRANSPOSE {
            let ncols_op_a = self.nrows; // cos it's transposed
            let nrows_op_b = other.nrows; // cos it's NOT transposed
            assert_eq!(ncols_op_a, nrows_op_b);
            ncols_op_a as i32
        } else if transpose_other == TRANSPOSE {
            let ncols_op_a = self.ncols; // cos it's NOT transposed
            let nrows_op_b = other.ncols; // cos it's transposed
            assert_eq!(ncols_op_a, nrows_op_b);
            ncols_op_a as i32
        } else {
            let ncols_op_a = self.ncols; // cos it's NOT transposed
            let nrows_op_b = other.nrows; // cos it's NOT transposed
            assert_eq!(ncols_op_a, nrows_op_b);
            ncols_op_a as i32
        };
        let c_nrows = m;
        let c_ncols = n;
        let mut mat_c = vec![0.; (c_nrows * c_ncols) as usize];
        let lda = if transpose_self == NO_TRANSPOSE {
            self.nrows as i32
        } else {
            self.ncols as i32
        };
        let ldb = if transpose_other == NO_TRANSPOSE {
            other.nrows as i32
        } else {
            other.ncols as i32
        };
        let ldc = if transpose_self == NO_TRANSPOSE {
            self.nrows as i32
        } else {
            self.ncols as i32
        };
        // let lda = self.nrows as i32;
        // let ldb = other.nrows as i32;
        // let ldc = self.nrows as i32;
        // DGEMM: C = alpha * op(A) * op(B) + beta * C.  Note: C gets overwritten with this.
        dgemm(
            transpose_a,
            transpose_b,
            m,
            n,
            k,
            alpha,
            mat_a,
            lda,
            mat_b,
            ldb,
            beta,
            &mut mat_c,
            ldc,
        );
        Matrix::from_data(c_nrows as usize, c_ncols as usize, mat_c)
    }
pub unsafe fn mmul2_apple ( & self , other : & Matrix , transpose_self : u8 , transpose_other : u8 , ) -> Result < Matrix , String > { // TODO check if the matrices can be multiplied let transpose_a = transpose_self ; let transpose_b = transpose_other ; let mat_a = & self . data ; let mat_b = & other . data ; let alpha = 1. ; let beta = 1. ; // m is nrows of Op(A) and nrows matrix C let m = if transpose_self == TRANSPOSE { // We're transposing self aka the a matrix self . ncols as i32 } else { self . nrows as i32 } ; // n is ncols of Op(b) and ncols of matrix c let n = if transpose_other == TRANSPOSE { other . nrows as i32 } else { other . ncols as i32 } ; // k is ncols of op(A), and nrows of op(B) let k = if transpose_self == TRANSPOSE && transpose_other == TRANSPOSE { let ncols_op_a = self . nrows ; // cos it's transposed let nrows_op_b = other . ncols ; // cos it's transposed assert_eq ! ( ncols_op_a nrows_op_b ) ; ncols_op_a as i32 } else if transpose_self == TRANSPOSE { let ncols_op_a = self . nrows ; // cos it's transposed let nrows_op_b = other . nrows ; // cos it's NOT transposed assert_eq ! ( ncols_op_a nrows_op_b ) ; ncols_op_a as i32 } else if transpose_other == TRANSPOSE { let ncols_op_a = self . ncols ; // cos it's NOT transposed let nrows_op_b = other . ncols ; // cos it's transposed assert_eq ! ( ncols_op_a nrows_op_b ) ; ncols_op_a as i32 } else { let ncols_op_a = self . ncols ; // cos it's NOT transposed let nrows_op_b = other . nrows ; // cos it's NOT transposed assert_eq ! ( ncols_op_a nrows_op_b ) ; ncols_op_a as i32 } ; let c_nrows = m ; let c_ncols = n ; let mut mat_c = vec ! [ 0. ( c_nrows c_ncols ) as usize ] ; let lda = if transpose_self == NO_TRANSPOSE { self . nrows as i32 } else { self . ncols as i32 } ; let ldb = if transpose_other == NO_TRANSPOSE { other . nrows as i32 } else { other . ncols as i32 } ; let ldc = if transpose_self == NO_TRANSPOSE { self . nrows as i32 } else { self . ncols as i32 } ; // let lda = self.nrows as i32; // let ldb = other.nrows as i32; // let ldc = self.nrows as i32; // DGEMM: C = alpha * op(A) * op(B) + beta * C.  Note: C gets overwritten with this. dgemm ( transpose_a , transpose_b , m , n , k , alpha , mat_a , lda , mat_b , ldb , beta , & mut mat_c , ldc , ) ; Matrix :: from_data ( c_nrows as usize , c_ncols as usize , mat_c ) }
See the above comment about this string of identical functions with different names.
See the above comment about this string of identical functions with different names .
&self
other
&Matrix
transpose_self
u8
transpose_other
u8