3#ifndef pRC_ALGORITHMS_JACOBI_ROTATION_H
4#define pRC_ALGORITHMS_JACOBI_ROTATION_H
19 "JacobiRotation<T>: T has to be of type Value or Complex.");
22 template<
class R1,
class R2,
class R3,
class R = Common<R1, R2, R3>,
23 If<IsConvertible<R, T>> = 0>
27 r.makeJacobi(
x,
y,
z);
31 template<
class R1,
class R2,
class R = Common<R1, R2>,
32 If<IsConvertible<R, T>> = 0>
54 template<
class X,
class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
55 If<IsConvertible<
typename R::Type, T>> = 0,
56 If<IsSatisfied<(
typename R::Dimension() == 2)>> = 0>
69 "JacobiRotation input 2x2 matrix is not self-adjoint.");
80 template<
class X,
class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
81 If<IsConvertible<
typename R::Type, T>> = 0,
82 If<IsSatisfied<(
typename R::Dimension() == 1)>> = 0>
91 template<
class R, If<IsConvertible<R, T>> = 0>
98 template<
class R, If<IsConvertible<R, T>> = 0>
106 constexpr decltype(
auto)
c() &&
111 constexpr decltype(
auto)
c()
const &&
116 constexpr auto &
c() &
126 constexpr decltype(
auto)
s() &&
131 constexpr decltype(
auto)
s()
const &&
136 constexpr auto &
s() &
147 template<
class R1,
class R2,
class R3,
class R = Common<R1, R2, R3>,
148 If<IsConvertible<R, T>> = 0>
149 constexpr auto makeJacobi(
R1 const &
x,
R2 const &
y,
R3 const &
z)
162 auto const t = [&
beta, &
w]()
184 template<
class R1,
class R2,
class R = Common<R1, R2>,
185 If<IsConvertible<R, T>> = 0>
186 constexpr auto makeGivens(
R1 const &
x,
R2 const &
y)
207 if(
abs(
x) <= NumericLimits<typename R::Value>::min())
221 auto const xS =
x /
x1;
223 auto const yS =
y /
x1;
230 if(
x.real() <
zero())
238 auto const xS =
x /
y1;
240 auto const yS =
y /
y1;
248 if(
x.real() <
zero())
259 auto const t =
y /
x;
266 auto const t =
x /
y;
280 template<
class T, Size M, Size N>
284 template<
class V,
class T, Size M, Size N>
288 template<
class T, Size N>
292 template<
class V,
class T, Size N>
296 template<
class TA,
class TB>
300 return a.
c() == b.
c() && a.
s() == b.
s();
303 template<
class TA,
class TB>
310 template<
class TA,
class TB>
330 template<
class T,
class X,
class R = RemoveReference<X>,
331 If<Any<All<IsTensor<R>, Not<IsReference<X>>>,
332 All<IsTensorish<R>, IsAssignable<X>>>> = 0,
333 If<IsSatisfied<(
typename R::Dimension() == 2)>> = 0>
341 [&
r, &
x, &
y](
auto const i)
343 auto const tX =
x(
i);
344 auto const tY =
y(
i);
352 template<
class T,
class X,
class R = RemoveReference<X>,
353 If<Any<All<IsTensor<R>, Not<IsReference<X>>>,
354 All<IsTensorish<R>, IsAssignable<X>>>> = 0,
355 If<IsSatisfied<(
typename R::Dimension() == 2)>> = 0>
356 static inline constexpr decltype(
auto)
apply(
X &&m,
363 [&
r, &
x, &
y](
auto const i)
365 auto const tX =
x(
i);
366 auto const tY =
y(
i);
374 template<
class T,
class X,
class R = RemoveReference<X>,
375 If<Any<All<IsTensor<R>, Not<IsReference<X>>>,
376 All<IsTensorish<R>, IsAssignable<X>>>> = 0,
377 If<IsSatisfied<(
typename R::Dimension() == 1)>> = 0>
381 auto const tX =
v(
p);
382 auto const tY =
v(
q);
390 template<
class T,
class X,
class R = RemoveReference<X>,
391 If<Any<All<IsTensor<R>, Not<IsReference<X>>>,
392 All<IsTensorish<R>, IsAssignable<X>>>> = 0,
393 If<IsSatisfied<(
typename R::Dimension() == 1)>> = 0>
394 static inline constexpr decltype(
auto)
apply(
X &&
v,
397 auto const tX =
v(
p);
398 auto const tY =
v(
q);
Definition jacobi_rotation.hpp:17
constexpr JacobiRotation(X &&a, Index const p, Index const q)
Definition jacobi_rotation.hpp:57
constexpr JacobiRotation()=default
constexpr JacobiRotation(JacobiRotation< R > const &other)
Definition jacobi_rotation.hpp:92
constexpr JacobiRotation & operator=(JacobiRotation const &) &=default
constexpr JacobiRotation & operator=(JacobiRotation &&) &=default
static constexpr auto MakeJacobi(R1 const &x, R2 const &y, R3 const &z)
Definition jacobi_rotation.hpp:24
constexpr auto & operator=(JacobiRotation< R > const &rhs) &
Definition jacobi_rotation.hpp:99
constexpr auto & c() &
Definition jacobi_rotation.hpp:116
constexpr decltype(auto) c() &&
Definition jacobi_rotation.hpp:106
~JacobiRotation()=default
constexpr JacobiRotation(JacobiRotation &&)=default
static constexpr auto MakeGivens(R1 const &x, R2 const &y)
Definition jacobi_rotation.hpp:33
constexpr decltype(auto) s() &&
Definition jacobi_rotation.hpp:126
constexpr decltype(auto) s() const &&
Definition jacobi_rotation.hpp:131
constexpr JacobiRotation(JacobiRotation const &)=default
constexpr JacobiRotation(T const &c, T const &s)
Definition jacobi_rotation.hpp:48
constexpr auto & s() const &
Definition jacobi_rotation.hpp:141
constexpr auto & c() const &
Definition jacobi_rotation.hpp:121
constexpr decltype(auto) c() const &&
Definition jacobi_rotation.hpp:111
constexpr auto & s() &
Definition jacobi_rotation.hpp:136
Definition sequence.hpp:56
Definition type_traits.hpp:32
static void error(Xs &&...args)
Definition log.hpp:14
Definition cholesky.hpp:18
static constexpr auto mean(Xs &&...args)
Definition mean.hpp:15
static constexpr decltype(auto) apply(JacobiRotation< T > const &r, X &&m, Index const p, Index const q)
Definition jacobi_rotation.hpp:334
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
static constexpr auto rcp(Complex< T > const &b)
Definition rcp.hpp:13
static constexpr decltype(auto) real(X &&a)
Definition real.hpp:11
static constexpr auto zero()
Definition zero.hpp:12
JacobiRotation(Tensor< T, M, N > const &a, Index const p, Index const q) -> JacobiRotation< T >
static constexpr auto operator*(JacobiRotation< TA > const &a, JacobiRotation< TB > const &b)
Definition jacobi_rotation.hpp:311
static constexpr auto sign(Complex< T > const &a)
Definition sign.hpp:13
static constexpr auto transpose(JacobiRotation< T > const &a)
Definition jacobi_rotation.hpp:319
static constexpr auto isSelfAdjoint(X &&a, TT const &tolerance=NumericLimits< TT >::tolerance())
Definition is_self_adjoint.hpp:18
static constexpr auto adjoint(JacobiRotation< T > const &a)
Definition jacobi_rotation.hpp:325
static constexpr auto abs(Complex< T > const &a)
Definition abs.hpp:12
static constexpr auto operator!=(JacobiRotation< TA > const &a, JacobiRotation< TB > const &b)
Definition jacobi_rotation.hpp:304
constexpr auto cDebugLevel
Definition config.hpp:46
static constexpr auto operator==(JacobiRotation< TA > const &a, JacobiRotation< TB > const &b)
Definition jacobi_rotation.hpp:297
static constexpr auto sqrt(Complex< T > const &a)
Definition sqrt.hpp:12
static constexpr auto conj(Complex< T > const &a)
Definition conj.hpp:11
static constexpr auto identity()
Definition identity.hpp:12
Definition type_traits.hpp:15