numerics
Loading...
Searching...
No Matches
num::GivensRotation Struct Reference

Givens plane rotation: G = [c, s; -s, c]. More...

#include <small_matrix.hpp>

Public Member Functions

constexpr void apply (real &x, real &y) const noexcept
 Apply G from the left: [x; y] <- G * [x; y].
 
constexpr void apply_t (real &x, real &y) const noexcept
 Apply G^T (inverse rotation): [x; y] <- G^T * [x; y].
 
constexpr SmallMatrix< 2, 2 > as_matrix () const noexcept
 Return the 2x2 rotation matrix.
 

Static Public Member Functions

static constexpr GivensRotation from (real a, real b) noexcept
 

Public Attributes

real c
 
real s
 

Detailed Description

Givens plane rotation: G = [c, s; -s, c].

Constructed so that G * [a; b]^T = [r; 0] with r = hypot(a, b).

auto g = GivensRotation::from(h_jj, h_jj1); // zero H[j,j+1] in GMRES
g.apply(g_j, g_j1); // rotate RHS vector too
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
static constexpr GivensRotation from(real a, real b) noexcept

Definition at line 144 of file small_matrix.hpp.

Member Function Documentation

◆ apply()

constexpr void num::GivensRotation::apply ( real x,
real y 
) const
inlineconstexprnoexcept

Apply G from the left: [x; y] <- G * [x; y].

Definition at line 158 of file small_matrix.hpp.

References c, num::ipow(), and s.

◆ apply_t()

constexpr void num::GivensRotation::apply_t ( real x,
real y 
) const
inlineconstexprnoexcept

Apply G^T (inverse rotation): [x; y] <- G^T * [x; y].

Definition at line 165 of file small_matrix.hpp.

References c, num::ipow(), and s.

◆ as_matrix()

constexpr SmallMatrix< 2, 2 > num::GivensRotation::as_matrix ( ) const
inlineconstexprnoexcept

Return the 2x2 rotation matrix.

Definition at line 172 of file small_matrix.hpp.

References c, and s.

◆ from()

static constexpr GivensRotation num::GivensRotation::from ( real  a,
real  b 
)
inlinestaticconstexprnoexcept

Compute (c,s) such that G*[a;b] = [r;0], r = hypot(a,b). Stable for any (a,b) including b==0.

Definition at line 149 of file small_matrix.hpp.

References num::ipow().

Member Data Documentation

◆ c

real num::GivensRotation::c

Definition at line 145 of file small_matrix.hpp.

Referenced by apply(), apply_t(), and as_matrix().

◆ s

real num::GivensRotation::s

Definition at line 145 of file small_matrix.hpp.

Referenced by apply(), apply_t(), and as_matrix().


The documentation for this struct was generated from the following file: