11 const std::vector< typename T::ScalarType >& c,
14 const std::vector< T >& xx,
15 const typename T::ScalarType c0 ) {
17 typename T::ScalarType;
20 { self.lincomb_impl( c, xx, c0 ) } -> std::same_as< void >;
23 { self_const.dot_impl( x ) } -> std::same_as< typename T::ScalarType >;
26 { self.invert_entries_impl() } -> std::same_as< void >;
29 { self.scale_with_vector_impl( x ) } -> std::same_as< void >;
32 { self.randomize_impl() } -> std::same_as< void >;
35 { self_const.max_abs_entry_impl() } -> std::same_as< typename T::ScalarType >;
38 { self_const.has_nan_or_inf_impl() } -> std::same_as< bool >;
41 { self.swap_impl( x_non_const ) } -> std::same_as< void >;
46template <
typename T >
48 typename T::Block1Type;
49 typename T::Block2Type;
54 { self_const.block_1() } -> std::same_as< const typename T::Block1Type& >;
55 { self_const.block_2() } -> std::same_as< const typename T::Block2Type& >;
57 { self.block_1() } -> std::same_as< typename T::Block1Type& >;
58 { self.block_2() } -> std::same_as< typename T::Block2Type& >;
62template < VectorLike Vector >
71template < VectorLike Vector >
75 const std::vector< Vector >& x,
78 y.lincomb_impl( c, x, c0 );
86template < VectorLike Vector >
96template < VectorLike Vector >
106template < VectorLike Vector >
117template < VectorLike Vector >
120 return y.dot_impl( x );
126template < VectorLike Vector >
129 y.invert_entries_impl();
136template < VectorLike Vector >
139 y.scale_with_vector_impl( x );
145template < VectorLike Vector >
155template < VectorLike Vector >
158 return y.max_abs_entry_impl();
165template < VectorLike Vector >
168 const auto dot_prod =
dot( y, y );
169 return std::sqrt( dot_prod );
177template < VectorLike Vector >
180 const auto dot_prod =
dot( y, y );
181 return std::sqrt( dot_prod * scaling_factor_under_the_root );
188template < VectorLike Vector >
191 return y.has_nan_or_inf_impl();
198template < VectorLike Vector >
199void swap( Vector& x, Vector& y )
208template <
typename ScalarT >
251template <
typename ScalarT >
265 const std::vector< ScalarType >& c,
266 const std::vector< DummyBlock2Vector >& x,
Dummy block 2-vector class for concept checks and testing. Contains two DummyVector blocks.
Definition vector.hpp:253
bool has_nan_or_inf_impl() const
Dummy implementation of NaN check.
Definition vector.hpp:294
ScalarType dot_impl(const DummyBlock2Vector &x) const
Dummy implementation of dot product.
Definition vector.hpp:275
void randomize_impl()
Dummy implementation of randomize.
Definition vector.hpp:288
ScalarT ScalarType
Scalar type used by the block vector.
Definition vector.hpp:256
void invert_entries_impl()
Dummy implementation of invert entries.
Definition vector.hpp:282
DummyVector< ScalarType > & block_1()
Get mutable reference to block 1.
Definition vector.hpp:305
void lincomb_impl(const std::vector< ScalarType > &c, const std::vector< DummyBlock2Vector > &x, const ScalarType c0)
Dummy implementation of linear combination.
Definition vector.hpp:264
const DummyVector< ScalarType > & block_1() const
Get const reference to block 1.
Definition vector.hpp:300
DummyVector< ScalarType > & block_2()
Get mutable reference to block 2.
Definition vector.hpp:307
ScalarType max_abs_entry_impl() const
Dummy implementation of max absolute entry.
Definition vector.hpp:291
void swap_impl(DummyBlock2Vector &other)
Dummy implementation of swap.
Definition vector.hpp:297
void scale_with_vector_impl(const DummyBlock2Vector &x)
Dummy implementation of scale with vector.
Definition vector.hpp:285
const DummyVector< ScalarType > & block_2() const
Get const reference to block 2.
Definition vector.hpp:302
Dummy vector class for concept checks and testing. Implements required vector operations as no-ops.
Definition vector.hpp:210
bool has_nan_or_inf_impl() const
Dummy implementation of NaN check.
Definition vector.hpp:243
void lincomb_impl(const std::vector< ScalarType > &c, const std::vector< DummyVector > &x, const ScalarType c0)
Dummy implementation of linear combination.
Definition vector.hpp:216
ScalarType max_abs_entry_impl() const
Dummy implementation of max absolute entry.
Definition vector.hpp:240
ScalarT ScalarType
Scalar type used by the vector.
Definition vector.hpp:213
void swap_impl(DummyVector< ScalarType > &other)
Dummy implementation of swap.
Definition vector.hpp:246
void scale_with_vector_impl(const DummyVector &x)
Dummy implementation of scale with vector.
Definition vector.hpp:234
void invert_entries_impl()
Dummy implementation of invert entries.
Definition vector.hpp:231
ScalarType dot_impl(const DummyVector &x) const
Dummy implementation of dot product.
Definition vector.hpp:224
void randomize_impl()
Dummy implementation of randomize.
Definition vector.hpp:237
Concept for types that behave like block 2-vectors. Extends VectorLike and requires block types and a...
Definition vector.hpp:47
Concept for types that behave like vectors. Requires exposing ScalarType and implementations for line...
Definition vector.hpp:8
Contains linear algebra utilities and functions for the Terra project.
Definition diagonally_scaled_operator.hpp:8
void invert_entries(Vector &y)
Invert the entries of a vector. For each entry , computes .
Definition vector.hpp:127
void lincomb(Vector &y, const std::vector< ScalarOf< Vector > > &c, const std::vector< Vector > &x, const ScalarOf< Vector > &c0)
Compute a linear combination of vectors. Implements: .
Definition vector.hpp:72
ScalarOf< Vector > norm_2(const Vector &y)
Compute the 2-norm (Euclidean norm) of a vector. Implements: .
Definition vector.hpp:166
void randomize(Vector &y)
Randomize the entries of a vector. Sets each entry of to a random value.
Definition vector.hpp:146
ScalarOf< Vector > dot(const Vector &y, const Vector &x)
Compute the dot product of two vectors. Implements: .
Definition vector.hpp:118
ScalarOf< Vector > norm_2_scaled(const Vector &y, const ScalarOf< Vector > &scaling_factor_under_the_root)
Compute the scaled 2-norm of a vector. Implements: .
Definition vector.hpp:178
ScalarOf< Vector > norm_inf(const Vector &y)
Compute the infinity norm (max absolute entry) of a vector. Implements: .
Definition vector.hpp:156
void scale_in_place(Vector &y, const Vector &x)
Scale a vector in place with another vector. For each entry , computes .
Definition vector.hpp:137
bool has_nan_or_inf(const Vector &y)
Check if a vector contains NaN or inf entries. Returns true if any entry of is NaN or inf.
Definition vector.hpp:189
void assign(Vector &y, const ScalarOf< Vector > &c0)
Assign a scalar value to a vector. Implements: .
Definition vector.hpp:97
void swap(Vector &x, Vector &y)
Swap the contents of two vectors. Exchanges the entries of and .
Definition vector.hpp:199
typename Vector::ScalarType ScalarOf
Alias for the scalar type of a vector.
Definition vector.hpp:63