convert valarray to basic array

K

Kai I. H.

Hi,

is there an efficient way to convert a valarray< double > into double[]
without using a loop to copy each value from the valarray to the basic
array?

I use a valarray because I need the mathematical operations of
valarray. Now I want to use an extern function to transform my
valarray. The input should be my valarray. But the input parameter of
the extern function is of type double[]. The extern function was
programmed by someone else and I don't want to change this code.

Hope you can help me.

Thanks in advance.

Kai I. H.
 
V

velthuijsen

is there an efficient way to convert a valarray said:
without using a loop to copy each value from the valarray to the basic
array?

I use a valarray because I need the mathematical operations of
valarray. Now I want to use an extern function to transform my
valarray. The input should be my valarray. But the input parameter of
the extern function is of type double[]. The extern function was
programmed by someone else and I don't want to change this code.

Well you could do the following:
SomeoneElsesFunction(&YourValarray[0], YourValarray.size());

Note that this is not to clean programming, I'm effectively accessing
the private pointer in the valarray that points to the interal array
used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top