Giter Club home page Giter Club logo

Comments (2)

brevzin avatar brevzin commented on June 3, 2024

I'm not familiar with Eigen.

to() was standardized from C++23, you can find the mechanism for how it works here. In short, if C is the destination type and r is the source range, it'll try to do (in order):

  1. C(r)
  2. C(from_range, r)
  3. C(ranges::begin(r), ranges::end(r))
  4. C c; /* try to reserve */; ranges::copy(r, /* inserter into c */);
  5. A more complicated thing for recursion

It looks like option (4) there might work for Eigen::VectorXd, does it? If so we could try to extend the implementation here to do something similar.

range-v3 right now tries to do

  1. C c; r.reserve(ranges::size(r)); c.assign(ranges::begin(r), ranges::end(r));
  2. C(ranges::begin(r), ranges::end(r))

from range-v3.

hwelzel avatar hwelzel commented on June 3, 2024

Thanks for all the info!
Indeed option 4 should work with Eigen. Its pretty much what I do in my custom function in the original comment as you noted.

I tried with c++23 std::ranges::to (should've done before) but unfortunately it doesn't compile.
https://godbolt.org/z/rsd8bdEKc
So I am not sure that in the end it would work with ranges-v3 either. Maybe Eigen would need to do something as well.

from range-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.