8000 `ADREPORT( Eigen::SparseMatrix M )` causes compile error · Issue #407 · kaskr/adcomp · GitHub
[go: up one dir, main page]

Skip to content

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

Open

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0