Skip to content

Conversation

@arima-04
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Jul 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

This looks quite promising.
@PetroZarytskyi, can you take a look and possibly review this PR, too.
@davidlange6, can you check English?

Note that the constructor pullback does not need anything such as
:code:`clad::ConstructorPushforwardTag<::Coordinates>`. It is because
the constructor pullback takes :code:`d_coordinates` as an argument, which can be
used to identify the class for which the constructor pullback is defined.
Copy link
Owner

Choose a reason for hiding this comment

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

Can we add a section on clad::zero?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you meant clad::zero_init?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have mentioned why the constructor pullback custom derivatives does not have the initialization problem.

Currently, the docs does not cover object construction through custom derivatives. I would like to cover this topic as a follow-up PR.


Constructor pullback custom derivatives are more similar to the ordinary pullback
functions. Constructor pullback functions do not have the same problem as of constructor
pushforward functions of initializing the primal object and the derivative object. After all,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sadly, constructor_pullback doesn't have the same problem because the initialization must be done in the forward pass, and so this responsibility lies on constructor_reverse_forw. By the way, we need a section about that. We can often avoid using that by

A a(args);

-->

A a(args);
A da(a);
clad::zero_init(a);

But really, we can only avoid constructor_reverse_forw either for iterable containers, simple numerical structures (no pointer fields) like std::pair, or when the object is initialized with the default constructor. For complex types like std::vector, we rely on constructor_reverse_forw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have mentioned why the pullback constructors does not have the same problem of initialization as of pushforward constructors.

Currently, the docs does not cover object construction through custom derivatives. I would like to cover this topic as a follow-up PR.

@arima-04
Copy link
Contributor Author

Thank you for the detailed reviews @vgvassilev and @PetroZarytskyi. I will implement the reviews soon.

@vgvassilev
Copy link
Owner

@arima-04, ping.

@arima-04 arima-04 force-pushed the CustomDerivativeDocs branch 2 times, most recently from ec8cbaf to 765fb95 Compare August 27, 2025 13:03
@arima-04 arima-04 marked this pull request as draft August 27, 2025 13:04
@arima-04 arima-04 force-pushed the CustomDerivativeDocs branch from 765fb95 to 7e26619 Compare August 27, 2025 13:05
@arima-04 arima-04 force-pushed the CustomDerivativeDocs branch from 7e26619 to 3b0133d Compare August 29, 2025 08:54
@arima-04 arima-04 marked this pull request as ready for review August 29, 2025 09:00
@arima-04
Copy link
Contributor Author

@vgvassilev @PetroZarytskyi Apologies for the delay. I have applied all the reviews suggestions.

@davidlange6
Copy link
Collaborator

for english checking - could you first run the text through google docs and resolve the grammar suggestions that it has (it is likely at least as good as me)

@vgvassilev
Copy link
Owner

@arima-04, ping.

@arima-04
Copy link
Contributor Author

@arima-04, ping.

I will get back to this PR tomorrow. I couldn't get a chance to run the documentation through google docs.

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.

4 participants