forum.alglib.net

ALGLIB forum
It is currently Thu Mar 28, 2024 3:58 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Can a real_1d_array point do some double array?
PostPosted: Tue Aug 30, 2016 8:24 am 
Offline

Joined: Tue Aug 30, 2016 7:40 am
Posts: 3
Hi,
I have a large array of contiguous memory in double, which I don't want to copy to a real_1d_array to save memory. Also moving (std::move) it is not an option as I want to keep the original array for further processing. Is it possible to create a real_1D_array with the original array pointer to double?

I did some fiddling with the code and modified setcontent to have p_vec to point to pContent ( p_vec->ptr.p_double = const_cast<double *> (pContent);), which seems to work. But this is really a hack and I am not convinced it does not have side effects in other parts of the library.

Thank you in advance for any help!
Max


Top
 Profile  
 
 Post subject: Re: Can a real_1d_array point do some double array?
PostPosted: Thu Sep 01, 2016 4:54 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 903
Hello!

You can use ae_vector_attach_to_x() function, which allows to attach ae_vector object to the memory managed by x_vector object. Here "attach" means that ae_vector does not allocate its own storage, but uses one pointed by X-structure.

Initialization of the X-structure is pretty straightforward and documented in comments near its declaration. Just one notice: set owner field to OWN_CALLER, it will tell ALGLIB that this memory is owned by you.


Top
 Profile  
 
 Post subject: Re: Can a real_1d_array point do some double array?
PostPosted: Tue Sep 06, 2016 5:18 pm 
Offline

Joined: Tue Aug 30, 2016 7:40 am
Posts: 3
Hi Sergey,
Thank you very much for your help.
Max


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group