ALPS Project

Header file functional.h

This header contains mathematical function objects not present in the standard or boost libraries.

Synopsis

namespace alps {


template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct plus : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct minus : std::binary_function<Arg1, Arg2, Result>  {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct multiplies : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct divides : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct modulus : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_and : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_or : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_xor : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class T, class X>
struct plus_scaled : std::binary_function<T, T, T> {
    plus_scaled(X x) : val(x) {}
    T operator () (const T& x, const T& y) const;
private:
    X val;
};

template <class T, class X>
struct minus_scaled : public std::binary_function<T, T, T> {
    minus_scaled(X x) : val(x) {}
    T operator () (const T& x, const T& y) const;
private:
    X val;
};

template <class T>
struct absmax : public std::binary_function<T, T, typename TypeTraits<T>::norm_t> {
    typename TypeTraits<T>::norm_t operator () (const T& x, const T& y);
};

template <class T>
struct conj_mult : std::binary_function<T,T,T> {
inline T operator()(const T& a, const T& b) const
};

template <class T>
struct conj_mult > : 
  std::binary_function,std::complex<T>,std::complex<T> > {
inline std::complex<T> operator()(const std::complex<T>& a, const std::complex<T>& b) const;
};

template<class T> 
struct add_abs : public std::binary_function<T,typename TypeTraits<T>::norm_t,typename TypeTraits<T>::norm_t> {
inline typename TypeTraits<T>::norm_t operator()(typename TypeTraits<T>::norm_t sum, T val) const;
};

template<class T> 
struct add_abs2 : public std::binary_function<T,typename TypeTraits<T>::norm_t,typename TypeTraits<T>::norm_t> {
inline typename TypeTraits<T>::norm_t operator()(typename TypeTraits<T>::norm_t sum, T val) const;
};

Function objects


template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct plus : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct minus : std::binary_function<Arg1, Arg2, Result>  {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct multiplies : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct divides : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct modulus : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_and : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_or : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};

template <class Arg1, class Arg2=Arg1, class Result=Arg1>
struct bit_xor : std::binary_function<Arg1, Arg2, Result> {
  Result operator () (const Arg1& x, const Arg2& y) const;
};
are similar to the corresponding classes from the standard library, but can take arguments of different type and extend the standard function obejcts with bit functions.
template <class T, class S>
struct plus_scaled : std::binary_function<T, T, T> 
{
  plus_scaled(S s);
  T operator () (const T& x, const T& y) const;
};

template <class T, class S>
struct minus_scaled : public std::binary_function<T, T, T> 
{
  minus_scaled(S s);
  T operator () (const T& x, const T& y) const;
};
are like std::plus and std::minus but multiply the second argument with the scale factor given in the constructor.
template <class T>
struct conj_mult : std::binary_function<T,T,T>
{
  T operator()(const T& x, const T& y);
};

template <class T> struct conj_mult > : 
  std::binary_function,std::complex<T>,std::complex<T> > 
{
  std::complex<T> operator()(const std::complex<T>& x const std::complex<T>& y);
};
is like std::multiplies but takes the complex conjugate of the first argument if the type T is complex.
template <class T>
struct absmax : public std::binary_function<T, T, typename TypeTraits<T>::norm_t> 
{
  typename TypeTraits<T>::norm_t operator () (const T& x, const T& y) const;
};
returns the maximum of the absolute values of the arguments.
template<class T> 
struct add_abs : public std::binary_function<T,typename TypeTraits<T>::norm_t,typename TypeTraits<T>::norm_t> 
{
  typename TypeTraits<T>::norm_t operator()(typename TypeTraits<T>::norm_t sum, T val);
};
adds the absolute value of the second argument to the first.
template<class T> 
struct add_abs2 : public std::binary_function<T,typename TypeTraits<T>::norm_t,typename TypeTraits<T>::norm_t> 
{
  typename TypeTraits<T>::norm_t operator()(typename TypeTraits<T>::norm_t sum, T val);
};
adds the square of the absolute value of the second argument to the first.
copyright (c) 1994-2003 by Matthias Troyer