0

The LAPACKE documentation states that for C and C++ code, arrays should be passed as pointers, not double pointers as 2D arrays are usually created.

Is there a way to create a C++ dynamic 2D array from a single pointer?

  • 1
    *Is there a way to create a C++ dynamic 2D array from a single pointer?* -- Maybe create the 2D dynamic array [contiguously](https://stackoverflow.com/questions/21943621/how-to-create-a-contiguous-2d-array-in-c/21944048#21944048), and pass `arr[0]` to your function that expects the data to be laid out contiguously? – PaulMcKenzie Nov 04 '22 at 08:20
  • 1
    It works! If you create the dynamic array in a way that stores the data contiguously in the memory, you can create a pointer to the first element of the array as pass it to the function as argument. Thanks! – gununes132 Nov 08 '22 at 22:12
  • I will leave it to you to post the answer, since you are more familiar with LAPACKE than I am. I am hesitant in posting answers about libraries I am not familiar with. I suggested what may work, i.e. creating the 2D data array in a contiguous fashion, and "fooling" LAPACKE it is working with a 1D array. So if this works, please post the answer so as to help others who have the same issue. – PaulMcKenzie Nov 09 '22 at 15:07

0 Answers0