Coder Social home page Coder Social logo

Comments (9)

spectre-ns avatar spectre-ns commented on July 17, 2024

@tdegeus Yes I have a couple guys on our staff thinking it worked like std::vector is there a limitation to doing this on the underlying storage?

from xtensor.

spectre-ns avatar spectre-ns commented on July 17, 2024

@tdegeus The bottom level storage is just linear memory. Could it be implemented with a std::vector to propagate STL behaviour to some of the interface methods?

from xtensor.

tdegeus avatar tdegeus commented on July 17, 2024

I think even that mostly the underlying IS std::vector so there are surely many cases where we could fix resize to propagate downstream properties. In addition, it would be nice to add push_back to xt::xtensor<T, 1>. Beyond that, were you thinking about more features?

from xtensor.

spectre-ns avatar spectre-ns commented on July 17, 2024

I think in ND we could implement a greedy concatenate using std::vector::insert to avoid the current performance issues.

from xtensor.

tdegeus avatar tdegeus commented on July 17, 2024

From the implementation I think that the underlying resize is used:

c.resize(size);

So I think that for xtensor and xarray resize is item preserving. Could you comment @JohanMabille ?

Edit I tried, indeed elements are not conserved. Yet, as indicated, at first glance I don't see where elements are modified.

from xtensor.

spectre-ns avatar spectre-ns commented on July 17, 2024

@tdegeus I just read the gitter channel and it sounds like it is deferred to the container implementation. How do you propose ensuring that the implementation be element preserving?

from xtensor.

tdegeus avatar tdegeus commented on July 17, 2024

I have no idea yet ;)

from xtensor.

JohanMabille avatar JohanMabille commented on July 17, 2024

Actually the default container for xtensor and xarray is not std::vector, but uvector, which does not preserve its elements when resized.

Anyway, the resize with preserving should be independent from the dimension of the tensor, and should not make any assumption regarding the underlying container. One way to implement it would be to compute the "intersection" shape, and then recursively loop over to copy from the first vector to the other one, and eventually swap the vectors.

(I'll try to post some code later)

from xtensor.

spectre-ns avatar spectre-ns commented on July 17, 2024

@JohanMabille why is std::vector<T> not the underlying data structure? I've had a couple colleagues encounter issues with resizing containers expecting the same behaviour as std::vector<T>.

from xtensor.

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.