1 /* blas/source_symm_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.
25 if (alpha == 0.0 && beta == 1.0)
28 if (Order == CblasRowMajor) {
36 uplo = (Uplo == CblasUpper) ? CblasLower : CblasUpper;
37 side = (Side == CblasLeft) ? CblasRight : CblasLeft;
40 /* form y := beta*y */
42 for (i = 0; i < n1; i++) {
43 for (j = 0; j < n2; j++) {
47 } else if (beta != 1.0) {
48 for (i = 0; i < n1; i++) {
49 for (j = 0; j < n2; j++) {
50 C[ldc * i + j] *= beta;
58 if (side == CblasLeft && uplo == CblasUpper) {
60 /* form C := alpha*A*B + C */
62 for (i = 0; i < n1; i++) {
63 for (j = 0; j < n2; j++) {
64 const BASE temp1 = alpha * B[ldb * i + j];
66 C[i * ldc + j] += temp1 * A[i * lda + i];
67 for (k = i + 1; k < n1; k++) {
68 const BASE Aik = A[i * lda + k];
69 C[k * ldc + j] += Aik * temp1;
70 temp2 += Aik * B[ldb * k + j];
72 C[i * ldc + j] += alpha * temp2;
76 } else if (side == CblasLeft && uplo == CblasLower) {
78 /* form C := alpha*A*B + C */
80 for (i = 0; i < n1; i++) {
81 for (j = 0; j < n2; j++) {
82 const BASE temp1 = alpha * B[ldb * i + j];
84 for (k = 0; k < i; k++) {
85 const BASE Aik = A[i * lda + k];
86 C[k * ldc + j] += Aik * temp1;
87 temp2 += Aik * B[ldb * k + j];
89 C[i * ldc + j] += temp1 * A[i * lda + i] + alpha * temp2;
93 } else if (side == CblasRight && uplo == CblasUpper) {
95 /* form C := alpha*B*A + C */
97 for (i = 0; i < n1; i++) {
98 for (j = 0; j < n2; j++) {
99 const BASE temp1 = alpha * B[ldb * i + j];
101 C[i * ldc + j] += temp1 * A[j * lda + j];
102 for (k = j + 1; k < n2; k++) {
103 const BASE Ajk = A[j * lda + k];
104 C[i * ldc + k] += temp1 * Ajk;
105 temp2 += B[ldb * i + k] * Ajk;
107 C[i * ldc + j] += alpha * temp2;
111 } else if (side == CblasRight && uplo == CblasLower) {
113 /* form C := alpha*B*A + C */
115 for (i = 0; i < n1; i++) {
116 for (j = 0; j < n2; j++) {
117 const BASE temp1 = alpha * B[ldb * i + j];
119 for (k = 0; k < j; k++) {
120 const BASE Ajk = A[j * lda + k];
121 C[i * ldc + k] += temp1 * Ajk;
122 temp2 += B[ldb * i + k] * Ajk;
124 C[i * ldc + j] += temp1 * A[j * lda + j] + alpha * temp2;
129 BLAS_ERROR("unrecognized operation");