Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clad::zero_vector instead of 0 in the vectorized forward mode #1140

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

PetroZarytskyi
Copy link
Collaborator

@PetroZarytskyi PetroZarytskyi commented Nov 14, 2024

This is necessary to ensure type safety. 0 represents a zero vector but is only properly treated as a zero vector when it gets added/subtracted with a clad::array. Initializing a clad::array with 0 will create not a zero vector but an empty array (with zero elements). To fix this, we needed exceptions for all declarations. We would need to make new exceptions when passing parameters to pushforwards.

After merging this PR and #1121, #527 will be fixed automatically.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.48%. Comparing base (6753511) to head (3811bbd).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1140   +/-   ##
=======================================
  Coverage   94.48%   94.48%           
=======================================
  Files          50       50           
  Lines        8850     8850           
=======================================
  Hits         8362     8362           
  Misses        488      488           
Files with missing lines Coverage Δ
...clude/clad/Differentiator/BaseForwardModeVisitor.h 25.00% <ø> (ø)
lib/Differentiator/VectorForwardModeVisitor.cpp 100.00% <100.00%> (ø)
Files with missing lines Coverage Δ
...clude/clad/Differentiator/BaseForwardModeVisitor.h 25.00% <ø> (ø)
lib/Differentiator/VectorForwardModeVisitor.cpp 100.00% <100.00%> (ø)
---- 🚨 Try these New Features:

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@vgvassilev
Copy link
Owner

Now the array is uninitialized.

@vgvassilev
Copy link
Owner

Now the array is uninitialized.

I think I understand the issue -- can you separate this PR into two separate ones?

…ensure type safety.

This is necessary to ensure type safety. ``0`` represents a zero vector but is only properly treated as a zero vector when it gets added/subtracted with a ``clad::array``. Initializing a ``clad::array`` with ``0`` will create not a zero vector but an empty array (with zero elements). To fix this, we needed exceptions for all declarations. We would need to make new exceptions when passing parameters to pushforwards.
Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@vgvassilev vgvassilev merged commit a7de6af into vgvassilev:master Nov 19, 2024
90 checks passed
@PetroZarytskyi PetroZarytskyi deleted the zero_vec branch November 19, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants