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

DM-14725: Eliminate explicit use of ndarray::EigenView in C++ code #58

Merged
merged 2 commits into from Jun 8, 2018

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented Jun 7, 2018

No description provided.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

A few changes requested, but nothing major.

ndarray::EigenView<Scalar,1,1,Eigen::ArrayXpr> _data;
ndarray::EigenView<Scalar,1,1,Eigen::ArrayXpr> _arg;
ndarray::Array<Scalar,1,1> _data; // ArrayXpr
ndarray::Array<Scalar,1,1> _arg; // ArrayXpr
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand these comments.

Copy link
Contributor Author

@r-owen r-owen Jun 8, 2018

Choose a reason for hiding this comment

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

I think they were placeholders. I'll remove them on DM-14625 (since I jumped the gun and merged this branch before I realized you had any suggested changes).

}

virtual bool differentiateResiduals(
ndarray::Array<Scalar const,1,1> const & parameters,
ndarray::Array<Scalar,2,-2> const & derivatives
) const {
ndarray::EigenView<Scalar,2,-2,Eigen::ArrayXpr> d(derivatives);
auto d = derivatives.asEigen<Eigen::ArrayXpr>();
auto argEigen = _arg.asEigen<Eigen::ArrayXpr>();
Copy link
Member

Choose a reason for hiding this comment

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

You end up doing these conversions a lot. Consider using private getters or simply letting the types of _data and _arg break when you switch to Eigen::Map.

Copy link
Contributor Author

@r-owen r-owen Jun 8, 2018

Choose a reason for hiding this comment

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

The plan is as follows: add asEigenArray and asEigenMatrix to ndarray::Array; these will both return Eigen::Map. Then eliminate all use of asEigen in our code, which will eliminate all use of ndarray::EigenView. We can then remove EigenView from ndarray ((at least conditionally when ndarray is built against too new a version of Eigen, but as far as LSST is concerned it will go away).

Copy link
Member

Choose a reason for hiding this comment

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

How does that reduce the code duplication of translating _data and _arg to Eigen::Map every time you want to use them?

ndarray::EigenView<Pixel const,1,1,Eigen::ArrayXpr> const & variance
ndarray::Array<Pixel const,1,1> const & model,
ndarray::Array<Pixel const,1,1> const & data,
ndarray::Array<Pixel const,1,1> const & variance
Copy link
Member

Choose a reason for hiding this comment

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

👍 for separation of interface and implementation.

@r-owen r-owen merged commit f3e751c into master Jun 8, 2018
@ktlim ktlim deleted the tickets/DM-14725 branch August 25, 2018 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants