[WIP] Adds specializations for handling sparse matrix unary operations
Summary
This is a WIP for supporting sparse matrix unary operations in Stan math. Related to #2597 , this API will return a sparse matrix with all values filled in for sparse matrices when the function does not have a f(0) -> 0 mapping. The scheme here just adds a bool ApplyZero template parameter to apply_scalar_unary where if ApplyZero is true, a dense matrix is returned and for false a sparse matrix is returned.
Though note if we want to change the API to always be Sparse -> Sparse that's pretty easy here
Tests
The tests have been modified for atan() and acos() to take a vector input and the usual lambda functor we use for testing and make a sparse matrix with the vector values along the diagonal via a helper function make_sparse_mat_func().
Side Effects
Release notes
Adds support for Unary sparse matrix functions
Checklist
-
[x] Math issue #2597
-
[x] Copyright holder: Steve Bronder
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses: - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause) - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
-
[x] the basic tests are passing
- unit tests pass (to run, use:
./runTests.py test/unit) - header checks pass, (
make test-headers) - dependencies checks pass, (
make test-math-dependencies) - docs build, (
make doxygen) - code passes the built in C++ standards checks (
make cpplint)
- unit tests pass (to run, use:
-
[x] the code is written in idiomatic C++ and changes are documented in the doxygen
-
[x] the new changes are tested
@andrjohns would you mind taking a look at this?
Moving to draft; it's still marked at "WIP." Please move it out of draft when you're ready.