ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
viennacl::coordinate_matrix< NumericT, AlignmentV > Class Template Reference

A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row and column indices and val denotes the entry. More...

#include <coordinate_matrix.hpp>

Public Types

typedef
viennacl::backend::mem_handle 
handle_type
 
typedef scalar< typename
viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT
< NumericT >::ResultType > 
value_type
 
typedef vcl_size_t size_type
 

Public Member Functions

 coordinate_matrix ()
 Default construction of a coordinate matrix. No memory is allocated. More...
 
 coordinate_matrix (viennacl::context ctx)
 
 coordinate_matrix (vcl_size_t rows, vcl_size_t cols, vcl_size_t nonzeros=0, viennacl::context ctx=viennacl::context())
 Construction of a coordinate matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated. More...
 
 coordinate_matrix (vcl_size_t rows, vcl_size_t cols, viennacl::context ctx)
 Construction of a coordinate matrix with the supplied number of rows and columns in the supplied context. Does not yet allocate memory. More...
 
void reserve (vcl_size_t new_nonzeros)
 Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved. More...
 
void resize (vcl_size_t new_size1, vcl_size_t new_size2, bool preserve=true)
 Resize the matrix. More...
 
void clear ()
 Resets all entries in the matrix back to zero without changing the matrix size. Resets the sparsity pattern. More...
 
vcl_size_t size1 () const
 Returns the number of rows. More...
 
vcl_size_t size2 () const
 Returns the number of columns. More...
 
vcl_size_t nnz () const
 Returns the number of nonzero entries. More...
 
vcl_size_t internal_nnz () const
 Returns the number of internal nonzero entries. More...
 
const handle_typehandle12 () const
 Returns the OpenCL handle to the (row, column) index array. More...
 
const handle_typehandle () const
 Returns the OpenCL handle to the matrix entry array. More...
 
const handle_typehandle3 () const
 Returns the OpenCL handle to the group start index array. More...
 
vcl_size_t groups () const
 

Friends

template<typename CPUMatrixT , typename NumericT2 , unsigned int AlignmentV2>
void copy (const CPUMatrixT &cpu_matrix, coordinate_matrix< NumericT2, AlignmentV2 > &gpu_matrix)
 

Detailed Description

template<class NumericT, unsigned int AlignmentV>
class viennacl::coordinate_matrix< NumericT, AlignmentV >

A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row and column indices and val denotes the entry.

The present implementation of coordinate_matrix suffers from poor runtime efficiency. Users are adviced to use compressed_matrix in the meanwhile.

Template Parameters
NumericTThe floating point type (either float or double, checked at compile time)
AlignmentVThe internal memory size for the arrays, given by (size()/AlignmentV + 1) * AlignmentV. AlignmentV must be a power of two.
Examples:
iterative.cpp.

Definition at line 186 of file coordinate_matrix.hpp.

Member Typedef Documentation

template<class NumericT, unsigned int AlignmentV>
typedef viennacl::backend::mem_handle viennacl::coordinate_matrix< NumericT, AlignmentV >::handle_type

Definition at line 189 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
typedef vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::size_type

Definition at line 191 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
typedef scalar<typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT<NumericT>::ResultType> viennacl::coordinate_matrix< NumericT, AlignmentV >::value_type

Definition at line 190 of file coordinate_matrix.hpp.

Constructor & Destructor Documentation

template<class NumericT, unsigned int AlignmentV>
viennacl::coordinate_matrix< NumericT, AlignmentV >::coordinate_matrix ( )
inline

Default construction of a coordinate matrix. No memory is allocated.

Definition at line 194 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
viennacl::coordinate_matrix< NumericT, AlignmentV >::coordinate_matrix ( viennacl::context  ctx)
inlineexplicit

Definition at line 196 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
viennacl::coordinate_matrix< NumericT, AlignmentV >::coordinate_matrix ( vcl_size_t  rows,
vcl_size_t  cols,
vcl_size_t  nonzeros = 0,
viennacl::context  ctx = viennacl::context() 
)
inline

Construction of a coordinate matrix with the supplied number of rows and columns. If the number of nonzeros is positive, memory is allocated.

Parameters
rowsNumber of rows
colsNumber of columns
nonzerosOptional number of nonzeros for memory preallocation
ctxOptional context in which the matrix is created (one out of multiple OpenCL contexts, CUDA, host)

Definition at line 219 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
viennacl::coordinate_matrix< NumericT, AlignmentV >::coordinate_matrix ( vcl_size_t  rows,
vcl_size_t  cols,
viennacl::context  ctx 
)
inlineexplicit

Construction of a coordinate matrix with the supplied number of rows and columns in the supplied context. Does not yet allocate memory.

Parameters
rowsNumber of rows
colsNumber of columns
ctxContext in which to create the matrix

Definition at line 251 of file coordinate_matrix.hpp.

Member Function Documentation

template<class NumericT, unsigned int AlignmentV>
void viennacl::coordinate_matrix< NumericT, AlignmentV >::clear ( )
inline

Resets all entries in the matrix back to zero without changing the matrix size. Resets the sparsity pattern.

Definition at line 342 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::groups ( ) const
inline

Definition at line 372 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
const handle_type& viennacl::coordinate_matrix< NumericT, AlignmentV >::handle ( ) const
inline

Returns the OpenCL handle to the matrix entry array.

Definition at line 368 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
const handle_type& viennacl::coordinate_matrix< NumericT, AlignmentV >::handle12 ( ) const
inline

Returns the OpenCL handle to the (row, column) index array.

Definition at line 366 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
const handle_type& viennacl::coordinate_matrix< NumericT, AlignmentV >::handle3 ( ) const
inline

Returns the OpenCL handle to the group start index array.

Definition at line 370 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::internal_nnz ( ) const
inline

Returns the number of internal nonzero entries.

Definition at line 363 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::nnz ( ) const
inline

Returns the number of nonzero entries.

Definition at line 361 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
void viennacl::coordinate_matrix< NumericT, AlignmentV >::reserve ( vcl_size_t  new_nonzeros)
inline

Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved.

Definition at line 270 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
void viennacl::coordinate_matrix< NumericT, AlignmentV >::resize ( vcl_size_t  new_size1,
vcl_size_t  new_size2,
bool  preserve = true 
)
inline

Resize the matrix.

Parameters
new_size1New number of rows
new_size2New number of columns
preserveIf true, the old values are preserved. At present, old values are always discarded.

Definition at line 297 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::size1 ( ) const
inline

Returns the number of rows.

Definition at line 357 of file coordinate_matrix.hpp.

template<class NumericT, unsigned int AlignmentV>
vcl_size_t viennacl::coordinate_matrix< NumericT, AlignmentV >::size2 ( ) const
inline

Returns the number of columns.

Definition at line 359 of file coordinate_matrix.hpp.

Friends And Related Function Documentation

template<class NumericT, unsigned int AlignmentV>
template<typename CPUMatrixT , typename NumericT2 , unsigned int AlignmentV2>
void copy ( const CPUMatrixT &  cpu_matrix,
coordinate_matrix< NumericT2, AlignmentV2 > &  gpu_matrix 
)
friend

The documentation for this class was generated from the following file: