CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Enumerations | Functions
Pointwise scalar functors
Pointwise functors on vectors
Collaboration diagram for Pointwise scalar functors:

Enumerations

enum  cuv::ScalarFunctor {
  SF_EXP, SF_SIN, SF_COS, SF_LOG,
  SF_SIGN, SF_SIGM, SF_DSIGM, SF_SQUARE,
  SF_SUBLIN, SF_ENERG, SF_INV, SF_SQRT,
  SF_NEGATE, SF_ABS, SF_SMAX, SF_POSLIN,
  SF_RECT, SF_DRECT, SF_COPY, SF_LOG1P,
  SF_POW, SF_DPOW, SF_ADD, SF_SUBTRACT,
  SF_RSUB, SF_MULT, SF_DIV, SF_RDIV,
  SF_LOGADDEXP, SF_MIN, SF_MAX, SF_ROBUST_ABS,
  SF_DROBUST_ABS, SF_EQ, SF_LT, SF_GT,
  SF_LEQ, SF_GEQ, SF_BERNOULLI_KL, SF_DBERNOULLI_KL,
  SF_AXPB, SF_TANH, SF_DTANH
}
 Scalar Functors for vectors and matrices Applied pointwise to a vector/matrix. More...

Functions

template<class D >
void cuv::apply_scalar_functor (D &v, const ScalarFunctor &sf, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 apply a scalar functor to all elements of v.
template<class D , class S >
void cuv::apply_scalar_functor (D &dst, const S &src, const ScalarFunctor &sf, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. apply a scalar functor to all elements of src.
template<class D >
void cuv::apply_scalar_functor (D &v, const ScalarFunctor &sf, const typename D::value_type &p, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. in-place, one parameter.
template<class D , class S >
void cuv::apply_scalar_functor (D &dst, const S &src, const ScalarFunctor &sf, const typename S::value_type &p, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.one parameter.
template<class D >
void cuv::apply_scalar_functor (D &v, const ScalarFunctor &sf, const typename D::value_type &p, const typename D::value_type &p2, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.in-place, two parameters.
template<class D , class S >
void cuv::apply_scalar_functor (D &dst, const S &src, const ScalarFunctor &sf, const typename S::value_type &p, const typename S::value_type &p2, const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *mask=NULL)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Detailed Description

Enumeration Type Documentation

Scalar Functors for vectors and matrices Applied pointwise to a vector/matrix.

Each entry x is transformed according to the given formular.

Without scalar parameters:

@li SF_COPY computes x (the identity)
@li SF_EXP computes exp(x)
@li SF_LOG computes log(x)
@li SF_SIGN computes sign(x)
@li SF_SIGM computes 1/(1+exp(-x))
@li SF_DSIGM computes x * (1-x)
@li SF_TANH computes tanh(x)
@li SF_DTANH computes x - x^2
@li SF_SIN computes sin(x)
@li SF_COS computes cos(x)
@li SF_SQUARE computes x*x
@li SF_SUBLIN computes 1-x
@li SF_ENERG computes -log(x) 
@li SF_INV computes 1/x 
@li SF_SQRT computes sqrt(x)
@li SF_NEGATE computes -x
@li SF_ABS computes absolute value of x
@li SF_SMAX computes (1/x -1) * x
@li SF_LOG1P computes \form#14

With one scalar parameter a:

  • SF_POW computes $x^a$
  • SF_DPOW computes $1/a * x^{a-1}$
  • SF_ADD computes x + a
  • SF_SUBTRACT computes x - a
  • SF_RSUB computes a - x
  • SF_MULT computes x * a
  • SF_DIV computes x / a
  • SF_RDIV computes a / x
  • SF_LOGADDEXP computes $\log(\exp(a) + \exp(x))$
  • SF_MIN computes min(x,a)
  • SF_MAX computes max(x,a)
  • SF_ROBUST_ABS computes $\sqrt{x^2+a}$
  • SF_DROBUST_ABS computes derivative of
    See Also
    SF_ROBUST_ABS $x/\sqrt{a+x^2}$
  • SF_EQ computes x == a
  • SF_LT computes x < a
  • SF_GT computes x > a
  • SF_LEQ computes x <= a
  • SF_GEQ computes x >= a
  • SF_BERNOULLI_KL computes Kullback-Leibler divergence of two bernoulli variables $x\log(a/x)+(1-a)\log\frac{1-a}{1-x}$
  • SF_DBERNOULLI_KL computes derivative of Kullback-Leibler divergence of two bernoulli variables w.r.t. x: $\frac{a-x}{x(x-1)}$

With two scalar parameters a and b:

  • SF_AXPB computes a*x+b

With zero OR two scalar parameters a and b:

  • SF_DTANH computes a/b * (a+x) + (a-x), if no params given: a=b=1
  • SF_TANH computes b*tanh(a*x), if no params given: a=b=1

Definition at line 192 of file tensor_ops.hpp.

Function Documentation

template<class D >
void cuv::apply_scalar_functor ( D &  v,
const ScalarFunctor &  sf,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

apply a scalar functor to all elements of v.

Pseudocode:

forall i:
if !mask or mask[i]:
v[i] = sf(v[i]);

in-place, no parameters

Parameters
vwhere we read from and write to
sfthe applied scalar functor
maskoptional

Definition at line 290 of file tensor_ops.hpp.

template<class D , class S >
void cuv::apply_scalar_functor ( D &  dst,
const S &  src,
const ScalarFunctor &  sf,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. apply a scalar functor to all elements of src.

no parameters

Parameters
dstdestination
srcsource
sfthe scalar functor to be applied
maskoptional mask

Definition at line 308 of file tensor_ops.hpp.

template<class D >
void cuv::apply_scalar_functor ( D &  v,
const ScalarFunctor &  sf,
const typename D::value_type &  p,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. in-place, one parameter.

This function applies a binary functor, fixing the second argument to a constant.

Pseudocode:

forall i:
if !mask or mask[i]:
v[i] = bf(v[i],p);
Parameters
vsource and destination
sfthe scalar functor to be applied
pparameter for binary functor
maskoptional mask

Definition at line 333 of file tensor_ops.hpp.

template<class D , class S >
void cuv::apply_scalar_functor ( D &  dst,
const S &  src,
const ScalarFunctor &  sf,
const typename S::value_type &  p,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.one parameter.

This function applies a binary functor, fixing the second argument to a constant.

Pseudocode:

forall i:
if !mask or mask[i]:
dst[i] = bf(src[i],p);
Parameters
dstdestination
srcsource
sfthe scalar functor to be applied
pparameter for binary functor
maskoptional mask

Definition at line 357 of file tensor_ops.hpp.

template<class D >
void cuv::apply_scalar_functor ( D &  v,
const ScalarFunctor &  sf,
const typename D::value_type &  p,
const typename D::value_type &  p2,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.in-place, two parameters.

This function applies a ternary functor, fixing the second and third argument to a constant.

Pseudocode:

forall i:
if !mask or mask[i]:
v[i] = tf(v[i],p,p2);
Parameters
vsource and destination
sfthe scalar functor to be applied
p2nd parameter for ternary functor
p23rd parameter for ternary functor
maskoptional mask

Definition at line 382 of file tensor_ops.hpp.

template<class D , class S >
void cuv::apply_scalar_functor ( D &  dst,
const S &  src,
const ScalarFunctor &  sf,
const typename S::value_type &  p,
const typename S::value_type &  p2,
const tensor< unsigned char, typename D::memory_space_type, typename D::memory_layout_type > *  mask = NULL 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

two parameters. This function applies a ternary functor, fixing the second and third argument to a constant.

Pseudocode:

forall i:
if !mask or mask[i]:
dst[i] = tf(src[i],p,p2);
Parameters
dstdestination
srcsource
sfthe scalar functor to be applied
p2nd parameter for ternary functor
p23rd parameter for ternary functor
maskoptional mask

Definition at line 407 of file tensor_ops.hpp.