Skip to content

Commit

Permalink
Add test for Jacobian calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletTanyavong committed Nov 13, 2023
1 parent 4bb45ea commit 8ea4654
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Mathematics.NET.Tests/AutoDiff/AutoDiffExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ public void Gradient_ScalarFunction_ReturnsGradient(double x, double y, double z
Assert<Real>.AreApproximatelyEqual(expected, actual, 1e-15);
}

[TestMethod]
[TestCategory("Vector Calculus")]
public void Jacobian_R3VectorFunction_ReturnsJacobian()
{
var u = _tape.CreateVariableVector(1.23, 0.66, 2.34);
Matrix3x3<Real> expected = new(
0.775330615737715, -0.5778557672605755, 0.3080621020764366,
0.2431083191631576, 0.2431083191631576, 0.2431083191631576,
1.450186648348945, 2.197252497498402, -0.6197378839098056);

var actual = _tape.Jacobian(FX, FY, FZ, u);

Assert<Real>.ElementsAreApproximatelyEqual(expected, actual, 1e-15);
}

//
// Helpers
//
Expand Down

0 comments on commit 8ea4654

Please sign in to comment.