template <class SizeVector, class ValueVector, int Options>
void sparse2eigen(
const CppAD::sparse_rcv<SizeVector, ValueVector>& source ,
Eigen::SparseMatrix<typename ValueVector::value_type, Options>& destination )
Include
If include_eigen
is specified on the cmake command line,
the file cppad/utility/sparse2eigen.hpp
is included by cppad/cppad.hpp.
In any case,
it can also be included separately with out the rest of
the CppAD routines.
Including this file defines
this version of the sparse2eigen within the CppAD namespace.
ValueVector
We use
ValueVector
to denote a
SimpleVector
class with elements of type
value_type
.
Options
We use
Options
to denote either
Eigen::RowMajor of Eigen::ColMajor.
value_type
The type of elements of elements in
source
and
destination
must be the same. We use
value_type
to denote this type.
source
This is the CppAD sparse matrix that is being converted to eigen format.
destination
This is the Eigen sparse matrix that is the result of the conversion.
Compressed
The result matrix
destination
is in compressed format. For example, let
size_t nnz = source.nnz();
const s_vector& s_value = source.val();
const value_type* d_value = destination.valuePtr();
const s_vector& row_major = source.row_major();
const s_vector& col_major = source.col_major();
It follows that, for
k = 0 , ..., nnz
:
If
Options
is Eigen::RowMajor,
d_value[k] == s_value[ row_major[k] ]
If
Options
is Eigen::ColMajor,
d_value[k] == s_value[ col_major[k] ]
Example
The file sparse2eigen.cpp
contains an example and test
of sparse2eigen.cpp It return true if the test passes
and false otherwise.
Input File: include/cppad/utility/sparse2eigen.hpp