<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
symm.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2017-2021, University of Tennessee. All rights reserved.
5// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
6//
7// This file is part of <T>LAPACK.
8// <T>LAPACK is free software: you can redistribute it and/or modify it under
9// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
10
11#ifndef TLAPACK_LEGACY_SYMM_HH
12#define TLAPACK_LEGACY_SYMM_HH
13
14#include "tlapack/blas/symm.hpp"
17
18namespace tlapack {
19namespace legacy {
20
83 template <typename TA, typename TB, typename TC>
84 void symm(Layout layout,
85 Side side,
86 Uplo uplo,
87 idx_t m,
88 idx_t n,
90 TA const* A,
91 idx_t lda,
92 TB const* B,
93 idx_t ldb,
95 TC* C,
96 idx_t ldc)
97 {
98 using internal::create_matrix;
100
101 // check arguments
102 tlapack_check_false(layout != Layout::ColMajor &&
103 layout != Layout::RowMajor);
104 tlapack_check_false(side != Side::Left && side != Side::Right);
105 tlapack_check_false(uplo != Uplo::Lower && uplo != Uplo::Upper &&
106 uplo != Uplo::General);
107 tlapack_check_false(m < 0);
108 tlapack_check_false(n < 0);
109 tlapack_check_false(lda < ((side == Side::Left) ? m : n));
110 tlapack_check_false(ldb < ((layout == Layout::RowMajor) ? n : m));
111 tlapack_check_false(ldc < ((layout == Layout::RowMajor) ? n : m));
112
113 // quick return
114 if (m == 0 || n == 0 ||
115 ((alpha == scalar_t(0)) && (beta == scalar_t(1))))
116 return;
117
118 // adapt if row major
119 if (layout == Layout::RowMajor) {
120 side = (side == Side::Left) ? Side::Right : Side::Left;
121 if (uplo == Uplo::Lower)
122 uplo = Uplo::Upper;
123 else if (uplo == Uplo::Upper)
124 uplo = Uplo::Lower;
125 std::swap(m, n);
126 }
127
128 // Matrix views
129 const auto A_ = (side == Side::Left)
130 ? create_matrix<TA>((TA*)A, m, m, lda)
131 : create_matrix<TA>((TA*)A, n, n, lda);
132 const auto B_ = create_matrix<TB>((TB*)B, m, n, ldb);
133 auto C_ = create_matrix<TC>(C, m, n, ldc);
134
135 if (alpha == scalar_t(0)) {
136 if (beta == scalar_t(0)) {
137 for (idx_t j = 0; j < n; ++j)
138 for (idx_t i = 0; i < m; ++i)
139 C_(i, j) = TC(0);
140 }
141 else {
142 for (idx_t j = 0; j < n; ++j)
143 for (idx_t i = 0; i < m; ++i)
144 C_(i, j) *= beta;
145 }
146 }
147 else {
148 if (beta == scalar_t(0))
149 symm(side, uplo, alpha, A_, B_, C_);
150 else
151 symm(side, uplo, alpha, A_, B_, beta, C_);
152 }
153 }
154
155} // namespace legacy
156} // namespace tlapack
157
158#endif // #ifndef TLAPACK_LEGACY_SYMM_HH
constexpr Layout layout
Layout of a matrix or vector.
Definition arrayTraits.hpp:232
Side
Definition types.hpp:266
Uplo
Definition types.hpp:45
Layout
Definition types.hpp:24
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
void symm(Layout layout, Side side, Uplo uplo, idx_t m, idx_t n, scalar_type< TA, TB, TC > alpha, TA const *A, idx_t lda, TB const *B, idx_t ldb, scalar_type< TA, TB, TC > beta, TC *C, idx_t ldc)
Symmetric matrix-matrix multiply:
Definition symm.hpp:84
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113