ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
matrix.hpp File Reference

Implementation of the dense matrix class. More...

Go to the source code of this file.

Classes

class  viennacl::matrix_expression< LHS, RHS, OP >
 Expression template class for representing a tree of expressions which ultimately result in a matrix. More...
 
struct  viennacl::row_iteration
 A tag indicating iteration along increasing row index of a matrix. More...
 
struct  viennacl::col_iteration
 A tag indicating iteration along increasing columns index of a matrix. More...
 
class  viennacl::matrix_iterator< ROWCOL, MatrixT >
 A dense matrix class. More...
 
class  viennacl::matrix< NumericT, F, AlignmentV >
 A dense matrix class. More...
 

Namespaces

 viennacl
 Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
 

Functions

template<class NumericT >
std::ostream & viennacl::operator<< (std::ostream &s, const matrix_base< NumericT > &gpu_matrix)
 Prints the matrix. Output is compatible to boost::numeric::ublas. More...
 
template<typename LHS , typename RHS , typename OP >
std::ostream & viennacl::operator<< (std::ostream &s, const matrix_expression< LHS, RHS, OP > &expr)
 Prints the matrix. Output is compatible to boost::numeric::ublas. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, op_trans > viennacl::trans (const matrix_base< NumericT > &mat)
 Returns an expression template class representing a transposed matrix. More...
 
template<typename NumericT >
vector_expression< const matrix_base< NumericT >, const int, op_matrix_diag > viennacl::diag (const matrix_base< NumericT > &A, int k=0)
 
template<typename NumericT >
matrix_expression< const vector_base< NumericT >, const int, op_vector_diag > viennacl::diag (const vector_base< NumericT > &v, int k=0)
 
template<typename NumericT , typename F >
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > viennacl::row (const matrix_base< NumericT, F > &A, unsigned int i)
 
template<typename NumericT , typename F >
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_column > viennacl::column (const matrix_base< NumericT, F > &A, unsigned int j)
 
template<typename CPUMatrixT , typename NumericT , typename F , unsigned int AlignmentV>
void viennacl::copy (const CPUMatrixT &cpu_matrix, matrix< NumericT, F, AlignmentV > &gpu_matrix)
 Copies a dense matrix from the host (CPU) to the OpenCL device (GPU or multi-core CPU) More...
 
template<typename NumericT , typename A1 , typename A2 , typename F , unsigned int AlignmentV>
void viennacl::copy (const std::vector< std::vector< NumericT, A1 >, A2 > &cpu_matrix, matrix< NumericT, F, AlignmentV > &gpu_matrix)
 Copies a dense STL-type matrix from the host (CPU) to the OpenCL device (GPU or multi-core CPU) More...
 
template<typename NumericT , typename F , unsigned int AlignmentV>
void viennacl::fast_copy (NumericT *cpu_matrix_begin, NumericT *cpu_matrix_end, matrix< NumericT, F, AlignmentV > &gpu_matrix)
 Copies a dense matrix from the host (CPU) to the OpenCL device (GPU or multi-core CPU) without temporary. Matrix-Layout on CPU must be equal to the matrix-layout on the GPU. More...
 
template<typename CPUMatrixT , typename NumericT , typename F , unsigned int AlignmentV>
void viennacl::copy (const matrix< NumericT, F, AlignmentV > &gpu_matrix, CPUMatrixT &cpu_matrix)
 Copies a dense matrix from the OpenCL device (GPU or multi-core CPU) to the host (CPU). More...
 
template<typename NumericT , typename A1 , typename A2 , typename F , unsigned int AlignmentV>
void viennacl::copy (const matrix< NumericT, F, AlignmentV > &gpu_matrix, std::vector< std::vector< NumericT, A1 >, A2 > &cpu_matrix)
 Copies a dense matrix from the OpenCL device (GPU or multi-core CPU) to the host (CPU). More...
 
template<typename NumericT , typename F , unsigned int AlignmentV>
void viennacl::fast_copy (const matrix< NumericT, F, AlignmentV > &gpu_matrix, NumericT *cpu_matrix_begin)
 Copies a dense matrix from the OpenCL device (GPU or multi-core CPU) to the host (CPU). More...
 
template<typename LHS1 , typename RHS1 , typename OP1 , typename LHS2 , typename RHS2 , typename OP2 >
matrix_expression< const matrix_expression< const LHS1, const RHS1, OP1 >, const matrix_expression< const LHS2, const RHS2, OP2 >, op_add > viennacl::operator+ (matrix_expression< const LHS1, const RHS1, OP1 > const &proxy1, matrix_expression< const LHS2, const RHS2, OP2 > const &proxy2)
 Generic 'catch-all' overload, which enforces a temporary if the expression tree gets too deep. More...
 
template<typename LHS1 , typename RHS1 , typename OP1 , typename NumericT >
matrix_expression< const matrix_expression< const LHS1, const RHS1, OP1 >, const matrix_base< NumericT >, op_add > viennacl::operator+ (matrix_expression< const LHS1, const RHS1, OP1 > const &proxy1, matrix_base< NumericT > const &proxy2)
 
template<typename NumericT , typename LHS2 , typename RHS2 , typename OP2 >
matrix_expression< const matrix_base< NumericT >, const matrix_expression< const LHS2, const RHS2, OP2 >, op_add > viennacl::operator+ (matrix_base< NumericT > const &proxy1, matrix_expression< const LHS2, const RHS2, OP2 > const &proxy2)
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, op_add > viennacl::operator+ (const matrix_base< NumericT > &m1, const matrix_base< NumericT > &m2)
 Operator overload for m1 + m2, where m1 and m2 are either dense matrices, matrix ranges, or matrix slices. No mixing of different storage layouts allowed at the moment. More...
 
template<typename LHS1 , typename RHS1 , typename OP1 , typename LHS2 , typename RHS2 , typename OP2 >
matrix_expression< const matrix_expression< const LHS1, const RHS1, OP1 >, const matrix_expression< const LHS2, const RHS2, OP2 >, op_sub > viennacl::operator- (matrix_expression< const LHS1, const RHS1, OP1 > const &proxy1, matrix_expression< const LHS2, const RHS2, OP2 > const &proxy2)
 
template<typename LHS1 , typename RHS1 , typename OP1 , typename NumericT >
matrix_expression< const matrix_expression< const LHS1, const RHS1, OP1 >, const matrix_base< NumericT >, op_sub > viennacl::operator- (matrix_expression< const LHS1, const RHS1, OP1 > const &proxy1, matrix_base< NumericT > const &proxy2)
 
template<typename NumericT , typename LHS2 , typename RHS2 , typename OP2 >
matrix_expression< const matrix_base< NumericT >, const matrix_expression< const LHS2, const RHS2, OP2 >, op_sub > viennacl::operator- (matrix_base< NumericT > const &proxy1, matrix_expression< const LHS2, const RHS2, OP2 > const &proxy2)
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, op_sub > viennacl::operator- (const matrix_base< NumericT > &m1, const matrix_base< NumericT > &m2)
 Operator overload for m1 - m2, where m1 and m2 are either dense matrices, matrix ranges, or matrix slices. No mixing of different storage layouts allowed at the moment. More...
 
template<typename S1 , typename NumericT >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_base< NumericT >, const S1, op_mult >>::type viennacl::operator* (S1 const &value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a host scalar (float or double) and m1 is a ViennaCL matrix. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (char value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a char (8-bit integer) More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (short value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a short integer. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (int value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is an integer. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (long value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a long integer. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (float value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a single precision floating point value. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (double value, matrix_base< NumericT > const &m1)
 Operator overload for the expression alpha * m1, where alpha is a double precision floating point value. More...
 
template<typename LHS , typename RHS , typename OP , typename S1 >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_expression< LHS, RHS, OP >, const S1, op_mult > >::type viennacl::operator* (matrix_expression< LHS, RHS, OP > const &proxy, S1 const &val)
 Operator overload for the multiplication of a matrix expression with a scalar from the right, e.g. (beta * m1) * alpha. Here, beta * m1 is wrapped into a matrix_expression and then multiplied with alpha from the right. More...
 
template<typename S1 , typename LHS , typename RHS , typename OP >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_expression< LHS, RHS, OP >, const S1, op_mult > >::type viennacl::operator* (S1 const &val, matrix_expression< LHS, RHS, OP > const &proxy)
 Operator overload for the multiplication of a matrix expression with a ViennaCL scalar from the left, e.g. alpha * (beta * m1). Here, beta * m1 is wrapped into a matrix_expression and then multiplied with alpha from the left. More...
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_base< NumericT >, const S1, op_mult > >::type viennacl::operator* (matrix_base< NumericT > const &m1, S1 const &s1)
 Scales the matrix by a GPU scalar 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, char s1)
 Scales the matrix by a char (8-bit integer) 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, short s1)
 Scales the matrix by a short integer 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, int s1)
 Scales the matrix by an integer 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, long s1)
 Scales the matrix by a long integer 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, float s1)
 Scales the matrix by a single precision floating point number 'alpha' and returns an expression template. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_mult > viennacl::operator* (matrix_base< NumericT > const &m1, double s1)
 Scales the matrix by a double precision floating point number 'alpha' and returns an expression template. More...
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT > & >::type viennacl::operator*= (matrix_base< NumericT > &m1, S1 const &gpu_val)
 Scales a matrix by a GPU scalar value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, char gpu_val)
 Scales a matrix by a char (8-bit) value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, short gpu_val)
 Scales a matrix by a short integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, int gpu_val)
 Scales a matrix by an integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, long gpu_val)
 Scales a matrix by a long integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, float gpu_val)
 Scales a matrix by a single precision floating point value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator*= (matrix_base< NumericT > &m1, double gpu_val)
 Scales a matrix by a double precision floating point value. More...
 
template<typename LHS , typename RHS , typename OP , typename S1 >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_expression< const LHS, const RHS, OP >, const S1, op_div > >::type viennacl::operator/ (matrix_expression< const LHS, const RHS, OP > const &proxy, S1 const &val)
 Operator overload for the division of a matrix expression by a scalar from the right, e.g. (beta * m1) / alpha. Here, beta * m1 is wrapped into a matrix_expression and then divided by alpha. More...
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_any_scalar< S1 >::value, matrix_expression< const matrix_base< NumericT >, const S1, op_div > >::type viennacl::operator/ (matrix_base< NumericT > const &m1, S1 const &s1)
 Returns an expression template for scaling the matrix by a GPU scalar 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, char s1)
 Returns an expression template for scaling the matrix by a char (8-bit integer) 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, short s1)
 Returns an expression template for scaling the matrix by a short integer 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, int s1)
 Returns an expression template for scaling the matrix by an integer 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, long s1)
 Returns an expression template for scaling the matrix by a long integer 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, float s1)
 Returns an expression template for scaling the matrix by a single precision floating point number 'alpha'. More...
 
template<typename NumericT >
matrix_expression< const matrix_base< NumericT >, const NumericT, op_div > viennacl::operator/ (matrix_base< NumericT > const &m1, double s1)
 Returns an expression template for scaling the matrix by a double precision floating point number 'alpha'. More...
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_scalar< S1 >::value, matrix_base< NumericT > & >::type viennacl::operator/= (matrix_base< NumericT > &m1, S1 const &gpu_val)
 Scales a matrix by a GPU scalar value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, char gpu_val)
 Scales a matrix by a char (8-bit integer) value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, short gpu_val)
 Scales a matrix by a short integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, int gpu_val)
 Scales a matrix by an integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, long gpu_val)
 Scales a matrix by a long integer value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, float gpu_val)
 Scales a matrix by a single precision floating point value. More...
 
template<typename NumericT >
matrix_base< NumericT > & viennacl::operator/= (matrix_base< NumericT > &m1, double gpu_val)
 Scales a matrix by a double precision floating point value. More...
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_scalar< S1 >::value, viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod >, const S1, op_mult >>::type viennacl::operator* (const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy, const S1 &val)
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_cpu_scalar< S1 >::value, viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod >, const NumericT, op_mult >>::type viennacl::operator* (const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy, const S1 &val)
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_scalar< S1 >::value, viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod >, const S1, op_mult >>::type viennacl::operator* (const S1 &val, const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
 
template<typename NumericT , typename S1 >
viennacl::enable_if< viennacl::is_cpu_scalar< S1 >::value, viennacl::matrix_expression< const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod >, const NumericT, op_mult >>::type viennacl::operator* (const S1 &val, const viennacl::matrix_expression< const vector_base< NumericT >, const vector_base< NumericT >, op_prod > &proxy)
 

Detailed Description

Implementation of the dense matrix class.

Definition in file matrix.hpp.