25namespace internal::dense_matrix_product {
43 const std::string shape =
44 std::to_string(matrix.
rows()) +
" x " + std::to_string(matrix.
columns());
64 const auto [rows, inner] = shape_of(left_operation, left);
65 const auto [inner_of_right, columns] = shape_of(right_operation, right);
66 if (inner != inner_of_right) {
67 throw std::invalid_argument(
"multiply: " + describe(left_operation, left) +
68 " matrix cannot multiply " + describe(right_operation, right) +
69 " one; the inner dimensions are " + std::to_string(inner) +
70 " and " + std::to_string(inner_of_right));
72 if (result.
rows() != rows || result.
columns() != columns) {
73 throw std::invalid_argument(
"multiply: the product is " + std::to_string(rows) +
" x " +
74 std::to_string(columns) +
" but the result given is " +
75 std::to_string(result.
rows()) +
" x " +
76 std::to_string(result.
columns()));
78 if (rows == 0 || columns == 0 || inner == 0) {
82 const int leading_left = left.
rows();
83 const int leading_right = right.
rows();
84 const int leading_result = result.
rows();
108 const auto [rows, inner] = shape_of(left_operation, left);
109 const auto [inner_of_right, columns] = shape_of(right_operation, right);
111 (void)inner_of_right;
113 multiply_add(left_operation, left, right_operation, right, alpha, result);
T * data()
The column-major buffer: with rows() it is the (pointer, leading dimension) BLAS takes.
void zgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, const std::complex< double > *alpha, const std::complex< double > *a, const int *lda, const std::complex< double > *b, const int *ldb, const std::complex< double > *beta, std::complex< double > *c, const int *ldc)
OperandShape shape_of(MatrixOperation operation, const DenseMatrix< Complex > &matrix)
std::string describe(MatrixOperation operation, const DenseMatrix< Complex > &matrix)
void multiply_add(MatrixOperation left_operation, const DenseMatrix< Complex > &left, MatrixOperation right_operation, const DenseMatrix< Complex > &right, Complex alpha, DenseMatrix< Complex > &result)
const char * blas_transpose_flag(MatrixOperation operation)
The letter BLAS takes for the operation.
std::complex< double > Complex
DenseMatrix< Complex > multiply(MatrixOperation left_operation, const DenseMatrix< Complex > &left, MatrixOperation right_operation, const DenseMatrix< Complex > &right, Complex alpha=Complex(1.0, 0.0))
alpha * op(left) * op(right), as a new matrix of the product's shape.
The rows and columns of op(matrix).