Giter Site home page Giter Site logo

Comments (3)

strasdat avatar strasdat commented on May 19, 2024

Personally, I do not like c++/Eigen's philosophy to default to the efficient version, instead to the safe one:

int i;
std::cout << i << std::endl; // reading uninitialized value

In practice, there are only few cases where this is a performance bottleneck, and we really don't want to initialize the variable i.

In a perfect world

int i; // initializes to 0
int j [[uninitialized]]; // leaves j uninitialized

I can't change c++ built in types, but I can write libraries in such a way.

Long story short, I'd be okay to add a

static SE3<...> uninitilized();

factory which leaves the element uninitialized, if there is demand for it.

from sophus.

ibtaylor avatar ibtaylor commented on May 19, 2024

Yeah, what I a mess. I thought this was sort of the reason for the new syntax int j{}; http://en.cppreference.com/w/cpp/language/value_initialization

I guess I was thinking about the situation where you have a std::vector of SE3d and want to resize() vs reserve()/push_back(). Afaik, you're forced to pass over and initialize all of the memory during the resize even if you plan on initializing with a loop after if your default constructor fully initializes.

from sophus.

strasdat avatar strasdat commented on May 19, 2024

I'd say reserve()/push_back() is clearly the better approach in general, since you don't have to worry about how expensive the default constructor is for a type Foo.

from sophus.

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.