Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Did some one use Eigen or Armadillo library to do calculation?

Did some one use Eigen or Armadillo library to do calculation?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structurestutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    smallkubi
    wrote on last edited by
    #1

    Now ,i have one question. I use library to define a matrix B, for example, as follows, how can i convert B.real() to a double[] array? thanks very much.

    MatrixXcd B(n,3);
    for( int i=0; i

    J 1 Reply Last reply
    0
    • S smallkubi

      Now ,i have one question. I use library to define a matrix B, for example, as follows, how can i convert B.real() to a double[] array? thanks very much.

      MatrixXcd B(n,3);
      for( int i=0; i

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      I did not have used it so far but it should be possible to copy the values to your array this way:

      // A one-dimensional array
      double *da = new double[n * 3];
      for (int i = 0; i < n; i++)
      for (int j = 0; j < 3; j++)
      da[i*3 + j] = B(i, j).real();

      S 1 Reply Last reply
      0
      • J Jochen Arndt

        I did not have used it so far but it should be possible to copy the values to your array this way:

        // A one-dimensional array
        double *da = new double[n * 3];
        for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
        da[i*3 + j] = B(i, j).real();

        S Offline
        S Offline
        smallkubi
        wrote on last edited by
        #3

        Thank you very much. My code is in Loop many times, so i want a efficient code. your code can reach my function,but efficient i think it's not good.

        J 1 Reply Last reply
        0
        • S smallkubi

          Thank you very much. My code is in Loop many times, so i want a efficient code. your code can reach my function,but efficient i think it's not good.

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          It is difficult to answer without knowing how the data are used. But a short web reserach found this: [EIGEN] How to get in and out data from Eigen matrix | Vlad's Blog[^]. So it seems that you can use Map to get a pointer to the complex values. That should be sufficient because the real part is stored first and therefore already at the specified index (when *p is a pointer to a complex array, p[n] and p[n].real() have the same address).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups