MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::itl::mg Namespace Reference

Classes

class  multigrid
 Multigrid solver/preconditioner. More...

Functions

mat::compressed2D< double > make_prolongation_1d (std::size_t n_coarse)
 Builds a 1D linear interpolation prolongation matrix (coarse -> fine).
template<typename Accumulator = void, typename Value>
vec::dense_vector< Value > prolongate (const mat::compressed2D< Value > &P, const vec::dense_vector< Value > &coarse)
 Prolongation: interpolate coarse-grid vector to fine grid.
mat::compressed2D< double > make_restriction_1d (std::size_t n_fine)
 Builds a 1D full-weighting restriction matrix (fine -> coarse).
template<typename Accumulator = void, typename Value>
vec::dense_vector< Value > restrict (const mat::compressed2D< Value > &R, const vec::dense_vector< Value > &fine)
 Restriction: project fine-grid vector to coarse grid.

Function Documentation

◆ make_prolongation_1d()

mat::compressed2D< double > mtl::itl::mg::make_prolongation_1d ( std::size_t n_coarse)
inline

Builds a 1D linear interpolation prolongation matrix (coarse -> fine).

Maps a vector of size n_coarse to size n_fine = 2 * n_coarse + 1. Coarse points are copied; fine points are averaged from neighbors.

◆ make_restriction_1d()

mat::compressed2D< double > mtl::itl::mg::make_restriction_1d ( std::size_t n_fine)
inline

Builds a 1D full-weighting restriction matrix (fine -> coarse).

Maps a vector of size n_fine to size n_coarse = (n_fine - 1) / 2. Uses the standard [1/4, 1/2, 1/4] stencil.

◆ prolongate()

template<typename Accumulator = void, typename Value>
vec::dense_vector< Value > mtl::itl::mg::prolongate ( const mat::compressed2D< Value > & P,
const vec::dense_vector< Value > & coarse )

Prolongation: interpolate coarse-grid vector to fine grid.

x_fine = P * x_coarse

Accumulator (#585) routes each row's sum of products through math::accumulator_traits, rounded once; the default void is the plain Value sum. The sum starts from math::zero<Value>(), not Value{}: the two agree for the built-in types, but a value-initialized LNS is 1, not 0 (see math/accumulator_traits.hpp), which made every prolongated entry off by one.

◆ restrict()

template<typename Accumulator = void, typename Value>
vec::dense_vector< Value > mtl::itl::mg::restrict ( const mat::compressed2D< Value > & R,
const vec::dense_vector< Value > & fine )

Restriction: project fine-grid vector to coarse grid.

r_coarse = R * r_fine

Accumulator (#585) routes each row's sum of products through math::accumulator_traits, rounded once; the default void is the plain Value sum. The sum starts from math::zero<Value>(), not Value{}: the two agree for the built-in types, but a value-initialized LNS is 1, not 0 (see math/accumulator_traits.hpp), which made every restricted entry off by one.