martinResearch / MatlabAutoDiff

A matlab implementation of forward automatic differentiation with operator overloading and sparse jacobians
BSD 3-Clause "New" or "Revised" License
39 stars 12 forks source link

derivative of determinant added #8

Closed gha3mi closed 2 years ago

gha3mi commented 2 years ago

Hello,

Thanks for this great resource.

I have added the derivative of the determinant. Could you check this?

Kind regards, Ali

martinResearch commented 2 years ago

Thank you for the contribution!

There is a minor fix to do to use x.derivatives. Also I would like to have a test around this new code before completing the pull request. Could you please add a test for a matrix of size 3x3

f = @(x) det(x);
CheckAutoDiffJacobian(f, randn(3, 3), 1e-9);

in AutoDiff_tests.m to verify the implementation is right? Thank you!

gha3mi commented 2 years ago

Thank you for the contribution!

There is a minor fix to do to use x.derivatives. Also I would like to have a test around this new code before completing the pull request. Could you please add a test for a matrix of size 3x3

f = @(x) det(x);
CheckAutoDiffJacobian(f, randn(3, 3), 1e-9);

in AutoDiff_tests.m to verify the implementation is right? Thank you!

I implemented two tests for a 3x3 and a 4x4 matrix. It seems that these tests verifies the implementation.

martinResearch commented 2 years ago

Great thank you !