forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 10:23 am

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  [ 5 posts ] 
Author Message
 Post subject: How right to fill real_2d_array?
PostPosted: Mon Sep 13, 2010 5:00 am 
Offline

Joined: Mon Sep 13, 2010 12:58 am
Posts: 14
Hi

I have 2d array with float data in it. How should I form "real_2d_array" array to use my data in alglib?
I've made something like that

Code:
ap::real_2d_array xy;
xy.setlength(iArrayWidth, iArrayHeight);

for ( int i = 0; i < iArrayHeight; i++ )
{
   for ( int j = 0; j < iArrayWidth; j++ )
   {
      xy(i,j) = m_Array[i][j];
   }
}


Is it right?

Thanks
Best regards, Aleksey.


Top
 Profile  
 
 Post subject: Re: How right to fill real_2d_array?
PostPosted: Mon Sep 13, 2010 1:54 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Yes, that is one of the ways. You can also use setcontent() call, if your data are stored in contiguous memory.


Top
 Profile  
 
 Post subject: Re: How right to fill real_2d_array?
PostPosted: Mon Sep 13, 2010 4:19 pm 
Offline

Joined: Mon Sep 13, 2010 12:58 am
Posts: 14
Thanks for reply! ;)

If I will use setcontent how should I make my 2d array in memory to pass it in setcontect?

Thanks,
Best regards, Aleksey.


Top
 Profile  
 
 Post subject: Re: How right to fill real_2d_array?
PostPosted: Mon Sep 13, 2010 7:45 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Quote:
If I will use setcontent how should I make my 2d array in memory to pass it in setcontect?

You can pass pointer to its first element; just setcontent(&m_Array[0][0],.....) should be enough.

However, you should ensure that size of your 2D array is equal to that of ALGLIB array.


Top
 Profile  
 
 Post subject: Re: How right to fill real_2d_array?
PostPosted: Wed Sep 15, 2010 7:58 am 
Offline

Joined: Mon Sep 13, 2010 12:58 am
Posts: 14
Ok, it is clearly for me now! Thank you Sergey! ;)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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