Skip to content

function takes either array or a view #75

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

Open
nbecker opened this issue Mar 31, 2017 · 0 comments
Open

function takes either array or a view #75

nbecker opened this issue Mar 31, 2017 · 0 comments

Comments

@nbecker
Copy link
Contributor

nbecker commented Mar 31, 2017

I tried coding this to find max_element using a binary search:

template<typename flt_t>
flt_t max_element2 (nd::Array<flt_t,1,1> const& in) {
  if (boost::size(in) == 1)
    return in[0];
  else {
    flt_t a = max_element2 (in[nd::view(0,boost::size(in)/2)]);
    flt_t b = max_element2 (in[nd::view(boost::size(in)/2)()]);
    return std::max (a, b);
  }
}

But it doesn't compile, because the recursive call passing a view doesn't match the function sig. I also tried ArrayRef, but same result. What is the correct way to code this?

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

No branches or pull requests

1 participant