forum.alglib.net
http://forum.alglib.net/

How right to fill real_2d_array?
http://forum.alglib.net/viewtopic.php?f=2&t=60
Page 1 of 1

Author:  AlekseyL [ Mon Sep 13, 2010 5:00 am ]
Post subject:  How right to fill real_2d_array?

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.

Author:  Sergey.Bochkanov [ Mon Sep 13, 2010 1:54 pm ]
Post subject:  Re: How right to fill real_2d_array?

Yes, that is one of the ways. You can also use setcontent() call, if your data are stored in contiguous memory.

Author:  AlekseyL [ Mon Sep 13, 2010 4:19 pm ]
Post subject:  Re: How right to fill real_2d_array?

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.

Author:  Sergey.Bochkanov [ Mon Sep 13, 2010 7:45 pm ]
Post subject:  Re: How right to fill real_2d_array?

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.

Author:  AlekseyL [ Wed Sep 15, 2010 7:58 am ]
Post subject:  Re: How right to fill real_2d_array?

Ok, it is clearly for me now! Thank you Sergey! ;)

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/