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 6944399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:18:06+00:00 2026-05-27T13:18:06+00:00

The Eigen library can map existing memory into Eigen matrices. float array[3]; Map<Vector3f>(array, 3).fill(10);

  • 0

The Eigen library can map existing memory into Eigen matrices.

float array[3];
Map<Vector3f>(array, 3).fill(10);
int data[4] = 1, 2, 3, 4;
Matrix2i mat2x2(data);
MatrixXi mat2x2 = Map<Matrix2i>(data);
MatrixXi mat2x2 = Map<MatrixXi>(data, 2, 2);

My question is, how can we get c array (e.g. float[] a) from eigen matrix (e.g. Matrix3f m)? What it the real layout of eigen matrix? Is the real data stored as in normal c array?

  • 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-05-27T13:18:07+00:00Added an answer on May 27, 2026 at 1:18 pm

    You can use the data() member function of the Eigen Matrix class. The layout by default is column-major, not row-major as a multidimensional C array (the layout can be chosen when creating a Matrix object). For sparse matrices the preceding sentence obviously doesn’t apply.

    Example:

    ArrayXf v = ArrayXf::LinSpaced(11, 0.f, 10.f);
    // vc is the corresponding C array. Here's how you can use it yourself:
    float *vc = v.data();
    cout << vc[3] << endl;  // 3.0
    // Or you can give it to some C api call that takes a C array:
    some_c_api_call(vc, v.size());
    // Be careful not to use this pointer after v goes out of scope! If
    // you still need the data after this point, you must copy vc. This can
    // be done using in the usual C manner, or with Eigen's Map<> class.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using Eigen matrix framework, and the SparseVector library. I was running into
I am trying to learn C++ with the Eigen library. int main(){ MatrixXf m
I'm using eigen library to rotate a plane to be parallel to the ground
Reading the Eigen library documentation, I noticed that some objects cannot be passed by
I'm making use of Eigen library which promises vectorization of matrix operations. I don't
in my project I'm making use of Eigen C++ library for linear algebra and
Consider the following code (C++11), which uses the Eigen 3 library (http://eigen.tuxfamily.org): #include <iostream>
I am attempting to pass an Eigen::Vector4d into an function like this: Matrix3d quat2DCM(Vector4d
I try to link my c++ application against the Eigen 2.0.15 library. Some details:
Has anybody successfully imported the eigen library using the ndk? I was thinking about

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.