CUV  0.9.201304091348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Enumerations | Functions
Reductions from matrix to row or column
BLAS2 -- Matrix/Vector operations
Collaboration diagram for Reductions from matrix to row or column:

Enumerations

enum  cuv::reduce_functor {
  RF_ADD, RF_MEAN, RF_ADD_SQUARED, RF_MAX,
  RF_ARGMAX, RF_ARGMIN, RF_MIN, RF_MULT,
  RF_LOGADDEXP, RF_ADDEXP
}
 Reduce functor to reduce a matrix to a row or column. More...

Functions

template<class V , class __value_type2 , class M , class L >
void cuv::reduce_to_col (tensor< V, M > &dst, const tensor< __value_type2, M, L > &src, reduce_functor rf=RF_ADD, const __value_type2 &factNew=1.f, const __value_type2 &factOld=0.f)
 Reduce a matrix to one column using specified reduce functor (or add them up by default)
template<class V , class __value_type2 , class M , class L >
void cuv::reduce_to_row (tensor< V, M > &dst, const tensor< __value_type2, M, L > &src, reduce_functor rf=RF_ADD, const __value_type2 &factNew=1.f, const __value_type2 &factOld=0.f)
 Reduce a matrix to one row using specified reduce functor (or add them up by default)
template<class V , class M , class L >
tensor< V, M > cuv::sum (const tensor< V, M, L > &src, const int &axis)
 Convenience function that creates a new vector and performs reduction by summing along given axis.

Detailed Description

Enumeration Type Documentation

Reduce functor to reduce a matrix to a row or column.

  • RF_ADD adds columns/rows
  • RF_MEAN adds columns/rows, divides by number of entries
  • RF_ADD_SQUARED adds squared entries of columns/rows
  • RF_MAX uses maximum in colum (when reducing to row) or row (when reducing to column)
  • RF_MIN uses minimum in colum (when reducing to row) or row (when reducing to column)
  • RF_MULT multiplies by summing in log-space $r_j = exp(\sum_i \log m_{ji})$
  • RF_LOGADDEXP calculates $r_j = \log(\sum_i\exp(m_ji)$ in a numerically stable way
  • RF_ADDEXP calculates $r_j = \sum_i\exp(m_ji)$ in a numerically stable way

Definition at line 185 of file matrix_ops.hpp.

Function Documentation

template<class V , class __value_type2 , class M , class L >
void cuv::reduce_to_col ( tensor< V, M > &  dst,
const tensor< __value_type2, M, L > &  src,
reduce_functor  rf = RF_ADD,
const __value_type2 &  factNew = 1.f,
const __value_type2 &  factOld = 0.f 
)

Reduce a matrix to one column using specified reduce functor (or add them up by default)

Parameters
dstDestination vector, dst.size = src.h()
srcSource matrix
rfReduce functor
factNewScalar factor for result of reduce functor
factOldScalar factor for former entry of dst
Calculates
dst= factOld * dst + factNew * rf(src)
By default, the reduce functor is RF_ADD so that rf(src) is the sum over all columns of src.
template<class V , class __value_type2 , class M , class L >
void cuv::reduce_to_row ( tensor< V, M > &  dst,
const tensor< __value_type2, M, L > &  src,
reduce_functor  rf = RF_ADD,
const __value_type2 &  factNew = 1.f,
const __value_type2 &  factOld = 0.f 
)

Reduce a matrix to one row using specified reduce functor (or add them up by default)

Parameters
dstDestination vector, dst.size = src.w()
srcSource matrix
rfReduce functor
factNewScalar factor for result of reduce functor
factOldScalar factor for former entry of dst
Calculates
dst= factOld * dst + factNew * rf(src)
By default, the reduce functor is RF_ADD so that rf(src) is the sum over all rows of src.
template<class V , class M , class L >
tensor<V, M> cuv::sum ( const tensor< V, M, L > &  src,
const int &  axis 
)

Convenience function that creates a new vector and performs reduction by summing along given axis.

Parameters
srcSource matrix
axisAlong which axis (0 = reduce to row, 1 = reduce to col)

Definition at line 239 of file matrix_ops.hpp.