18 #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"
49 using namespace boost::numeric::ublas;
53 int main (
int argc,
const char * argv[])
56 typedef boost::numeric::ublas::matrix<ScalarType, boost::numeric::ublas::column_major> MatrixType;
57 typedef boost::numeric::ublas::vector<ScalarType> VectorType;
62 std::size_t rows = 1800;
63 std::size_t cols = 1800;
64 double num_ops_qr = 2.0 * cols * cols * (rows - cols/3.0);
65 double num_ops_recovery = 4.0 * (rows*rows*cols - rows*cols*cols + cols*cols*cols);
67 MatrixType A(rows, cols);
68 MatrixType Q(rows, rows);
69 MatrixType R(rows, cols);
71 for (std::size_t i=0; i<rows; ++i)
73 for (std::size_t j=0; j<cols; ++j)
75 A(i,j) = 1.0 + (i + 1)*(j+1);
78 for (std::size_t j=0; j<rows; ++j)
88 elapsed = timer.
get();
89 std::cout <<
"Time for QR on CPU: " << elapsed << std::endl;
90 std::cout <<
"Estimated GFLOPs: " << 2e-9 * num_ops_qr/ elapsed << std::endl;
97 elapsed = timer.
get();
98 std::cout <<
"Time for Q-recovery on CPU: " << elapsed << std::endl;
99 std::cout <<
"Estimated GFLOPs: " << 2e-9 * num_ops_recovery / elapsed << std::endl;
int main(int argc, const char *argv[])
void recoverQ(MatrixType const &A, VectorType const &betas, MatrixType &Q, MatrixType &R)
Provides a QR factorization using a block-based approach.
void block_qr(std::vector< std::vector< unsigned int > > &g_I, std::vector< std::vector< unsigned int > > &g_J, block_matrix &g_A_I_J_vcl, block_vector &g_bv_vcl, std::vector< cl_uint > &g_is_update, viennacl::context ctx)
Inplace QR factorization via Householder reflections c.f. Gene H. Golub, Charles F. Van Loan "Matrix Computations" 3rd edition p.224 performed on GPU.