Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:12:56+00:00 2026-06-10T22:12:56+00:00

I am using the Eigen 3.1.1 library and MS Visual C++ 2010. I would

  • 0

I am using the Eigen 3.1.1 library and MS Visual C++ 2010. I would like to implement a simple concurrent buffer that controls access to an element of a generic type T.

As I am working with Eigen types the new operator of the concurrent buffer must be overloaded if the buffer is instantiated with a fixed-size vectorizable Eigen type. See also:
Structures Having Eigen Members.

#include <boost/thread.hpp>
#include <Eigen/Geometry>   // required for the eigen macro

// abstract base class for all buffers
template <class T>
class ConcurrentBuffer
{
public:
    // virtual destructor to allow subclassing
    virtual ~ConcurrentBuffer(){}

    //virtual void get(T& elem) = 0;
    //virtual void put(const T& elem) = 0;
};


template<class T>
class SingleElementStorage : public ConcurrentBuffer<T>
{
public:
    // For fixed-size vect. Eigen types:
    typedef T Elem_type;
    enum { NeedsToAlign = (sizeof(Elem_type)%16)==0 };
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)


    SingleElementStorage() {}
    ~SingleElementStorage() {}

    //void get(T& elem);
    //void put(const T& elem);

private:
    T elem_;
    boost::shared_mutex mutex_;
};

This code compiles fine with MSVC++. My question is if this is the best way to realize such a buffer. Actually this code also compiles if only EIGEN_MAKE_ALIGNED_OPERATOR_NEW is used and the typedef and the enum are removed.

So why should I not simply put EIGEN_MAKE_ALIGNED_OPERATOR_NEW in every struct/class of my project?

Another related question: Is it somehow possible to put the macro into the abstract base class “ConcurrentBuffer” so that all derived classes do not need to add eigen specific implementations?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:12:57+00:00Added an answer on June 10, 2026 at 10:12 pm

    I glanced at the macro definition and it seems, that you don´t need to do the NeedsToAlign part on your side. Eigen is doing it already for you. It is also stated in the Eigen documentation to just use the macro alone (so why would this not be a good solution?).

    Regarding your second question: The operator new will be declared without virtual, so I suppose(!) it will not work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to implement using eigen something like (pseudocode): A = BooleanExpr(X)
I would like to use the Eigen matrix library as the linear algebra engine
I'm using eigen library to rotate a plane to be parallel to the ground
Using Rails 3.2.0 with haml and sass: I Would like to link an external
When I create a matrix using Eigen, like this: Eigen::MatrixXd M(3,3); M<< 1.0, 4.0,
I'm using eigen matrix library. How can I convert a matrix of 1* 1
I am programming a matrix-matrix multiplication using the Eigen library in VS2010. When I
I was using Eigen matrix framework, and the SparseVector library. I was running into
Using Jenkins or Hudson I would like to create a pipeline of builds with
I am using Eigen library in C++. According to Eigen documentation : In order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.