Skip to content

ADREPORT( Eigen::SparseMatrix M ) causes compile error #407

@James-Thorson-NOAA

Description

@James-Thorson-NOAA

I'm sure it's a low priority, but it appears that including the code below results in a compile error:

Eigen::SparseMatrix<Type> M; 
ADREPORT( M );

I have worked around this by defining the function:

template<class Type>
vector<Type> get_nonzero_elements( Eigen::SparseMatrix<Type> M ) {
    std::vector<Type> values;

    for (int k = 0; k < M.outerSize(); ++k) {
        for (typename Eigen::SparseMatrix<Type>::InnerIterator it(M, k); it; ++it) {
            values.push_back(it.value());
        }
    }

    return values;  // Return vector of nonzero values if needed
}

and then combining the vector of non-zero values with the triplet form in the R side. However, it might be worth adding an ADREPORT option for Eigen::SparseMatrix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions