<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
lapy2.hpp
Go to the documentation of this file.
1
5//
6// Copyright (c) 2025, University of Colorado Denver. All rights reserved.
7//
8// This file is part of <T>LAPACK.
9// <T>LAPACK is free software: you can redistribute it and/or modify it under
10// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
11
12#ifndef TLAPACK_LAPY2_HH
13#define TLAPACK_LAPY2_HH
14
16
17namespace tlapack {
18
28template <TLAPACK_REAL TX,
29 TLAPACK_REAL TY,
30 enable_if_t<(
31 /* Requires: */
32 is_real<TX> && is_real<TY>),
33 int> = 0>
34real_type<TX, TY> lapy2(const TX& x, const TY& y)
35{
36 // using
38
39 // constants
40 const real_t one(1);
41 const real_t zero(0);
42 const TX xabs = abs(x);
43 const TY yabs = abs(y);
44
45 real_t w, z;
46 if (xabs > yabs) {
47 w = xabs;
48 z = yabs;
49 }
50 else {
51 w = yabs;
52 z = xabs;
53 }
54
55 return (z == zero) ? w : w * sqrt(one + (z / w) * (z / w));
56}
57
58} // namespace tlapack
59
60#endif // TLAPACK_LAPY2_HH
#define TLAPACK_REAL
Macro for tlapack::concepts::Real compatible with C++17.
Definition concepts.hpp:918
real_type< TX, TY > lapy2(const TX &x, const TY &y)
Finds , taking care not to cause unnecessary overflow.
Definition lapy2.hpp:34
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