All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bicgstab.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_BICGSTAB_HPP_
#define VIENNACL_LINALG_BICGSTAB_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 <vector>
#include <cmath>
#include <numeric>
#include "viennacl/forwards.h"
#include "viennacl/tools/tools.hpp"
#include "viennacl/linalg/prod.hpp"
#include "viennacl/linalg/inner_prod.hpp"
#include "viennacl/linalg/norm_2.hpp"
#include "viennacl/traits/clear.hpp"
#include "viennacl/traits/size.hpp"
#include "viennacl/traits/context.hpp"
#include "viennacl/meta/result_of.hpp"
#include "viennacl/linalg/iterative_operations.hpp"
namespace viennacl
{
namespace linalg
{
class bicgstab_tag
{
public:
bicgstab_tag(double tol = 1e-8, vcl_size_t max_iters = 400, vcl_size_t max_iters_before_restart = 200)
: tol_(tol), abs_tol_(0), iterations_(max_iters), iterations_before_restart_(max_iters_before_restart) {}
double tolerance() const { return tol_; }
double abs_tolerance() const { return abs_tol_; }
void abs_tolerance(double new_tol) { if (new_tol >= 0) abs_tol_ = new_tol; }
vcl_size_t max_iterations() const { return iterations_; }
vcl_size_t max_iterations_before_restart() const { return iterations_before_restart_; }
vcl_size_t iters() const { return iters_taken_; }
void iters(vcl_size_t i) const { iters_taken_ = i; }
double error() const { return last_error_; }
void error(double e) const { last_error_ = e; }
private:
double tol_;
double abs_tol_;
vcl_size_t iterations_;
vcl_size_t iterations_before_restart_;
//return values from solver
mutable vcl_size_t iters_taken_;
mutable double last_error_;
};
namespace detail
{
template<typename MatrixT, typename NumericT>
viennacl::vector<NumericT> pipelined_solve(MatrixT const & A, //MatrixType const & A,
viennacl::vector_base<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
viennacl::vector<NumericT> result = viennacl::zero_vector<NumericT>(rhs.size(), viennacl::traits::context(rhs));
viennacl::vector<NumericT> residual = rhs;
viennacl::vector<NumericT> p = rhs;
viennacl::vector<NumericT> r0star = rhs;
viennacl::vector<NumericT> Ap = rhs;
viennacl::vector<NumericT> s = rhs;
viennacl::vector<NumericT> As = rhs;
// Layout of temporary buffer:
// chunk 0: <residual, r_0^*>
// chunk 1: <As, As>
// chunk 2: <As, s>
// chunk 3: <Ap, r_0^*>
// chunk 4: <As, r_0^*>
// chunk 5: <s, s>
vcl_size_t buffer_size_per_vector = 256;
vcl_size_t num_buffer_chunks = 6;
viennacl::vector<NumericT> inner_prod_buffer = viennacl::zero_vector<NumericT>(num_buffer_chunks*buffer_size_per_vector, viennacl::traits::context(rhs)); // temporary buffer
std::vector<NumericT> host_inner_prod_buffer(inner_prod_buffer.size());
NumericT norm_rhs_host = viennacl::linalg::norm_2(residual);
NumericT beta;
NumericT alpha;
NumericT omega;
NumericT residual_norm = norm_rhs_host;
inner_prod_buffer[0] = norm_rhs_host * norm_rhs_host;
NumericT r_dot_r0 = 0;
NumericT As_dot_As = 0;
NumericT As_dot_s = 0;
NumericT Ap_dot_r0 = 0;
NumericT As_dot_r0 = 0;
NumericT s_dot_s = 0;
if (norm_rhs_host <= tag.abs_tolerance()) //solution is zero if RHS norm is zero
return result;
for (vcl_size_t i = 0; i < tag.max_iterations(); ++i)
{
tag.iters(i+1);
// Ap = A*p_j
// Ap_dot_r0 = <Ap, r_0^*>
viennacl::linalg::pipelined_bicgstab_prod(A, p, Ap, r0star,
inner_prod_buffer, buffer_size_per_vector, 3*buffer_size_per_vector);
//
//viennacl::fast_copy(inner_prod_buffer.begin(), inner_prod_buffer.end(), host_inner_prod_buffer.begin());
//Ap_dot_r0 = std::accumulate(host_inner_prod_buffer.begin() + buffer_size_per_vector, host_inner_prod_buffer.begin() + 2 * buffer_size_per_vector, ScalarType(0));
//alpha = residual_dot_r0 / Ap_dot_r0;
//s = residual - alpha * Ap;
// s = r - alpha * Ap
// <s, s> first stage
// dump alpha at end of inner_prod_buffer
viennacl::linalg::pipelined_bicgstab_update_s(s, residual, Ap,
inner_prod_buffer, buffer_size_per_vector, 5*buffer_size_per_vector);
// As = A*s_j
// As_dot_As = <As, As>
// As_dot_s = <As, s>
// As_dot_r0 = <As, r_0^*>
viennacl::linalg::pipelined_bicgstab_prod(A, s, As, r0star,
inner_prod_buffer, buffer_size_per_vector, 4*buffer_size_per_vector);
viennacl::fast_copy(inner_prod_buffer.begin(), inner_prod_buffer.end(), host_inner_prod_buffer.begin());
typedef typename std::vector<NumericT>::difference_type difference_type;
r_dot_r0 = std::accumulate(host_inner_prod_buffer.begin(), host_inner_prod_buffer.begin() + difference_type( buffer_size_per_vector), NumericT(0));
As_dot_As = std::accumulate(host_inner_prod_buffer.begin() + difference_type( buffer_size_per_vector), host_inner_prod_buffer.begin() + difference_type(2 * buffer_size_per_vector), NumericT(0));
As_dot_s = std::accumulate(host_inner_prod_buffer.begin() + difference_type(2 * buffer_size_per_vector), host_inner_prod_buffer.begin() + difference_type(3 * buffer_size_per_vector), NumericT(0));
Ap_dot_r0 = std::accumulate(host_inner_prod_buffer.begin() + difference_type(3 * buffer_size_per_vector), host_inner_prod_buffer.begin() + difference_type(4 * buffer_size_per_vector), NumericT(0));
As_dot_r0 = std::accumulate(host_inner_prod_buffer.begin() + difference_type(4 * buffer_size_per_vector), host_inner_prod_buffer.begin() + difference_type(5 * buffer_size_per_vector), NumericT(0));
s_dot_s = std::accumulate(host_inner_prod_buffer.begin() + difference_type(5 * buffer_size_per_vector), host_inner_prod_buffer.begin() + difference_type(6 * buffer_size_per_vector), NumericT(0));
alpha = r_dot_r0 / Ap_dot_r0;
beta = - As_dot_r0 / Ap_dot_r0;
omega = As_dot_s / As_dot_As;
residual_norm = std::sqrt(s_dot_s - NumericT(2.0) * omega * As_dot_s + omega * omega * As_dot_As);
if (monitor && monitor(result, std::fabs(residual_norm / norm_rhs_host), monitor_data))
break;
if (std::fabs(residual_norm / norm_rhs_host) < tag.tolerance() || residual_norm < tag.abs_tolerance())
break;
// x_{j+1} = x_j + alpha * p_j + omega * s_j
// r_{j+1} = s_j - omega * t_j
// p_{j+1} = r_{j+1} + beta * (p_j - omega * q_j)
// and compute first stage of r_dot_r0 = <r_{j+1}, r_o^*> for use in next iteration
viennacl::linalg::pipelined_bicgstab_vector_update(result, alpha, p, omega, s,
residual, As,
beta, Ap,
r0star, inner_prod_buffer, buffer_size_per_vector);
}
//store last error estimate:
tag.error(residual_norm / norm_rhs_host);
return result;
}
template<typename NumericT>
viennacl::vector<NumericT> solve_impl(viennacl::compressed_matrix<NumericT> const & A,
viennacl::vector<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
return pipelined_solve(A, rhs, tag, viennacl::linalg::no_precond(), monitor, monitor_data);
}
template<typename NumericT>
viennacl::vector<NumericT> solve_impl(viennacl::coordinate_matrix<NumericT> const & A,
viennacl::vector<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
return detail::pipelined_solve(A, rhs, tag, viennacl::linalg::no_precond(), monitor, monitor_data);
}
template<typename NumericT>
viennacl::vector<NumericT> solve_impl(viennacl::ell_matrix<NumericT> const & A,
viennacl::vector<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
return detail::pipelined_solve(A, rhs, tag, viennacl::linalg::no_precond(), monitor, monitor_data);
}
template<typename NumericT>
viennacl::vector<NumericT> solve_impl(viennacl::sliced_ell_matrix<NumericT> const & A,
viennacl::vector<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
return detail::pipelined_solve(A, rhs, tag, viennacl::linalg::no_precond(), monitor, monitor_data);
}
template<typename NumericT>
viennacl::vector<NumericT> solve_impl(viennacl::hyb_matrix<NumericT> const & A,
viennacl::vector<NumericT> const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(viennacl::vector<NumericT> const &, NumericT, void*) = NULL,
void *monitor_data = NULL)
{
return detail::pipelined_solve(A, rhs, tag, viennacl::linalg::no_precond(), monitor, monitor_data);
}
template<typename MatrixT, typename VectorT>
VectorT solve_impl(MatrixT const & matrix,
VectorT const & rhs,
bicgstab_tag const & tag,
viennacl::linalg::no_precond,
bool (*monitor)(VectorT const &, typename viennacl::result_of::cpu_value_type<typename viennacl::result_of::value_type<VectorT>::type>::type, void*) = NULL,
void *monitor_data = NULL)
{
typedef typename viennacl::result_of::value_type<VectorT>::type NumericType;
typedef typename viennacl::result_of::cpu_value_type<NumericType>::type CPU_NumericType;
VectorT result = rhs;
viennacl::traits::clear(result);
VectorT residual = rhs;
VectorT p = rhs;
VectorT r0star = rhs;
VectorT tmp0 = rhs;
VectorT tmp1 = rhs;
VectorT s = rhs;
CPU_NumericType norm_rhs_host = viennacl::linalg::norm_2(residual);
CPU_NumericType ip_rr0star = norm_rhs_host * norm_rhs_host;
CPU_NumericType beta;
CPU_NumericType alpha;
CPU_NumericType omega;
//ScalarType inner_prod_temp; //temporary variable for inner product computation
CPU_NumericType new_ip_rr0star = 0;
CPU_NumericType residual_norm = norm_rhs_host;
if (norm_rhs_host <= tag.abs_tolerance()) //solution is zero if RHS norm is zero
return result;
bool restart_flag = true;
vcl_size_t last_restart = 0;
for (vcl_size_t i = 0; i < tag.max_iterations(); ++i)
{
if (restart_flag)
{
residual = viennacl::linalg::prod(matrix, result);
residual = rhs - residual;
p = residual;
r0star = residual;
ip_rr0star = viennacl::linalg::norm_2(residual);
ip_rr0star *= ip_rr0star;
restart_flag = false;
last_restart = i;
}
tag.iters(i+1);
tmp0 = viennacl::linalg::prod(matrix, p);
alpha = ip_rr0star / viennacl::linalg::inner_prod(tmp0, r0star);
s = residual - alpha*tmp0;
tmp1 = viennacl::linalg::prod(matrix, s);
CPU_NumericType norm_tmp1 = viennacl::linalg::norm_2(tmp1);
omega = viennacl::linalg::inner_prod(tmp1, s) / (norm_tmp1 * norm_tmp1);
result += alpha * p + omega * s;
residual = s - omega * tmp1;
new_ip_rr0star = viennacl::linalg::inner_prod(residual, r0star);
residual_norm = viennacl::linalg::norm_2(residual);
if (monitor && monitor(result, std::fabs(residual_norm / norm_rhs_host), monitor_data))
break;
if (std::fabs(residual_norm / norm_rhs_host) < tag.tolerance() || residual_norm < tag.abs_tolerance())
break;
beta = new_ip_rr0star / ip_rr0star * alpha/omega;
ip_rr0star = new_ip_rr0star;
if ( (ip_rr0star <= 0 && ip_rr0star >= 0)
|| (omega <= 0 && omega >= 0)
|| (i - last_restart > tag.max_iterations_before_restart())
) //search direction degenerate. A restart might help
restart_flag = true;
// Execution of
// p = residual + beta * (p - omega*tmp0);
// without introducing temporary vectors:
p -= omega * tmp0;
p = residual + beta * p;
}
//store last error estimate:
tag.error(residual_norm / norm_rhs_host);
return result;
}
template<typename MatrixT, typename VectorT, typename PreconditionerT>
VectorT solve_impl(MatrixT const & matrix,
VectorT const & rhs,
bicgstab_tag const & tag,
PreconditionerT const & precond,
bool (*monitor)(VectorT const &, typename viennacl::result_of::cpu_value_type<typename viennacl::result_of::value_type<VectorT>::type>::type, void*) = NULL,
void *monitor_data = NULL)
{
typedef typename viennacl::result_of::value_type<VectorT>::type NumericType;
typedef typename viennacl::result_of::cpu_value_type<NumericType>::type CPU_NumericType;
VectorT result = rhs;
viennacl::traits::clear(result);
VectorT residual = rhs;
VectorT r0star = residual; //can be chosen arbitrarily in fact
VectorT tmp0 = rhs;
VectorT tmp1 = rhs;
VectorT s = rhs;
VectorT p = residual;
CPU_NumericType ip_rr0star = viennacl::linalg::norm_2(residual);
CPU_NumericType norm_rhs_host = viennacl::linalg::norm_2(residual);
CPU_NumericType beta;
CPU_NumericType alpha;
CPU_NumericType omega;
CPU_NumericType new_ip_rr0star = 0;
CPU_NumericType residual_norm = norm_rhs_host;
if (norm_rhs_host <= tag.abs_tolerance()) //solution is zero if RHS norm is zero
return result;
bool restart_flag = true;
vcl_size_t last_restart = 0;
for (unsigned int i = 0; i < tag.max_iterations(); ++i)
{
if (restart_flag)
{
residual = viennacl::linalg::prod(matrix, result);
residual = rhs - residual;
precond.apply(residual);
p = residual;
r0star = residual;
ip_rr0star = viennacl::linalg::norm_2(residual);
ip_rr0star *= ip_rr0star;
restart_flag = false;
last_restart = i;
}
tag.iters(i+1);
tmp0 = viennacl::linalg::prod(matrix, p);
precond.apply(tmp0);
alpha = ip_rr0star / viennacl::linalg::inner_prod(tmp0, r0star);
s = residual - alpha*tmp0;
tmp1 = viennacl::linalg::prod(matrix, s);
precond.apply(tmp1);
CPU_NumericType norm_tmp1 = viennacl::linalg::norm_2(tmp1);
omega = viennacl::linalg::inner_prod(tmp1, s) / (norm_tmp1 * norm_tmp1);
result += alpha * p + omega * s;
residual = s - omega * tmp1;
residual_norm = viennacl::linalg::norm_2(residual);
if (monitor && monitor(result, std::fabs(residual_norm / norm_rhs_host), monitor_data))
break;
if (residual_norm / norm_rhs_host < tag.tolerance() || residual_norm < tag.abs_tolerance())
break;
new_ip_rr0star = viennacl::linalg::inner_prod(residual, r0star);
beta = new_ip_rr0star / ip_rr0star * alpha/omega;
ip_rr0star = new_ip_rr0star;
if ( (ip_rr0star >= 0 && ip_rr0star <= 0) || (omega >=0 && omega <= 0) || i - last_restart > tag.max_iterations_before_restart()) //search direction degenerate. A restart might help
restart_flag = true;
// Execution of
// p = residual + beta * (p - omega*tmp0);
// without introducing temporary vectors:
p -= omega * tmp0;
p = residual + beta * p;
//std::cout << "Rel. Residual in current step: " << std::sqrt(std::fabs(viennacl::linalg::inner_prod(residual, residual) / norm_rhs_host)) << std::endl;
}
//store last error estimate:
tag.error(residual_norm / norm_rhs_host);
return result;
}
}
template<typename MatrixT, typename VectorT, typename PreconditionerT>
VectorT solve(MatrixT const & matrix, VectorT const & rhs, bicgstab_tag const & tag, PreconditionerT const & precond)
{
return detail::solve_impl(matrix, rhs, tag, precond);
}
template<typename IndexT, typename NumericT, typename PreconditionerT>
std::vector<NumericT> solve(std::vector< std::map<IndexT, NumericT> > const & A, std::vector<NumericT> const & rhs, bicgstab_tag const & tag, PreconditionerT const & precond)
{
viennacl::compressed_matrix<NumericT> vcl_A;
viennacl::copy(A, vcl_A);
viennacl::vector<NumericT> vcl_rhs(rhs.size());
viennacl::copy(rhs, vcl_rhs);
viennacl::vector<NumericT> vcl_result = solve(vcl_A, vcl_rhs, tag, precond);
std::vector<NumericT> result(vcl_result.size());
viennacl::copy(vcl_result, result);
return result;
}
template<typename MatrixT, typename VectorT>
VectorT solve(MatrixT const & matrix, VectorT const & rhs, bicgstab_tag const & tag)
{
return solve(matrix, rhs, tag, viennacl::linalg::no_precond());
}
template<typename VectorT>
class bicgstab_solver
{
public:
typedef typename viennacl::result_of::cpu_value_type<VectorT>::type numeric_type;
bicgstab_solver(bicgstab_tag const & tag) : tag_(tag), monitor_callback_(NULL), user_data_(NULL) {}
template<typename MatrixT, typename PreconditionerT>
VectorT operator()(MatrixT const & A, VectorT const & b, PreconditionerT const & precond) const
{
if (viennacl::traits::size(init_guess_) > 0) // take initial guess into account
{
VectorT mod_rhs = viennacl::linalg::prod(A, init_guess_);
mod_rhs = b - mod_rhs;
VectorT y = detail::solve_impl(A, mod_rhs, tag_, precond, monitor_callback_, user_data_);
return init_guess_ + y;
}
return detail::solve_impl(A, b, tag_, precond, monitor_callback_, user_data_);
}
template<typename MatrixT>
VectorT operator()(MatrixT const & A, VectorT const & b) const
{
return operator()(A, b, viennacl::linalg::no_precond());
}
void set_initial_guess(VectorT const & x) { init_guess_ = x; }
void set_monitor(bool (*monitor_fun)(VectorT const &, numeric_type, void *), void *user_data)
{
monitor_callback_ = monitor_fun;
user_data_ = user_data;
}
bicgstab_tag const & tag() const { return tag_; }
private:
bicgstab_tag tag_;
VectorT init_guess_;
bool (*monitor_callback_)(VectorT const &, numeric_type, void *);
void *user_data_;
};
}
}
#endif
viennacl::hyb_matrix
Sparse matrix class using a hybrid format composed of the ELL and CSR format for storing the nonzeros...
Definition: forwards.h:406
viennacl::linalg::bicgstab_tag::max_iterations_before_restart
vcl_size_t max_iterations_before_restart() const
Returns the maximum number of iterations before a restart.
Definition: bicgstab.hpp:70
viennacl::linalg::norm_2
T norm_2(std::vector< T, A > const &v1)
Definition: norm_2.hpp:96
norm_2.hpp
Generic interface for the l^2-norm. See viennacl/linalg/vector_operations.hpp for implementations...
viennacl::linalg::bicgstab_tag::bicgstab_tag
bicgstab_tag(double tol=1e-8, vcl_size_t max_iters=400, vcl_size_t max_iters_before_restart=200)
The constructor.
Definition: bicgstab.hpp:56
viennacl::linalg::bicgstab_tag::abs_tolerance
void abs_tolerance(double new_tol)
Sets the absolute tolerance.
Definition: bicgstab.hpp:65
size.hpp
Generic size and resize functionality for different vector and matrix types.
prod.hpp
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
tools.hpp
Various little tools used here and there in ViennaCL.
viennacl::linalg::detail::solve_impl
viennacl::vector< NumericT > solve_impl(viennacl::compressed_matrix< NumericT > const &A, viennacl::vector< NumericT > const &rhs, bicgstab_tag const &tag, viennacl::linalg::no_precond, bool(*monitor)(viennacl::vector< NumericT > const &, NumericT, void *)=NULL, void *monitor_data=NULL)
Overload for the pipelined CG implementation for the ViennaCL sparse matrix types.
Definition: bicgstab.hpp:219
viennacl::linalg::bicgstab_tag::error
double error() const
Returns the estimated relative error at the end of the solver run.
Definition: bicgstab.hpp:77
viennacl::traits::clear
void clear(VectorType &vec)
Generic routine for setting all entries of a vector to zero. This is the version for non-ViennaCL obj...
Definition: clear.hpp:43
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::linalg::bicgstab_solver
Definition: bicgstab.hpp:538
viennacl::zero_vector
Definition: vector_def.hpp:93
viennacl::matrix
A dense matrix class.
Definition: forwards.h:375
viennacl::linalg::inner_prod
viennacl::enable_if< viennacl::is_stl< typename viennacl::traits::tag_of< VectorT1 >::type >::value, typename VectorT1::value_type >::type inner_prod(VectorT1 const &v1, VectorT2 const &v2)
Definition: inner_prod.hpp:100
viennacl::linalg::bicgstab_solver::bicgstab_solver
bicgstab_solver(bicgstab_tag const &tag)
Definition: bicgstab.hpp:543
viennacl::linalg::bicgstab_tag::abs_tolerance
double abs_tolerance() const
Returns the absolute tolerance.
Definition: bicgstab.hpp:63
viennacl::result_of::value_type::type
T::value_type type
Definition: result_of.hpp:213
inner_prod.hpp
Generic interface for the computation of inner products. See viennacl/linalg/vector_operations.hpp for implementations.
viennacl::linalg::bicgstab_tag::tolerance
double tolerance() const
Returns the relative tolerance.
Definition: bicgstab.hpp:60
viennacl::linalg::solve
VectorT solve(MatrixT const &matrix, VectorT const &rhs, bicgstab_tag const &tag, PreconditionerT const &precond)
Definition: bicgstab.hpp:496
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl::linalg::pipelined_bicgstab_vector_update
void pipelined_bicgstab_vector_update(vector_base< NumericT > &result, NumericT alpha, vector_base< NumericT > &p, NumericT omega, vector_base< NumericT > const &s, vector_base< NumericT > &residual, vector_base< NumericT > const &As, NumericT beta, vector_base< NumericT > const &Ap, vector_base< NumericT > const &r0star, vector_base< NumericT > &inner_prod_buffer, vcl_size_t buffer_chunk_size)
Performs a joint vector update operation needed for an efficient pipelined BiCGStab algorithm...
Definition: iterative_operations.hpp:171
viennacl::linalg::prod
VectorT prod(std::vector< std::vector< T, A1 >, A2 > const &matrix, VectorT const &vector)
Definition: prod.hpp:102
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::ell_matrix
Sparse matrix class using the ELLPACK format for storing the nonzeros.
Definition: ell_matrix.hpp:53
viennacl::vector_base::begin
iterator begin()
Returns an iterator pointing to the beginning of the vector (STL like)
Definition: vector.hpp:841
viennacl::linalg::no_precond
A tag class representing the use of no preconditioner.
Definition: forwards.h:873
viennacl::linalg::bicgstab_solver::operator()
VectorT operator()(MatrixT const &A, VectorT const &b) const
Definition: bicgstab.hpp:560
viennacl::sliced_ell_matrix
Sparse matrix class using the sliced ELLPACK with parameters C, .
Definition: forwards.h:403
context.hpp
Extracts the underlying context from objects.
viennacl::linalg::bicgstab_solver::set_monitor
void set_monitor(bool(*monitor_fun)(VectorT const &, numeric_type, void *), void *user_data)
Sets a monitor function pointer to be called in each iteration. Set to NULL to run without monitor...
Definition: bicgstab.hpp:578
viennacl::vector_base< NumericT >
viennacl::linalg::bicgstab_solver::tag
bicgstab_tag const & tag() const
Returns the solver tag containing basic configuration such as tolerances, etc.
Definition: bicgstab.hpp:585
viennacl::linalg::detail::pipelined_solve
viennacl::vector< NumericT > pipelined_solve(MatrixT const &A, viennacl::vector_base< NumericT > const &rhs, bicgstab_tag const &tag, viennacl::linalg::no_precond, bool(*monitor)(viennacl::vector< NumericT > const &, NumericT, void *)=NULL, void *monitor_data=NULL)
Implementation of a pipelined stabilized Bi-conjugate gradient solver.
Definition: bicgstab.hpp:98
viennacl::linalg::bicgstab_tag::max_iterations
vcl_size_t max_iterations() const
Returns the maximum number of iterations.
Definition: bicgstab.hpp:68
viennacl::vcl_size_t
std::size_t vcl_size_t
Definition: forwards.h:75
clear.hpp
Generic clear functionality for different vector and matrix types.
viennacl::vector< NumericT >
viennacl::result_of::cpu_value_type::type
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
Definition: result_of.hpp:271
viennacl::linalg::pipelined_bicgstab_prod
void pipelined_bicgstab_prod(MatrixT const &A, vector_base< NumericT > const &p, vector_base< NumericT > &Ap, vector_base< NumericT > const &r0star, vector_base< NumericT > &inner_prod_buffer, vcl_size_t buffer_chunk_size, vcl_size_t buffer_chunk_offset)
Performs a joint vector update operation needed for an efficient pipelined CG algorithm.
Definition: iterative_operations.hpp:208
viennacl::linalg::bicgstab_solver::set_initial_guess
void set_initial_guess(VectorT const &x)
Specifies an initial guess for the iterative solver.
Definition: bicgstab.hpp:569
iterative_operations.hpp
Implementations of specialized routines for the iterative solvers.
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::linalg::bicgstab_solver::numeric_type
viennacl::result_of::cpu_value_type< VectorT >::type numeric_type
Definition: bicgstab.hpp:541
viennacl::result_of::cpu_value_type
Helper meta function for retrieving the main RAM-based value type. Particularly important to obtain T...
Definition: result_of.hpp:269
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::linalg::bicgstab_tag::error
void error(double e) const
Sets the estimated relative error at the end of the solver run.
Definition: bicgstab.hpp:79
viennacl::vector_base::size
size_type size() const
Returns the length of the vector (cf. std::vector)
Definition: vector_def.hpp:118
viennacl::linalg::bicgstab_tag::iters
vcl_size_t iters() const
Return the number of solver iterations:
Definition: bicgstab.hpp:73
viennacl::compressed_matrix< NumericT >
viennacl::linalg::pipelined_bicgstab_update_s
void pipelined_bicgstab_update_s(vector_base< NumericT > &s, vector_base< NumericT > &r, vector_base< NumericT > const &Ap, vector_base< NumericT > &inner_prod_buffer, vcl_size_t buffer_chunk_size, vcl_size_t buffer_chunk_offset)
Performs a joint vector update operation needed for an efficient pipelined CG algorithm.
Definition: iterative_operations.hpp:134
viennacl::linalg::bicgstab_tag::iters
void iters(vcl_size_t i) const
Definition: bicgstab.hpp:74
viennacl::linalg::bicgstab_tag
A tag for the stabilized Bi-conjugate gradient solver. Used for supplying solver parameters and for d...
Definition: bicgstab.hpp:47
viennacl::vector_base::end
iterator end()
Returns an iterator pointing to the end of the vector (STL like)
Definition: vector.hpp:848
result_of.hpp
A collection of compile time type deductions.
viennacl::linalg::bicgstab_solver::operator()
VectorT operator()(MatrixT const &A, VectorT const &b, PreconditionerT const &precond) const
Definition: bicgstab.hpp:546
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
viennacl::fast_copy
void fast_copy(const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_begin, const const_vector_iterator< SCALARTYPE, ALIGNMENT > &gpu_end, CPU_ITERATOR cpu_begin)