This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 703 - AutoDiffScalar: using SparseVector to store the derivatives
Summary: AutoDiffScalar: using SparseVector to store the derivatives
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-06 11:50 UTC by Alexander Werner
Modified: 2019-12-04 12:48 UTC (History)
1 user (show)



Attachments
Patch (3.40 KB, patch)
2013-11-06 11:50 UTC, Alexander Werner
no flags Details | Diff
Revised Patch as described in the reply (6.97 KB, patch)
2013-11-19 17:32 UTC, Alexander Werner
no flags Details | Diff

Description Alexander Werner 2013-11-06 11:50:17 UTC
Created attachment 391 [details]
Patch

In some situations it is convenient to store the derivatives in a sparse vector.
However the causes a lot of memory allocation.
Comment 1 Christoph Hertzberg 2013-11-18 13:56:55 UTC
Sorry for the late answer.

Some comments: 
* Just include SparseCore and don't include any boost headers.
* Indentation style is two spaces (no tabs)
* A unit-test case would be really appreciated!
* What shall happen if dense and sparse derivatives are mixed?

Generally, wouldn't it usually be more efficient to calculate derivatives with dense vectors and possibly extend those to sparse vectors afterwards?
Comment 2 Alexander Werner 2013-11-19 17:27:16 UTC
> * Just include SparseCore and don't include any boost headers.
Fixed.
> * Indentation style is two spaces (no tabs)
Fixed.
> * A unit-test case would be really appreciated!
Fixed.
> * What shall happen if dense and sparse derivatives are mixed?
Still to be resolved.

Added:
> * When I compiled the unit test first it did not compile. Please notice the change in foo<> at the very to of autodiff.cpp - I added the cast of the constant variable. Otherwise my gcc reports:
eigen/unsupported/test/autodiff.cpp: In function ‘Scalar foo(const Scalar&, const Scalar&) [with Scalar = Eigen::AutoDiffScalar<Eigen::Matrix<float, 2, 1, 0, 2, 1> >]’:
eigen/unsupported/test/autodiff.cpp:136:   instantiated from here
eigen/unsupported/test/autodiff.cpp:19: error: ambiguous overload for ‘operator*’ in ‘-5.0e-1 * x’

There is even a bug for that: 279


 
> Generally, wouldn't it usually be more efficient to calculate derivatives with
> dense vectors and possibly extend those to sparse vectors afterwards?
Yes, performance wise I certainly agree. However, using sparse vector
reveals the structure of the gradient. The structure should be constant and
even though elements of the derivative vectors are null for a given point of evaluation, the fact that those exist in the sparse derivative vector shows that
they can be non-zero for other evaluation points.
Comment 3 Alexander Werner 2013-11-19 17:32:00 UTC
Created attachment 393 [details]
Revised Patch as described in the reply
Comment 4 Nobody 2019-12-04 12:48:22 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/703.

Note You need to log in before you can comment on or make changes to this bug.