numerics 0.1.0
Loading...
Searching...
No Matches
num::kernel::subspace::CallableOp< F > Struct Template Referencefinal

Wrap any callable void(const Vector&, Vector&) as a LinearOp. More...

#include <subspace.hpp>

Inheritance diagram for num::kernel::subspace::CallableOp< F >:
num::kernel::subspace::LinearOp

Public Member Functions

 CallableOp (F f, idx n)
 
void apply (const Vector &x, Vector &y) const override
 y = A*x (y must be pre-allocated to the correct size)
 
idx rows () const noexcept override
 
idx cols () const noexcept override
 
- Public Member Functions inherited from num::kernel::subspace::LinearOp
virtual ~LinearOp ()=default
 

Detailed Description

template<typename F>
struct num::kernel::subspace::CallableOp< F >

Wrap any callable void(const Vector&, Vector&) as a LinearOp.

Useful for structured operators – stencils, FFT-based, implicit matrices – without forming an explicit matrix. The functor is stored by value.

apply() pre-allocates y to the correct size (n_) before calling f_ so that callers (e.g. arnoldi_step passing a pre-allocated scratch buffer) never trigger a heap allocation inside the hot Arnoldi loop. Lambdas passed to make_op / make_op_ptr can safely assume y.size() == n on entry.

[&](const Vector& x, Vector& y) { laplacian(x, y, N); }, N * N);
CallableOp< F > make_op(F f, idx n)
Factory: wrap a callable as a stack-allocated CallableOp<F>.
Definition subspace.hpp:128

Definition at line 108 of file subspace.hpp.

Constructor & Destructor Documentation

◆ CallableOp()

template<typename F >
num::kernel::subspace::CallableOp< F >::CallableOp ( f,
idx  n 
)
inline

Definition at line 109 of file subspace.hpp.

Member Function Documentation

◆ apply()

template<typename F >
void num::kernel::subspace::CallableOp< F >::apply ( const Vector x,
Vector y 
) const
inlineoverridevirtual

y = A*x (y must be pre-allocated to the correct size)

Implements num::kernel::subspace::LinearOp.

Definition at line 111 of file subspace.hpp.

References num::BasicVector< T >::size().

◆ cols()

template<typename F >
idx num::kernel::subspace::CallableOp< F >::cols ( ) const
inlineoverridevirtualnoexcept

Implements num::kernel::subspace::LinearOp.

Definition at line 116 of file subspace.hpp.

◆ rows()

template<typename F >
idx num::kernel::subspace::CallableOp< F >::rows ( ) const
inlineoverridevirtualnoexcept

Implements num::kernel::subspace::LinearOp.

Definition at line 115 of file subspace.hpp.


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