<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
lauum_recursive.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
5//
6// This file is part of <T>LAPACK.
7// <T>LAPACK is free software: you can redistribute it and/or modify it under
8// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
9
10#ifndef TLAPACK_LAUUM_RECURSIVETLAPACK_HH
11#define TLAPACK_LAUUM_RECURSIVETLAPACK_HH
12
14#include "tlapack/blas/trmm.hpp"
15
16namespace tlapack {
17
44template <TLAPACK_SMATRIX matrix_t>
46
47{
48 tlapack_check(nrows(C) == ncols(C));
49
50 using T = type_t<matrix_t>;
51 using idx_t = size_type<matrix_t>;
53 using real_t = real_type<T>;
54
55 const idx_t n = nrows(C);
56
57 // check arguments
58 tlapack_check_false(uplo != Uplo::Lower && uplo != Uplo::Upper);
59 tlapack_check_false(nrows(C) != ncols(C));
60
61 // Quick return
62 if (n <= 0) return 0;
63
64 idx_t n0 = n / 2;
65
66 // 1-by-1 case for recursion
67 if (n == 1) {
68 real_t rC00 = real(C(0, 0));
69 real_t iC00 = imag(C(0, 0));
70 C(0, 0) = rC00 * rC00 + iC00 * iC00;
71 }
72 else {
73 if (uplo == Uplo::Lower) {
74 // Upper computes U * U_hermitian
75 auto C00 = slice(C, range(0, n0), range(0, n0));
76 auto C10 = slice(C, range(n0, n), range(0, n0));
77 auto C11 = slice(C, range(n0, n), range(n0, n));
78
82 C10);
84 }
85 else {
86 // Lower computes L_hermitian * L
87 auto C00 = slice(C, range(0, n0), range(0, n0));
88 auto C01 = slice(C, range(0, n0), range(n0, n));
89 auto C11 = slice(C, range(n0, n), range(n0, n));
90
94 C01);
96 }
97 }
98
99 return 0;
100}
101
102} // namespace tlapack
103
104#endif // TLAPACK_LAUUM_RECURSIVETLAPACK_HH
constexpr internal::LowerTriangle LOWER_TRIANGLE
Lower Triangle access.
Definition types.hpp:183
constexpr internal::UpperTriangle UPPER_TRIANGLE
Upper Triangle access.
Definition types.hpp:181
constexpr internal::RightSide RIGHT_SIDE
right side
Definition types.hpp:291
constexpr internal::NonUnitDiagonal NON_UNIT_DIAG
The main diagonal is not assumed to consist of 1's.
Definition types.hpp:215
constexpr internal::ConjTranspose CONJ_TRANS
conjugate transpose
Definition types.hpp:259
Uplo
Definition types.hpp:45
constexpr internal::NoTranspose NO_TRANS
no transpose
Definition types.hpp:255
constexpr internal::LeftSide LEFT_SIDE
left side
Definition types.hpp:289
constexpr real_type< T > real(const T &x) noexcept
Extends std::real() to real datatypes.
Definition utils.hpp:71
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
void herk(Uplo uplo, Op trans, const alpha_t &alpha, const matrixA_t &A, const beta_t &beta, matrixC_t &C)
Hermitian rank-k update:
Definition herk.hpp:68
void trmm(Side side, Uplo uplo, Op trans, Diag diag, const alpha_t &alpha, const matrixA_t &A, matrixB_t &B)
Triangular matrix-matrix multiply:
Definition trmm.hpp:72
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
int lauum_recursive(const Uplo &uplo, matrix_t &C)
LAUUM is a specific type of inplace HERK.
Definition lauum_recursive.hpp:45
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