SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Classes | Functions
shogun::linalg Namespace Reference

Namespaces

 implementation
 
 ocl
 
 operations
 
 util
 

Classes

struct  Block
 Generic class Block which wraps a matrix class and contains block specific information, providing a uniform way to deal with matrix blocks for all supported backend matrices. More...
 

Functions

template<class Matrix >
Block< Matrix > block (Matrix matrix, index_t row_begin, index_t col_begin, index_t row_size, index_t col_size)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
void add (Matrix A, Matrix B, Matrix C, typename Matrix::Scalar alpha=1.0, typename Matrix::Scalar beta=1.0)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
Matrix add (Matrix A, Matrix B, typename Matrix::Scalar alpha=1.0, typename Matrix::Scalar beta=1.0)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
void scale (Matrix A, Matrix B, typename Matrix::Scalar alpha)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
void scale (Matrix A, typename Matrix::Scalar alpha)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
void range_fill (Matrix A, typename Matrix::Scalar start=0.0)
 
template<Backend backend = linalg_traits<Core>::backend, class Matrix >
void range_fill (Matrix A, index_t len, typename Matrix::Scalar start=0.0)
 
template<class Operand , class UnaryOp >
auto elementwise_compute (Operand operand, UnaryOp unary_op) -> typename Operand::template container_type< decltype(unary_op(operand.data()[0]))>
 
template<class Operand , class UnaryOp >
void elementwise_compute_inplace (Operand operand, UnaryOp unary_op)
 
template<Backend backend, class Operand >
Operand::template
container_type< typename
operations::sin< typename
Operand::Scalar >::return_type > 
elementwise_sin (Operand operand)
 
template<Backend backend, class Operand >
void elementwise_sin_inplace (Operand operand)
 
template<Backend backend = linalg_traits<Redux>::backend, class Vector >
Vector::Scalar dot (Vector a, Vector b)
 
template<Backend backend = linalg_traits<Redux>::backend, class Matrix >
Matrix::Scalar max (Matrix m)
 
template<Backend backend = linalg_traits<Redux>::backend, class Vector >
Vector::Scalar vector_sum (Vector a)
 

Function Documentation

void shogun::linalg::add ( Matrix  A,
Matrix  B,
Matrix  C,
typename Matrix::Scalar  alpha = 1.0,
typename Matrix::Scalar  beta = 1.0 
)

Performs the operation \(C = \alpha A + \beta B\). Works for both matrices and vectors.

This version should be used for backend specific code requirements. For example, use this with CGPUMatrix and explicitly set ViennaCL backend, or SGMatrix and explicitly set Eigen3 backend. If matrix-type/backend-type independent code is desired, use the version that does not support preallocated result matrix but returns the result in a newly created matrix instead.

Parameters
AFirst matrix/vector
BSecond matrix/vector
CResult of the operation
alphascaling parameter for first matrix/vector
betascaling parameter for second matrix/vector

Definition at line 66 of file Core.h.

Matrix shogun::linalg::add ( Matrix  A,
Matrix  B,
typename Matrix::Scalar  alpha = 1.0,
typename Matrix::Scalar  beta = 1.0 
)

Performs the operation \(C = \alpha A + \beta B\). Works for both matrices and vectors.

This version returns the result in a newly created matrix/vector. If add is desired that will work irrespective of the backend and the matrix/vector type used, then this method should be used.

Parameters
AFirst matrix/vector
BSecond matrix/vector
alphascaling parameter for first matrix/vector
betascaling parameter for second matrix/vector
Returns
The result of the operation

Definition at line 86 of file Core.h.

Block<Matrix> shogun::linalg::block ( Matrix  matrix,
index_t  row_begin,
index_t  col_begin,
index_t  row_size,
index_t  col_size 
)

Method that returns a block object. Suited for Eigen3/SGMatrix

Parameters
matrixthe matrix on which the block is defined
row_beginthe row index at which the block starts
col_beginthe col index at which the block starts
row_sizethe number of rows in the block
col_sizethe number of cols in the block
Returns
a block object on this matrix

Definition at line 102 of file Block.h.

Vector::Scalar shogun::linalg::dot ( Vector  a,
Vector  b 
)

Wrapper method for internal implementation of vector dot-product that works with generic vectors.

Parameters
afirst vector
bsecond vector
Returns
the dot product of \(\mathbf{a}\) and \(\mathbf{b}\), represented as \(\sum_i a_i b_i\)

Definition at line 58 of file Redux.h.

auto shogun::linalg::elementwise_compute ( Operand  operand,
UnaryOp  unary_op 
) -> typename Operand::template container_type<decltype(unary_op(operand.data()[0]))>

Template method for computing custom unary operations element-wise for matrices and vectors using NATIVE backend. Works for SGMatrix/SGVector.

This method returns the result in a newly allocated matrix/vector.

Parameters
operandThe operand on which the element-wise operation has to be performed
unary_opThe custom unary operator
Returns
The result of the unary operator applied element-wise on the operand

Definition at line 56 of file ElementwiseOperations.h.

void shogun::linalg::elementwise_compute_inplace ( Operand  operand,
UnaryOp  unary_op 
)

Template method for computing custom unary operations element-wise for matrices and vectors using NATIVE backend. Works for SGMatrix/SGVector.

This method computes the result in-place.

Parameters
operandThe operand on which the element-wise operation has to be performed
unary_opThe custom unary operator

Definition at line 80 of file ElementwiseOperations.h.

Operand::template container_type<typename operations::sin<typename Operand::Scalar>::return_type> shogun::linalg::elementwise_sin ( Operand  operand)

Template method for computing element-wise sin for matrices and vectors.

This method returns the result in a newly allocated matrix/vector.

Parameters
operandThe operand on which the element-wise operation has to be performed
Returns
The result of the unary operator applied element-wise on the operand

Definition at line 141 of file ElementwiseOperations.h.

void shogun::linalg::elementwise_sin_inplace ( Operand  operand)

Template method for computing element-wise sin for matrices and vectors.

This method computes the result in-place.

Parameters
operandThe operand on which the element-wise operation has to be performed
Returns
The result of the unary operator applied element-wise on the operand

Definition at line 165 of file ElementwiseOperations.h.

Matrix::Scalar shogun::linalg::max ( Matrix  m)

Returns the largest element in a matrix or vector

Parameters
mthe matrix or the vector
Returns
the value of the largest element

Definition at line 68 of file Redux.h.

void shogun::linalg::range_fill ( Matrix  A,
typename Matrix::Scalar  start = 0.0 
)

Range fill a vector with start...start+len-1

Parameters
A- the matrix to be filled
start- value to be assigned to first element of vector or matrix

Definition at line 111 of file Core.h.

void shogun::linalg::range_fill ( Matrix  A,
index_t  len,
typename Matrix::Scalar  start = 0.0 
)

Range fill a vector array with start...start+len-1

Parameters
A- the array to be filled
len- length of the array to be filled
start- value to be assigned to first element of array

Definition at line 122 of file Core.h.

void shogun::linalg::scale ( Matrix  A,
Matrix  B,
typename Matrix::Scalar  alpha 
)

Performs the operation B = alpha*A. Works for both matrices and vectors

Definition at line 94 of file Core.h.

void shogun::linalg::scale ( Matrix  A,
typename Matrix::Scalar  alpha 
)

Performs the operation A = alpha*A. Works for both matrices and vectors

Definition at line 101 of file Core.h.

Vector::Scalar shogun::linalg::vector_sum ( Vector  a)

Wrapper method for internal implementation of vector sum of values that works with generic dense vectors

Parameters
avector whose sum has to be computed
Returns
the vector sum \(\sum_i a_i\)

Definition at line 81 of file Redux.h.


SHOGUN Machine Learning Toolbox - Documentation