26 #define VIENNACL_WITH_UBLAS 
   43 #include <boost/numeric/ublas/vector.hpp> 
   44 #include <boost/numeric/ublas/matrix.hpp> 
   45 #include <boost/numeric/ublas/io.hpp> 
   51 template<
typename MatrixType>
 
   52 double check(MatrixType 
const & qr, MatrixType 
const & ref)
 
   54   bool do_break = 
false;
 
   56   for (std::size_t i=0; i<ref.size1(); ++i)
 
   58     for (std::size_t j=0; j<ref.size2(); ++j)
 
   60       if (qr(i,j) != 0.0 && ref(i,j) != 0.0)
 
   62         double rel_err = fabs(qr(i,j) - ref(i,j)) / fabs(ref(i,j) );
 
   64         if (rel_err > max_error)
 
   89 int main (
int, 
const char **)
 
   92   typedef boost::numeric::ublas::matrix<ScalarType>              MatrixType;
 
   95   std::size_t rows = 113;   
 
   96   std::size_t cols = 54;    
 
  101   MatrixType ublas_A(rows, cols);
 
  102   MatrixType Q(rows, rows);
 
  103   MatrixType R(rows, cols);
 
  106   for (std::size_t i=0; i<rows; ++i)
 
  108     for (std::size_t j=0; j<cols; ++j)
 
  119     for (std::size_t j=0; j<rows; ++j)
 
  124   MatrixType ublas_A_backup(ublas_A);
 
  130   VCLMatrixType vcl_A(ublas_A.size1(), ublas_A.size2());
 
  140   std::cout << 
"--- Boost.uBLAS ---" << std::endl;
 
  147   MatrixType ublas_QR = 
prod(Q, R);
 
  148   double ublas_error = 
check(ublas_QR, ublas_A_backup);
 
  149   std::cout << 
"Maximum relative error (ublas): " << ublas_error << std::endl;
 
  155   std::cout << 
"--- Hybrid (default) ---" << std::endl;
 
  163   Q.clear(); R.clear();
 
  165   double hybrid_error = 
check(ublas_QR, ublas_A_backup);
 
  166   std::cout << 
"Maximum relative error (hybrid): " << hybrid_error << std::endl;
 
  172   std::cout << 
"!!!! TUTORIAL COMPLETED SUCCESSFULLY !!!!" << std::endl;
 
std::vector< T > inplace_qr(viennacl::matrix< T, F, ALIGNMENT > &A, vcl_size_t block_size=16)
Overload of inplace-QR factorization of a ViennaCL matrix A. 
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the dense matrix class. 
int main(int argc, const char *argv[])
std::cout<< "--- ViennaCL (hybrid implementation) ---"<< std::endl;std::vector< ScalarType > hybrid_betas
void recoverQ(MatrixType const &A, VectorType const &betas, MatrixType &Q, MatrixType &R)
Provides a QR factorization using a block-based approach. 
void prod(std::vector< std::map< IndexT, NumericT > > const &stl_A, std::vector< std::map< IndexT, NumericT > > const &stl_B, std::vector< std::map< IndexT, NumericT > > &stl_C)
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) ...
void check(T const &t, U const &u, EpsilonT eps)