Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

function takes either array or a view #75

Copy link
Copy link
@nbecker

Description

@nbecker
Issue body actions

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?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.