Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Static Public Member Functions | List of all members
CDPL::Math::MinimizerVariableArrayTraits< A > Struct Template Reference

Traits template that adapts arbitrary variable-array types to the linear-algebra operations required by minimizer implementations (dot, norm2, axpy, clear, assign, multiply, sub). More...

#include <MinimizerVariableArrayTraits.hpp>

+ Inheritance diagram for CDPL::Math::MinimizerVariableArrayTraits< A >:

Public Types

typedef A ArrayType
 The variable-array type. More...
 
typedef A::ValueType ValueType
 The scalar value type stored in the array. More...
 
typedef A::SizeType SizeType
 The size type used by the array. More...
 

Static Public Member Functions

template<typename T >
static T dot (const ArrayType &a1, const ArrayType &a2)
 Computes the inner product (dot product) of two variable arrays. More...
 
template<typename T >
static T norm2 (const ArrayType &a)
 Computes the Euclidean (L2) norm of a using a numerically stable scaling algorithm. More...
 
template<typename T >
static void axpy (const T &alpha, const ArrayType &x, ArrayType &y)
 Performs the in-place BLAS-style axpy operation \( y \leftarrow y + \alpha\, x \). More...
 
static void clear (ArrayType &a)
 Sets all elements of a to the default-constructed ValueType. More...
 
static void assign (ArrayType &a1, const ArrayType &a2)
 Copies the contents of a2 into a1. More...
 
template<typename T >
static void multiply (ArrayType &a, const T &v)
 Multiplies every element of a by the scalar v. More...
 
static void sub (ArrayType &a1, const ArrayType &a2)
 Subtracts a2 from a1 element-wise ( \( a_1 \leftarrow a_1 - a_2 \)). More...
 

Detailed Description

template<typename A>
struct CDPL::Math::MinimizerVariableArrayTraits< A >

Traits template that adapts arbitrary variable-array types to the linear-algebra operations required by minimizer implementations (dot, norm2, axpy, clear, assign, multiply, sub).

The primary template assumes A behaves like a Math::Vector (provides getSize, clear, assign, plusAssign/minusAssign, innerProd and arithmetic operators). Specializations adapt other array-of-vector storage types.

Template Parameters
AThe variable array type.

Member Typedef Documentation

◆ ArrayType

template<typename A >
typedef A CDPL::Math::MinimizerVariableArrayTraits< A >::ArrayType

The variable-array type.

◆ ValueType

template<typename A >
typedef A::ValueType CDPL::Math::MinimizerVariableArrayTraits< A >::ValueType

The scalar value type stored in the array.

◆ SizeType

template<typename A >
typedef A::SizeType CDPL::Math::MinimizerVariableArrayTraits< A >::SizeType

The size type used by the array.

Member Function Documentation

◆ dot()

template<typename A >
template<typename T >
static T CDPL::Math::MinimizerVariableArrayTraits< A >::dot ( const ArrayType a1,
const ArrayType a2 
)
inlinestatic

Computes the inner product (dot product) of two variable arrays.

Template Parameters
TThe scalar result type.
Parameters
a1The first variable array.
a2The second variable array.
Returns
The inner product as a value of type T.

◆ norm2()

template<typename A >
template<typename T >
static T CDPL::Math::MinimizerVariableArrayTraits< A >::norm2 ( const ArrayType a)
inlinestatic

Computes the Euclidean (L2) norm of a using a numerically stable scaling algorithm.

Template Parameters
TThe scalar result type.
Parameters
aThe variable array.
Returns
The Euclidean norm as a value of type T.

◆ axpy()

template<typename A >
template<typename T >
static void CDPL::Math::MinimizerVariableArrayTraits< A >::axpy ( const T &  alpha,
const ArrayType x,
ArrayType y 
)
inlinestatic

Performs the in-place BLAS-style axpy operation \( y \leftarrow y + \alpha\, x \).

Template Parameters
TThe scalar type of alpha.
Parameters
alphaThe scalar multiplier.
xThe variable array x.
yThe variable array y (updated in place).

◆ clear()

template<typename A >
static void CDPL::Math::MinimizerVariableArrayTraits< A >::clear ( ArrayType a)
inlinestatic

Sets all elements of a to the default-constructed ValueType.

Parameters
aThe variable array to clear.

◆ assign()

template<typename A >
static void CDPL::Math::MinimizerVariableArrayTraits< A >::assign ( ArrayType a1,
const ArrayType a2 
)
inlinestatic

Copies the contents of a2 into a1.

Parameters
a1The destination variable array.
a2The source variable array.

◆ multiply()

template<typename A >
template<typename T >
static void CDPL::Math::MinimizerVariableArrayTraits< A >::multiply ( ArrayType a,
const T &  v 
)
inlinestatic

Multiplies every element of a by the scalar v.

Template Parameters
TThe scalar type of v.
Parameters
aThe variable array to scale (updated in place).
vThe scalar multiplier.

◆ sub()

template<typename A >
static void CDPL::Math::MinimizerVariableArrayTraits< A >::sub ( ArrayType a1,
const ArrayType a2 
)
inlinestatic

Subtracts a2 from a1 element-wise ( \( a_1 \leftarrow a_1 - a_2 \)).

Parameters
a1The destination variable array (updated in place).
a2The variable array to subtract.

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