I was able to implement the following tutorial using ublas and viennacl for a few different iterative solvers:

https://github.com/viennacl/viennacl-dev/blob/master/examples/tutorial/iterative-ublas.cpp

My issue arose when trying to pass vectors calculated in C++ for the matrix.

// Global Variables

vector< vector<float> > Jacobian(0, vector<float>(0)); //Jacobian matrix

vector<float> delta_PQ; //rhs

//

// Set up some ublas objects

//

ublas::vector<ScalarType> rhs;

ublas::vector<ScalarType> result;

ublas::compressed_matrix<ScalarType> ublas_matrix;

using namespace boost::numeric;

typedef float ScalarType;

// Resize RHS from main program

resize_vector(rhs2, j_dimension);

ublas_matrix2.resize(j_dimension, j_dimension);

//copy content to GPU vector (recommended initialization)

copy(delta_PQ.begin(), delta_PQ.end(), rhs.begin()); //works

copy(Jacobian.begin(), Jacobian.end(), ublas_matrix); //won't compile

The last line throws an error. I tried using this form (below) as well but would need to convert the ublas::compressed_matrix to a viennacl::compressed_matrix.

copy(Jacobian, ublas_matrix);

Doing that results in a bunch of compile errors which I have another discussion topic open about. I have also posted on stackoverflow in hopes someone there will be able to help.

Thanks in advance!