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

Avoid Unnecessary Computation in Products. #77

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

akleeman
Copy link
Collaborator

@akleeman akleeman commented Feb 1, 2019

Only compute the right hand side of a covariance product if the left hand side isn't 0.

This way if you have some covariance function which is complex:

SlowCovarianceFunction slow;

we can then introduce decorrelating product functions,

class OnlyOdd : public CovarianceFunction<OnlyOdd> {
    double call_impl_(const int x, const int y) const {
        if (x % 2 && y %% 2) {
            return 1.;
        } else {
            return 0.;
        }
    }
}

Such that if you then form:

OnlyOdd odd;
auto product = odd * slow;

Evaluation of the slow function in product will only be done for odd numbers.

Copy link
Contributor

@seth-swiftnav seth-swiftnav left a comment

Choose a reason for hiding this comment

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

Looks Great. The description was much more confusing than the code itself.

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