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

Enumerations

enum  cuv::BinaryFunctor {
  BF_1ST, BF_2ND, BF_EQ, BF_AND,
  BF_OR, BF_POW, BF_ADD, BF_SUBTRACT,
  BF_MULT, BF_DIV, BF_MIN, BF_MAX,
  BF_ATAN2, BF_NORM, BF_LOGADDEXP, BF_LOGCE_OF_LOGISTIC,
  BF_BERNOULLI_KL, BF_DBERNOULLI_KL, BF_AXPY, BF_XPBY,
  BF_AXPBY, BF_EPSILON_INSENSITIVE_LOSS, BF_DEPSILON_INSENSITIVE_LOSS, BF_HINGE_LOSS,
  BF_DHINGE_LOSS, BF_SQHINGE_LOSS, BF_DSQHINGE_LOSS
}
 Binary functors for vectors and matrices. More...

Functions

template<class D , class S >
void cuv::apply_binary_functor (D &v, const S &w, const BinaryFunctor &bf)
 in-place, no parameters.
template<class D , class S , class S2 >
void cuv::apply_binary_functor (D &v, const S &w, const S2 &w2, const BinaryFunctor &bf)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class D , class S >
void cuv::apply_binary_functor (D &v, const S &w, const BinaryFunctor &bf, const typename S::value_type &param)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class D , class S , class S2 >
void cuv::apply_binary_functor (D &v, const S &w, const S2 &w2, const BinaryFunctor &bf, const typename S::value_type &param)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class D , class S >
void cuv::apply_binary_functor (D &v, const S &w, const BinaryFunctor &bf, const typename S::value_type &param, const typename S::value_type &param2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class D , class S , class S2 >
void cuv::apply_binary_functor (D &v, const S &w, const S2 &w2, const BinaryFunctor &bf, const typename S::value_type &param, const typename S::value_type &param2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class __value_type , class __memory_space_type , class __memory_layout_type >
void cuv::copy (tensor< __value_type, __memory_space_type, __memory_layout_type > &dst, const tensor< __value_type, __memory_space_type, __memory_layout_type > &src)
 Copy one vector into another.

Detailed Description

Enumeration Type Documentation

Binary functors for vectors and matrices.

Applied pointwise to a vector/matrix.
The target entry x is calculated from the two source entries x,y according to the given formular.

Without scalar parameters:

    @li BF_1ST evaluates to x
    @li BF_2ND evaluates to y
    @li BF_EQ  computes  x == y
    @li BF_AND computes  x && y
    @li BF_OR  computes  x || y
    @li BF_ADD computes  x += y
    @li BF_POW computes  pow(x,y)
    @li BF_SUBTRACT computes x -= y
    @li BF_MULT computes x *= y
    @li BF_DIV computes x /= y
    @li BF_MIN computes x = min(x,y)
    @li BF_MAX computes x = max(x,y)
    @li BF_LOGADDEXP computes x = log(exp(x)+exp(y))
  • BF_LOGCE_OF_LOGISTIC computes the negative log of cross-entropy $-x\log(y)-(1-x)\log(1-z)$ of logistic $z=1/(1+\exp(-y))$
  • BF_BERNOULLI_KL computes Kullback-Leibler divergence of two bernoulli variables $x\log(x/y)+(1-x)\log\frac{1-x}{1-y}$
  • BF_DBERNOULLI_KL computes derivative of Kullback-Leibler divergence of two bernoulli variables w.r.t. y: $\frac{x-y}{y(y-1)}$
    With one scalar parameter a:
    @li BF_AXPY computes x = a * x + y
    @li BF_XPBY computes x += a * y
    @li BF_EPSILON_INSENSITIVE_LOSS computes \form#26
    @li BF_DEPSILON_INSENSITIVE_LOSS computes  derivative of \form#27 w.r.t. y
    @li BF_HINGE_LOSS computes \form#28
    @li BF_DHINGE_LOSS computes  derivative of \form#29 w.r.t. y
    @li BF_SQHINGE_LOSS computes \form#30
    @li BF_DSQHINGE_LOSS computes  derivative of \form#31 w.r.t. y
    
    With two scalar parameters a and b:
    @li BF_AXPBY computes x = a * x + b * y

Definition at line 459 of file tensor_ops.hpp.

Function Documentation

template<class D , class S >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const BinaryFunctor &  bf 
)

in-place, no parameters.

Applies a binary functor pointwise.

Pseudocode:

forall i:
v[i] = bf(v[i],w[i]);
Parameters
vsource and destination
wsecond source
bfbinary functor to be applied

Definition at line 530 of file tensor_ops.hpp.

template<class D , class S , class S2 >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const S2 &  w2,
const BinaryFunctor &  bf 
)

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

no parameters.

Applies a binary functor pointwise.

Pseudocode:

forall i:
dst[i] = bf(w[i],w2[i]);
Parameters
vdestination
wfirst source
w2second source
bfbinary functor to be applied

Definition at line 553 of file tensor_ops.hpp.

template<class D , class S >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const BinaryFunctor &  bf,
const typename S::value_type &  param 
)

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.

Applies a ternary functor pointwise, fixing the 3rd argument to a constant.

Pseudocode:

forall i:
v[i] = tf(v[i],w[i],param);
Parameters
vsource and destination
wsecond source
bfbinary functor to be applied
paramthird parameter of ternary functor

Definition at line 577 of file tensor_ops.hpp.

template<class D , class S , class S2 >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const S2 &  w2,
const BinaryFunctor &  bf,
const typename S::value_type &  param 
)

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

one parameter.

Applies a ternary functor pointwise, fixing the 3rd argument to a constant.

Pseudocode:

forall i:
v[i] = tf(w[i],w2[i],param);
Parameters
vdestination
wfirst source
w2second source
bfbinary functor to be applied
paramthird parameter of ternary functor

Definition at line 602 of file tensor_ops.hpp.

template<class D , class S >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const BinaryFunctor &  bf,
const typename S::value_type &  param,
const typename S::value_type &  param2 
)

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.

Applies a four-ary functor pointwise, fixing the 3rd and 4th argument to constants.

Pseudocode:

forall i:
v[i] = ff(v[i],w[i],param, param2);
Parameters
vsource and destination
wsecond source
bfbinary functor to be applied
paramthird parameter of four-ary functor
param2fourth parameter of four-ary functor

Definition at line 626 of file tensor_ops.hpp.

template<class D , class S , class S2 >
void cuv::apply_binary_functor ( D &  v,
const S &  w,
const S2 &  w2,
const BinaryFunctor &  bf,
const typename S::value_type &  param,
const typename S::value_type &  param2 
)

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

two parameters.

Applies a four-ary functor pointwise, fixing the 3rd and 4th argument to constants.

Pseudocode:

forall i:
v[i] = ff(w[i],w2[i],param, param2);
Parameters
vdestination
wfirst source
w2second source
bfbinary functor to be applied
paramthird parameter of four-ary functor
param2third parameter of four-ary functor

Definition at line 651 of file tensor_ops.hpp.

template<class __value_type , class __memory_space_type , class __memory_layout_type >
void cuv::copy ( tensor< __value_type, __memory_space_type, __memory_layout_type > &  dst,
const tensor< __value_type, __memory_space_type, __memory_layout_type > &  src 
)

Copy one vector into another.

Parameters
dstDestination vector
srcSource vector

This is a convenience wrapper that applies the binary functor SF_COPY

Definition at line 663 of file tensor_ops.hpp.