1 /* blas/source_gemm_r.h
3 * Copyright (C) 2001, 2007 Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 if (alpha == 0.0 && beta == 1.0)
30 if (Order == CblasRowMajor) {
35 TransF = (TransA == CblasConjTrans) ? CblasTrans : TransA;
38 TransG = (TransB == CblasConjTrans) ? CblasTrans : TransB;
44 TransF = (TransB == CblasConjTrans) ? CblasTrans : TransB;
47 TransG = (TransA == CblasConjTrans) ? CblasTrans : TransA;
50 /* form y := beta*y */
52 for (i = 0; i < n1; i++) {
53 for (j = 0; j < n2; j++) {
57 } else if (beta != 1.0) {
58 for (i = 0; i < n1; i++) {
59 for (j = 0; j < n2; j++) {
60 C[ldc * i + j] *= beta;
68 if (TransF == CblasNoTrans && TransG == CblasNoTrans) {
70 /* form C := alpha*A*B + C */
72 for (k = 0; k < K; k++) {
73 for (i = 0; i < n1; i++) {
74 const BASE temp = alpha * F[ldf * i + k];
76 for (j = 0; j < n2; j++) {
77 C[ldc * i + j] += temp * G[ldg * k + j];
83 } else if (TransF == CblasNoTrans && TransG == CblasTrans) {
85 /* form C := alpha*A*B' + C */
87 for (i = 0; i < n1; i++) {
88 for (j = 0; j < n2; j++) {
90 for (k = 0; k < K; k++) {
91 temp += F[ldf * i + k] * G[ldg * j + k];
93 C[ldc * i + j] += alpha * temp;
97 } else if (TransF == CblasTrans && TransG == CblasNoTrans) {
99 for (k = 0; k < K; k++) {
100 for (i = 0; i < n1; i++) {
101 const BASE temp = alpha * F[ldf * k + i];
103 for (j = 0; j < n2; j++) {
104 C[ldc * i + j] += temp * G[ldg * k + j];
110 } else if (TransF == CblasTrans && TransG == CblasTrans) {
112 for (i = 0; i < n1; i++) {
113 for (j = 0; j < n2; j++) {
115 for (k = 0; k < K; k++) {
116 temp += F[ldf * k + i] * G[ldg * j + k];
118 C[ldc * i + j] += alpha * temp;
123 BLAS_ERROR("unrecognized operation");