Skip to content

Commit

Permalink
let boost come back for now, explicitly make switch_memory_context pu…
Browse files Browse the repository at this point in the history
…blic for vector_base class
  • Loading branch information
cdeterman committed Nov 15, 2016
1 parent a8326af commit 7b990a3
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 3,986 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.Rproj.user
.Rhistory
.RData
local/*.tar.gz
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: RViennaCL
Type: Package
Title: ViennaCL C++ Header Files
Version: 1.7.1.3
Date: 2016-03-07
Version: 1.7.1.4
Date: 2016-11-15
Author: Charles Determan Jr.
Maintainer: Charles Determan Jr <cdetermanjr@gmail.com>
Description: ViennaCL is a free open-source linear algebra library
Expand Down
4 changes: 2 additions & 2 deletions inst/include/viennacl/detail/vector_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class vector_base

/** @brief Resets all entries to zero. Does not change the size of the vector. */
void clear();

void switch_memory_context(viennacl::context new_ctx);

protected:

Expand All @@ -311,8 +313,6 @@ class vector_base
/** @brief Pads vectors with alignment > 1 with trailing zeros if the internal size is larger than the visible size */
void pad();

void switch_memory_context(viennacl::context new_ctx);

//TODO: Think about implementing the following public member functions
//void insert_element(unsigned int i, NumericT val){}
//void erase_element(unsigned int i){}
Expand Down
27 changes: 9 additions & 18 deletions inst/include/viennacl/linalg/qr-method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "viennacl/linalg/tql2.hpp"
#include "viennacl/linalg/prod.hpp"

// #include <boost/numeric/ublas/vector.hpp>
// #include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>

/** @file viennacl/linalg/qr-method.hpp
@brief Implementation of the QR method for eigenvalue computations. Experimental.
Expand Down Expand Up @@ -770,30 +770,21 @@ void update_float_QR_column_gpu(matrix_base<SCALARTYPE> & A,
}


std::vector<std::vector<SCALARTYPE> > eigen_values(A.size1());
for (unsigned int i = 0; i < A.size1(); ++i) {
eigen_values[i].resize(A.size1());
}
// boost::numeric::ublas::matrix<SCALARTYPE> eigen_values(A.size1(), A.size1());
// eigen_values.clear();
boost::numeric::ublas::matrix<SCALARTYPE> eigen_values(A.size1(), A.size1());
eigen_values.clear();

for (vcl_size_t i = 0; i < A.size1(); i++)
{
if(std::fabs(E[i]) < EPS)
{
// eigen_values(i, i) = D[i];
eigen_values[i][i] = D[i];
eigen_values(i, i) = D[i];
}
else
{
// eigen_values(i, i) = D[i];
// eigen_values(i, i + 1) = E[i];
// eigen_values(i + 1, i) = -E[i];
// eigen_values(i + 1, i + 1) = D[i];
eigen_values[i][i] = D[i];
eigen_values[i][i + 1] = E[i];
eigen_values[i + 1][i] = -E[i];
eigen_values[i + 1][i + 1] = D[i];
eigen_values(i, i) = D[i];
eigen_values(i, i + 1) = E[i];
eigen_values(i + 1, i) = -E[i];
eigen_values(i + 1, i + 1) = D[i];
i++;
}
}
Expand Down
25 changes: 9 additions & 16 deletions inst/include/viennacl/linalg/svd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@


// Note: Boost.uBLAS is required at the moment
// #include <boost/numeric/ublas/vector.hpp>
// #include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>


#include <cmath>
Expand Down Expand Up @@ -510,29 +510,22 @@ namespace viennacl
detail::bidiag(A, QL, QR);

// second stage
std::vector<SCALARTYPE> dh(to, 0);
std::vector<SCALARTYPE> sh(to + 1, 0);
// boost::numeric::ublas::vector<SCALARTYPE> dh = boost::numeric::ublas::scalar_vector<SCALARTYPE>(to, 0);
// boost::numeric::ublas::vector<SCALARTYPE> sh = boost::numeric::ublas::scalar_vector<SCALARTYPE>(to + 1, 0);
//std::vector<SCALARTYPE> dh(to, 0);
//std::vector<SCALARTYPE> sh(to + 1, 0);
boost::numeric::ublas::vector<SCALARTYPE> dh = boost::numeric::ublas::scalar_vector<SCALARTYPE>(to, 0);
boost::numeric::ublas::vector<SCALARTYPE> sh = boost::numeric::ublas::scalar_vector<SCALARTYPE>(to + 1, 0);


viennacl::linalg::opencl::bidiag_pack_svd(A, dh, sh);

detail::svd_qr_shift( QL, QR, dh, sh);

// Write resulting diagonal matrix with singular values to A:
// boost::numeric::ublas::matrix<SCALARTYPE> h_Sigma(row_num, col_num);

std::vector<std::vector<SCALARTYPE> > h_Sigma(row_num);
for (unsigned int i = 0; i < row_num; ++i) {
h_Sigma[i].resize(col_num);
}

// h_Sigma.clear();
boost::numeric::ublas::matrix<SCALARTYPE> h_Sigma(row_num, col_num);
h_Sigma.clear();

for (vcl_size_t i = 0; i < to; i++)
// h_Sigma(i, i) = dh[i];
h_Sigma[i][i] = dh[i];
h_Sigma(i, i) = dh[i];

copy(h_Sigma, A);
}
Expand Down
Loading

0 comments on commit 7b990a3

Please sign in to comment.