All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
coordinate_matrix.hpp
Go to the documentation of this file.
#ifndef VIENNACL_COORDINATE_MATRIX_HPP_
#define VIENNACL_COORDINATE_MATRIX_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <map>
#include <vector>
#include <list>
#include "viennacl/forwards.h"
#include "viennacl/vector.hpp"
#include "viennacl/linalg/sparse_matrix_operations.hpp"
namespace viennacl
{
//provide copy-operation:
template<typename CPUMatrixT, typename NumericT, unsigned int AlignmentV>
void copy(const CPUMatrixT & cpu_matrix,
coordinate_matrix<NumericT, AlignmentV> & gpu_matrix )
{
assert( (gpu_matrix.size1() == 0 || viennacl::traits::size1(cpu_matrix) == gpu_matrix.size1()) && bool("Size mismatch") );
assert( (gpu_matrix.size2() == 0 || viennacl::traits::size2(cpu_matrix) == gpu_matrix.size2()) && bool("Size mismatch") );
vcl_size_t group_num = 64;
// Step 1: Determine nonzeros:
if ( cpu_matrix.size1() > 0 && cpu_matrix.size2() > 0 )
{
vcl_size_t num_entries = 0;
for (typename CPUMatrixT::const_iterator1 row_it = cpu_matrix.begin1(); row_it != cpu_matrix.end1(); ++row_it)
for (typename CPUMatrixT::const_iterator2 col_it = row_it.begin(); col_it != row_it.end(); ++col_it)
++num_entries;
// Step 2: Set up matrix data:
gpu_matrix.nonzeros_ = num_entries;
gpu_matrix.rows_ = cpu_matrix.size1();
gpu_matrix.cols_ = cpu_matrix.size2();
viennacl::backend::typesafe_host_array<unsigned int> group_boundaries(gpu_matrix.handle3(), group_num + 1);
viennacl::backend::typesafe_host_array<unsigned int> coord_buffer(gpu_matrix.handle12(), 2*gpu_matrix.internal_nnz());
std::vector<NumericT> elements(gpu_matrix.internal_nnz());
vcl_size_t data_index = 0;
vcl_size_t current_fraction = 0;
group_boundaries.set(0, 0);
for (typename CPUMatrixT::const_iterator1 row_it = cpu_matrix.begin1(); row_it != cpu_matrix.end1(); ++row_it)
{
for (typename CPUMatrixT::const_iterator2 col_it = row_it.begin(); col_it != row_it.end(); ++col_it)
{
coord_buffer.set(2*data_index, col_it.index1());
coord_buffer.set(2*data_index + 1, col_it.index2());
elements[data_index] = *col_it;
++data_index;
}
while (data_index > vcl_size_t(static_cast<double>(current_fraction + 1) / static_cast<double>(group_num)) * num_entries) //split data equally over 64 groups
group_boundaries.set(++current_fraction, data_index);
}
//write end of last group:
group_boundaries.set(group_num, data_index);
//group_boundaries[1] = data_index; //for one compute unit
//std::cout << "Group boundaries: " << std::endl;
//for (vcl_size_t i=0; i<group_boundaries.size(); ++i)
// std::cout << group_boundaries[i] << std::endl;
viennacl::backend::memory_create(gpu_matrix.group_boundaries_, group_boundaries.raw_size(), traits::context(gpu_matrix.group_boundaries_), group_boundaries.get());
viennacl::backend::memory_create(gpu_matrix.coord_buffer_, coord_buffer.raw_size(), traits::context(gpu_matrix.coord_buffer_), coord_buffer.get());
viennacl::backend::memory_create(gpu_matrix.elements_, sizeof(NumericT)*elements.size(), traits::context(gpu_matrix.elements_), &(elements[0]));
}
}
template<typename NumericT, unsigned int AlignmentV>
void copy(const std::vector< std::map<unsigned int, NumericT> > & cpu_matrix,
coordinate_matrix<NumericT, AlignmentV> & gpu_matrix )
{
vcl_size_t max_col = 0;
for (vcl_size_t i=0; i<cpu_matrix.size(); ++i)
{
if (cpu_matrix[i].size() > 0)
max_col = std::max<vcl_size_t>(max_col, (cpu_matrix[i].rbegin())->first);
}
viennacl::copy(tools::const_sparse_matrix_adapter<NumericT>(cpu_matrix, cpu_matrix.size(), max_col + 1), gpu_matrix);
}
//gpu to cpu:
template<typename CPUMatrixT, typename NumericT, unsigned int AlignmentV>
void copy(const coordinate_matrix<NumericT, AlignmentV> & gpu_matrix,
CPUMatrixT & cpu_matrix )
{
assert( (viennacl::traits::size1(cpu_matrix) == gpu_matrix.size1()) && bool("Size mismatch") );
assert( (viennacl::traits::size2(cpu_matrix) == gpu_matrix.size2()) && bool("Size mismatch") );
if ( gpu_matrix.size1() > 0 && gpu_matrix.size2() > 0 )
{
//get raw data from memory:
viennacl::backend::typesafe_host_array<unsigned int> coord_buffer(gpu_matrix.handle12(), 2*gpu_matrix.nnz());
std::vector<NumericT> elements(gpu_matrix.nnz());
//std::cout << "GPU nonzeros: " << gpu_matrix.nnz() << std::endl;
viennacl::backend::memory_read(gpu_matrix.handle12(), 0, coord_buffer.raw_size(), coord_buffer.get());
viennacl::backend::memory_read(gpu_matrix.handle(), 0, sizeof(NumericT) * elements.size(), &(elements[0]));
//fill the cpu_matrix:
for (vcl_size_t index = 0; index < gpu_matrix.nnz(); ++index)
cpu_matrix(coord_buffer[2*index], coord_buffer[2*index+1]) = elements[index];
}
}
template<typename NumericT, unsigned int AlignmentV>
void copy(const coordinate_matrix<NumericT, AlignmentV> & gpu_matrix,
std::vector< std::map<unsigned int, NumericT> > & cpu_matrix)
{
if (cpu_matrix.size() == 0)
cpu_matrix.resize(gpu_matrix.size1());
assert(cpu_matrix.size() == gpu_matrix.size1() && bool("Matrix dimension mismatch!"));
tools::sparse_matrix_adapter<NumericT> temp(cpu_matrix, gpu_matrix.size1(), gpu_matrix.size2());
copy(gpu_matrix, temp);
}
template<class NumericT, unsigned int AlignmentV /* see forwards.h */ >
class coordinate_matrix
{
public:
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;
coordinate_matrix() : rows_(0), cols_(0), nonzeros_(0), group_num_(64) {}
explicit coordinate_matrix(viennacl::context ctx) : rows_(0), cols_(0), nonzeros_(0), group_num_(64)
{
group_boundaries_.switch_active_handle_id(ctx.memory_type());
coord_buffer_.switch_active_handle_id(ctx.memory_type());
elements_.switch_active_handle_id(ctx.memory_type());
#ifdef VIENNACL_WITH_OPENCL
if (ctx.memory_type() == OPENCL_MEMORY)
{
group_boundaries_.opencl_handle().context(ctx.opencl_context());
coord_buffer_.opencl_handle().context(ctx.opencl_context());
elements_.opencl_handle().context(ctx.opencl_context());
}
#endif
}
coordinate_matrix(vcl_size_t rows, vcl_size_t cols, vcl_size_t nonzeros = 0, viennacl::context ctx = viennacl::context()) :
rows_(rows), cols_(cols), nonzeros_(nonzeros)
{
if (nonzeros > 0)
{
viennacl::backend::memory_create(group_boundaries_, viennacl::backend::typesafe_host_array<unsigned int>().element_size() * (group_num_ + 1), ctx);
viennacl::backend::memory_create(coord_buffer_, viennacl::backend::typesafe_host_array<unsigned int>().element_size() * 2 * internal_nnz(), ctx);
viennacl::backend::memory_create(elements_, sizeof(NumericT) * internal_nnz(), ctx);
}
else
{
group_boundaries_.switch_active_handle_id(ctx.memory_type());
coord_buffer_.switch_active_handle_id(ctx.memory_type());
elements_.switch_active_handle_id(ctx.memory_type());
#ifdef VIENNACL_WITH_OPENCL
if (ctx.memory_type() == OPENCL_MEMORY)
{
group_boundaries_.opencl_handle().context(ctx.opencl_context());
coord_buffer_.opencl_handle().context(ctx.opencl_context());
elements_.opencl_handle().context(ctx.opencl_context());
}
#endif
}
}
explicit coordinate_matrix(vcl_size_t rows, vcl_size_t cols, viennacl::context ctx)
: rows_(rows), cols_(cols), nonzeros_(0)
{
group_boundaries_.switch_active_handle_id(ctx.memory_type());
coord_buffer_.switch_active_handle_id(ctx.memory_type());
elements_.switch_active_handle_id(ctx.memory_type());
#ifdef VIENNACL_WITH_OPENCL
if (ctx.memory_type() == OPENCL_MEMORY)
{
group_boundaries_.opencl_handle().context(ctx.opencl_context());
coord_buffer_.opencl_handle().context(ctx.opencl_context());
elements_.opencl_handle().context(ctx.opencl_context());
}
#endif
}
void reserve(vcl_size_t new_nonzeros)
{
if (new_nonzeros > nonzeros_) //TODO: Do we need to initialize new memory with zero?
{
handle_type coord_buffer_old;
handle_type elements_old;
viennacl::backend::memory_shallow_copy(coord_buffer_, coord_buffer_old);
viennacl::backend::memory_shallow_copy(elements_, elements_old);
vcl_size_t internal_new_nnz = viennacl::tools::align_to_multiple<vcl_size_t>(new_nonzeros, AlignmentV);
viennacl::backend::typesafe_host_array<unsigned int> size_deducer(coord_buffer_);
viennacl::backend::memory_create(coord_buffer_, size_deducer.element_size() * 2 * internal_new_nnz, viennacl::traits::context(coord_buffer_));
viennacl::backend::memory_create(elements_, sizeof(NumericT) * internal_new_nnz, viennacl::traits::context(elements_));
viennacl::backend::memory_copy(coord_buffer_old, coord_buffer_, 0, 0, size_deducer.element_size() * 2 * nonzeros_);
viennacl::backend::memory_copy(elements_old, elements_, 0, 0, sizeof(NumericT) * nonzeros_);
nonzeros_ = new_nonzeros;
}
}
void resize(vcl_size_t new_size1, vcl_size_t new_size2, bool preserve = true)
{
assert (new_size1 > 0 && new_size2 > 0);
if (new_size1 < rows_ || new_size2 < cols_) //enlarge buffer
{
std::vector<std::map<unsigned int, NumericT> > stl_sparse_matrix;
if (rows_ > 0)
stl_sparse_matrix.resize(rows_);
if (preserve && rows_ > 0)
viennacl::copy(*this, stl_sparse_matrix);
stl_sparse_matrix.resize(new_size1);
//std::cout << "Cropping STL matrix of size " << stl_sparse_matrix.size() << std::endl;
if (new_size2 < cols_ && rows_ > 0)
{
for (vcl_size_t i=0; i<stl_sparse_matrix.size(); ++i)
{
std::list<unsigned int> to_delete;
for (typename std::map<unsigned int, NumericT>::iterator it = stl_sparse_matrix[i].begin();
it != stl_sparse_matrix[i].end();
++it)
{
if (it->first >= new_size2)
to_delete.push_back(it->first);
}
for (std::list<unsigned int>::iterator it = to_delete.begin(); it != to_delete.end(); ++it)
stl_sparse_matrix[i].erase(*it);
}
//std::cout << "Cropping done..." << std::endl;
}
rows_ = new_size1;
cols_ = new_size2;
viennacl::copy(stl_sparse_matrix, *this);
}
rows_ = new_size1;
cols_ = new_size2;
}
void clear()
{
viennacl::backend::typesafe_host_array<unsigned int> host_group_buffer(group_boundaries_, 65);
viennacl::backend::typesafe_host_array<unsigned int> host_coord_buffer(coord_buffer_, 2);
std::vector<NumericT> host_elements(1);
viennacl::backend::memory_create(group_boundaries_, host_group_buffer.element_size() * 65, viennacl::traits::context(group_boundaries_), host_group_buffer.get());
viennacl::backend::memory_create(coord_buffer_, host_coord_buffer.element_size() * 2, viennacl::traits::context(coord_buffer_), host_coord_buffer.get());
viennacl::backend::memory_create(elements_, sizeof(NumericT) * 1, viennacl::traits::context(elements_), &(host_elements[0]));
nonzeros_ = 0;
group_num_ = 64;
}
vcl_size_t size1() const { return rows_; }
vcl_size_t size2() const { return cols_; }
vcl_size_t nnz() const { return nonzeros_; }
vcl_size_t internal_nnz() const { return viennacl::tools::align_to_multiple<vcl_size_t>(nonzeros_, AlignmentV); }
const handle_type & handle12() const { return coord_buffer_; }
const handle_type & handle() const { return elements_; }
const handle_type & handle3() const { return group_boundaries_; }
vcl_size_t groups() const { return group_num_; }
#if defined(_MSC_VER) && _MSC_VER < 1500 //Visual Studio 2005 needs special treatment
template<typename CPUMatrixT>
friend void copy(const CPUMatrixT & cpu_matrix, coordinate_matrix & gpu_matrix );
#else
template<typename CPUMatrixT, typename NumericT2, unsigned int AlignmentV2>
friend void copy(const CPUMatrixT & cpu_matrix, coordinate_matrix<NumericT2, AlignmentV2> & gpu_matrix );
#endif
private:
coordinate_matrix(coordinate_matrix const &);
coordinate_matrix & operator=(coordinate_matrix const &);
vcl_size_t rows_;
vcl_size_t cols_;
vcl_size_t nonzeros_;
vcl_size_t group_num_;
handle_type coord_buffer_;
handle_type elements_;
handle_type group_boundaries_;
};
//
// Specify available operations:
//
namespace linalg
{
namespace detail
{
// x = A * y
template<typename T, unsigned int A>
struct op_executor<vector_base<T>, op_assign, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> const & rhs)
{
// check for the special case x = A * x
if (viennacl::traits::handle(lhs) == viennacl::traits::handle(rhs.rhs()))
{
viennacl::vector<T> temp(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(1), temp, T(0));
lhs = temp;
}
else
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(1), lhs, T(0));
}
};
template<typename T, unsigned int A>
struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> const & rhs)
{
// check for the special case x += A * x
if (viennacl::traits::handle(lhs) == viennacl::traits::handle(rhs.rhs()))
{
viennacl::vector<T> temp(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(1), temp, T(0));
lhs += temp;
}
else
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(1), lhs, T(1));
}
};
template<typename T, unsigned int A>
struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_base<T>, op_prod> const & rhs)
{
// check for the special case x -= A * x
if (viennacl::traits::handle(lhs) == viennacl::traits::handle(rhs.rhs()))
{
viennacl::vector<T> temp(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(1), temp, T(0));
lhs -= temp;
}
else
viennacl::linalg::prod_impl(rhs.lhs(), rhs.rhs(), T(-1), lhs, T(1));
}
};
// x = A * vec_op
template<typename T, unsigned int A, typename LHS, typename RHS, typename OP>
struct op_executor<vector_base<T>, op_assign, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> const & rhs)
{
viennacl::vector<T> temp(rhs.rhs(), viennacl::traits::context(rhs));
viennacl::linalg::prod_impl(rhs.lhs(), temp, lhs);
}
};
// x += A * vec_op
template<typename T, unsigned int A, typename LHS, typename RHS, typename OP>
struct op_executor<vector_base<T>, op_inplace_add, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> const & rhs)
{
viennacl::vector<T> temp(rhs.rhs(), viennacl::traits::context(rhs));
viennacl::vector<T> temp_result(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), temp, temp_result);
lhs += temp_result;
}
};
// x -= A * vec_op
template<typename T, unsigned int A, typename LHS, typename RHS, typename OP>
struct op_executor<vector_base<T>, op_inplace_sub, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> >
{
static void apply(vector_base<T> & lhs, vector_expression<const coordinate_matrix<T, A>, const vector_expression<const LHS, const RHS, OP>, op_prod> const & rhs)
{
viennacl::vector<T> temp(rhs.rhs(), viennacl::traits::context(rhs));
viennacl::vector<T> temp_result(lhs);
viennacl::linalg::prod_impl(rhs.lhs(), temp, temp_result);
lhs -= temp_result;
}
};
} // namespace detail
} // namespace linalg
}
#endif
viennacl::backend::typesafe_host_array
Helper class implementing an array on the host. Default case: No conversion necessary.
Definition: util.hpp:92
viennacl::backend::typesafe_host_array::element_size
vcl_size_t element_size() const
Definition: util.hpp:112
viennacl::scalar
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:227
viennacl::coordinate_matrix::handle12
const handle_type & handle12() const
Returns the OpenCL handle to the (row, column) index array.
Definition: coordinate_matrix.hpp:366
viennacl::traits::size1
vcl_size_t size1(MatrixType const &mat)
Generic routine for obtaining the number of rows of a matrix (ViennaCL, uBLAS, etc.)
Definition: size.hpp:163
viennacl::coordinate_matrix::coordinate_matrix
coordinate_matrix(viennacl::context ctx)
Definition: coordinate_matrix.hpp:196
viennacl::coordinate_matrix::coordinate_matrix
coordinate_matrix()
Default construction of a coordinate matrix. No memory is allocated.
Definition: coordinate_matrix.hpp:194
viennacl::OPENCL_MEMORY
Definition: forwards.h:349
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::coordinate_matrix::nnz
vcl_size_t nnz() const
Returns the number of nonzero entries.
Definition: coordinate_matrix.hpp:361
viennacl::backend::typesafe_host_array::get
void * get()
Definition: util.hpp:110
viennacl::backend::memory_read
void memory_read(mem_handle const &src_buffer, vcl_size_t src_offset, vcl_size_t bytes_to_read, void *ptr, bool async=false)
Reads data from a buffer back to main RAM.
Definition: memory.hpp:261
viennacl::coordinate_matrix::resize
void resize(vcl_size_t new_size1, vcl_size_t new_size2, bool preserve=true)
Resize the matrix.
Definition: coordinate_matrix.hpp:297
viennacl::traits::size2
result_of::size_type< MatrixType >::type size2(MatrixType const &mat)
Generic routine for obtaining the number of columns of a matrix (ViennaCL, uBLAS, etc...
Definition: size.hpp:201
viennacl::backend::detail::element_size
vcl_size_t element_size(memory_types)
Definition: memory.hpp:299
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl::context
Represents a generic 'context' similar to an OpenCL context, but is backend-agnostic and thus also su...
Definition: context.hpp:39
viennacl::coordinate_matrix::internal_nnz
vcl_size_t internal_nnz() const
Returns the number of internal nonzero entries.
Definition: coordinate_matrix.hpp:363
viennacl::coordinate_matrix::coordinate_matrix
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 no...
Definition: coordinate_matrix.hpp:219
viennacl::traits::size
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
Definition: size.hpp:239
viennacl::coordinate_matrix::size2
vcl_size_t size2() const
Returns the number of columns.
Definition: coordinate_matrix.hpp:359
viennacl::coordinate_matrix::value_type
scalar< typename viennacl::tools::CHECK_SCALAR_TEMPLATE_ARGUMENT< NumericT >::ResultType > value_type
Definition: coordinate_matrix.hpp:190
viennacl::coordinate_matrix::size_type
vcl_size_t size_type
Definition: coordinate_matrix.hpp:191
sparse_matrix_operations.hpp
Implementations of operations using sparse matrices.
viennacl::coordinate_matrix::handle_type
viennacl::backend::mem_handle handle_type
Definition: coordinate_matrix.hpp:189
viennacl::tools::const_sparse_matrix_adapter
Adapts a constant sparse matrix type made up from std::vector<std::map<SizeT, NumericT> > to basic ub...
Definition: adapter.hpp:183
viennacl::coordinate_matrix::clear
void clear()
Resets all entries in the matrix back to zero without changing the matrix size. Resets the sparsity p...
Definition: coordinate_matrix.hpp:342
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
viennacl::vector
Definition: forwards.h:266
viennacl::coordinate_matrix::handle3
const handle_type & handle3() const
Returns the OpenCL handle to the group start index array.
Definition: coordinate_matrix.hpp:370
viennacl::context::memory_type
viennacl::memory_types memory_type() const
Definition: context.hpp:76
viennacl::coordinate_matrix::copy
friend void copy(const CPUMatrixT &cpu_matrix, coordinate_matrix< NumericT2, AlignmentV2 > &gpu_matrix)
viennacl::backend::mem_handle::switch_active_handle_id
void switch_active_handle_id(memory_types new_id)
Switches the currently active handle. If no support for that backend is provided, an exception is thr...
Definition: mem_handle.hpp:121
viennacl::backend::memory_copy
void memory_copy(mem_handle const &src_buffer, mem_handle &dst_buffer, vcl_size_t src_offset, vcl_size_t dst_offset, vcl_size_t bytes_to_copy)
Copies 'bytes_to_copy' bytes from address 'src_buffer + src_offset' to memory starting at address 'ds...
Definition: memory.hpp:140
viennacl::coordinate_matrix::reserve
void reserve(vcl_size_t new_nonzeros)
Allocate memory for the supplied number of nonzeros in the matrix. Old values are preserved...
Definition: coordinate_matrix.hpp:270
viennacl::traits::context
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
Definition: context.hpp:40
viennacl::coordinate_matrix::handle
const handle_type & handle() const
Returns the OpenCL handle to the matrix entry array.
Definition: coordinate_matrix.hpp:368
vector.hpp
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
viennacl::copy
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
Definition: circulant_matrix.hpp:150
viennacl::backend::typesafe_host_array::set
void set(vcl_size_t index, U value)
Definition: util.hpp:115
viennacl::coordinate_matrix::groups
vcl_size_t groups() const
Definition: coordinate_matrix.hpp:372
viennacl::backend::mem_handle
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Definition: mem_handle.hpp:89
viennacl::backend::mem_handle::raw_size
vcl_size_t raw_size() const
Returns the number of bytes of the currently active buffer.
Definition: mem_handle.hpp:230
viennacl::tools::sparse_matrix_adapter
Adapts a non-const sparse matrix type made up from std::vector<std::map<SizeT, NumericT> > to basic u...
Definition: adapter.hpp:357
viennacl::coordinate_matrix::coordinate_matrix
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 cont...
Definition: coordinate_matrix.hpp:251
viennacl::backend::memory_create
void memory_create(mem_handle &handle, vcl_size_t size_in_bytes, viennacl::context const &ctx, const void *host_ptr=NULL)
Creates an array of the specified size. If the second argument is provided, the buffer is initialized...
Definition: memory.hpp:87
viennacl::linalg::prod_impl
void prod_impl(const matrix_base< NumericT > &mat, const vector_base< NumericT > &vec, vector_base< NumericT > &result)
Carries out matrix-vector multiplication.
Definition: matrix_operations.hpp:438
viennacl::traits::handle
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41
viennacl::coordinate_matrix::size1
vcl_size_t size1() const
Returns the number of rows.
Definition: coordinate_matrix.hpp:357
op_assign
Definition: self_assign.cpp:132
viennacl::backend::memory_shallow_copy
void memory_shallow_copy(mem_handle const &src_buffer, mem_handle &dst_buffer)
A 'shallow' copy operation from an initialized buffer to an uninitialized buffer. The uninitialized b...
Definition: memory.hpp:177
viennacl::coordinate_matrix
A sparse square matrix, where entries are stored as triplets (i,j, val), where i and j are the row an...
Definition: coordinate_matrix.hpp:186