473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

convert valarray to basic array

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.

Jul 23 '05 #1
2 3670
> 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.


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.

Jul 23 '05 #2
Ok, I see, this is a solution for my problem. Thanks.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim West | last post by:
The following compiles with g++ 3.3.2, but fails with Intel icc 7.1 with the error: asdf.cc(6): error: expression must be an lvalue or a function designator f1(&arr); Is this undefined...
6
by: Steven T. Hatton | last post by:
I bought Josuttis's book on the repeated recommendations of people in this newsgroup. http://www.josuttis.com/libbook/ One of the first things I looked up was the std::valarray<>. And what I...
1
by: suresh | last post by:
Namasivayah, Stroustrup says when indirect array is used for reordering a valarray the index cannot be repeated twice(page 679). But Nicolai Josuttis in his book on C++ standard library, page...
3
by: klucar | last post by:
I'll start off differently by showing what I know how to do: valarray<float> va(100, 0.0f); float* fp; fp = &va; some_c_function( fp, va.size() ); What I want to do though is quite the...
9
by: Jim | last post by:
Hi, I want to declare that that a valarray of a certain name exist at the beginning of some code, but I can't instatiate it until I've read in some parameters later on in a for loop i.e. int...
3
by: Alex Howlett | last post by:
Stroustrup page 663 says this: valarray<floatv1 (1000); // 1000 elements with value float()==0.0F But when I run this program: -------------------------------------- #include <valarray>...
1
by: toton | last post by:
Hi, I am using vector and similar containers extensively for my project, as well as boost circular_buffer_space_optimized (and adobe circular_queue which is built over vector ). They all work with...
2
by: john | last post by:
Hi, in TC++PL3 on page 665, regarding valarray member functions, it is mentioned: "valarray operator-() const; // result= -v for every element // similarly: +, ~, !" I checked the web and...
43
by: john | last post by:
Hi, in TC++PL 3 on pages 674-675 it is mentioned: "Maybe your first idea for a two-dimensional vector was something like this: class Matrix { valarray< valarray<doublev; public: // ... };
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.