/// <summary> /// Computes the product of square metrices X = AB /// </summary> /// <param name="A">The left matrix</param> /// <param name="B">The right matrix</param> /// <param name="X">The target matrix</param> /// <param name="N">The number of columns in B and C</param> public static ref Matrix256 <N, double> gemm <N>(Matrix256 <N, double> A, Matrix256 <N, double> B, ref Matrix256 <N, double> X) where N : unmanaged, ITypeNat { var n = nat32i <N>(); var ld = n; CBLAS.cblas_dgemm(RowMajor, NoTranspose, NoTranspose, n, n, n, 1, ref head(A), ld, ref head(B), ld, 0, ref head(X), ld); return(ref X); }
/// <summary> /// Computes the product of square metrices X = AB /// </summary> /// <param name="A">The left matrix</param> /// <param name="B">The right matrix</param> /// <param name="X">The target matrix</param> /// <param name="N">The number of columns in B and C</param> public static ref BlockMatrix <N, double> gemm <N>(BlockMatrix <N, double> A, BlockMatrix <N, double> B, ref BlockMatrix <N, double> X) where N : ITypeNat, new() { var n = nati <N>(); var ld = n; CBLAS.cblas_dgemm(RowMajor, NoTranspose, NoTranspose, n, n, n, 1, ref head(A), ld, ref head(B), ld, 0, ref head(X), ld); return(ref X); }
/// <summary> /// Populates a target matrix with the product of the operands /// </summary> /// <param name="A">The left matrix</param> /// <param name="B">The right matrix</param> /// <param name="M">The number of rows in A and C</param> /// <param name="N">The number of columns in B and C</param> /// <param name="K">The number of columns in A and rows in B</param> public static ref Matrix256 <M, N, double> gemm <M, K, N>(Matrix256 <M, K, double> A, Matrix256 <K, N, double> B, ref Matrix256 <M, N, double> X) where M : unmanaged, ITypeNat where K : unmanaged, ITypeNat where N : unmanaged, ITypeNat { var m = nat32i <M>(); var k = nat32i <K>(); var n = nat32i <N>(); var lda = k; var ldb = n; var ldx = n; CBLAS.cblas_dgemm(RowMajor, NoTranspose, NoTranspose, m, n, k, 1d, ref head(A), lda, ref head(B), ldb, 0, ref head(X), ldx); return(ref X); }
/// <summary> /// Populates a target matrix with the product of the operands /// </summary> /// <param name="A">The left matrix</param> /// <param name="B">The right matrix</param> /// <param name="M">The number of rows in A and C</param> /// <param name="N">The number of columns in B and C</param> /// <param name="K">The number of columns in A and rows in B</param> public static ref BlockMatrix <M, N, double> gemm <M, K, N>(BlockMatrix <M, K, double> A, BlockMatrix <K, N, double> B, ref BlockMatrix <M, N, double> X) where M : ITypeNat, new() where K : ITypeNat, new() where N : ITypeNat, new() { var m = nati <M>(); var k = nati <K>(); var n = nati <N>(); var lda = k; var ldb = n; var ldx = n; CBLAS.cblas_dgemm(RowMajor, NoTranspose, NoTranspose, m, n, k, 1d, ref head(A), lda, ref head(B), ldb, 0, ref head(X), ldx); return(ref X); }