Current location: Hot Scripts Forums » Programming Languages » Everything Java » Converting 3dimensional Array into 2 dimensional array


Converting 3dimensional Array into 2 dimensional array

Reply
  #1 (permalink)  
Old 08-06-07, 05:58 AM
utd utd is offline
Newbie Coder
 
Join Date: Sep 2006
Location: richardson,texas
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Converting 3dimensional Array into 2 dimensional array

Hi,
I'm having a data in 3 dimensional array..as such i'm facing problems like java.lang.OutOfMemoryError:Java Heap space I thought of converting that 3 dimensional array to its equivalent 2 dimensional array..
The code that I was having is given below

Code:
for(int v=1;v<=clusters;v++)
			{
				if(minimum==Euclid[v])
				{
					clusterpointscount[v]++;
				
						
					for(int w=1;w<=columns;w++)
					{
						trackclusters[v][clusterpointscount[v]][w]=x[i][w];
						
						}
					}
				}
Instead of placing x[i][w] content into trackclusters[v][clusterpointscount[v]][w] i would like x[i][w] data to be placed in some array of this type: trackclusters[][]

o make it simple ... i want the data that is been stored in 3-dimensional array ie; trackclusters[][][] into 2-dimensional array of kind trackclusters[][]

eg: Points in cluster1:

0.33 0.0 0.0 0.0 0.5 0.0
0.5 0.0 0.0 0.0 0.67 0.0
0.67 0.0 0.0 0.0 1.0 0.0

Points in cluster2:

0.08 0.13 0.0 0.0 0.0 0.37
0.08 0.13 0.0 0.0 0.17 0.12

if trackclusters[1][1][1] represents the data that is present in Cluster:1 row:1 column:1
and trackcluster[2][2][1] represents the data that is present in cluster:2 row:2 column:1

instead of storing the data of Points in cluster in 3dimensional array.. i want to store them in 2 dimensional array

Somebody please help me out in this regard.
Thnx in advance

Last edited by utd; 08-06-07 at 06:15 AM.
Reply With Quote
  #2 (permalink)  
Old 08-06-07, 11:33 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
for(int v=1;v<=clusters;v++)
{
if(minimum==Euclid[v])
{
clusterpointscount[v]++;
for(int w=1;w<=columns;w++)
{
trackclusters[v][clusterpointscount[v]][w]=x[i][w];
}
}
}
When you look at a three-dimensional array, the first argument
is an index which represents a pointer to a table in the array.
The second and third arguments are the row and column of the
table that the first argument is pointing to.

To change a three-dimensional array to a two-dimensional array,
you first must load the data into the three-dimensional array.
Then merge the tables in the three-dimensional array into a
two-dimensional array.
__________________
Jerry Broughton

Last edited by job0107; 08-06-07 at 11:45 PM.
Reply With Quote
  #3 (permalink)  
Old 08-07-07, 04:17 PM
utd utd is offline
Newbie Coder
 
Join Date: Sep 2006
Location: richardson,texas
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
The reason why I asked a question of changing a 3-d array to 2-d array is as follows:
I'll be having all my data in an array x[rows+1][columns+1].. When I made of use of 3-d array like trackclusters[rows+1][rows+1][columns+1] I'll be wasting a memory of about (rows+1).For eg: if rows=3000 and columns=45, then see that I'm wasting about 3000 copies of memory. To overcome this problem I want to make use of
2-d array ratherthan using 3-d array..
so could you please give me some other solution for this?
Reply With Quote
  #4 (permalink)  
Old 08-07-07, 05:56 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
If your data starts out in a 2-dimensional array, why did you store it in a 3-dimensional array? Why don't you put it in a 2-dimensional array and forget about the 3-dimensional array?

I really don't understand what you are trying to do.

Besides a 3-dimensional array isn't (row,row,column) it's (index,row,column).

A 3-dimensional array is used to store multiple tables, not just one table.

When you use a 3-dimensional array, a space for a table is reserved in memory
for every index that you specify. That takes up a lot more memory then one table does.
__________________
Jerry Broughton

Last edited by job0107; 08-07-07 at 06:03 PM.
Reply With Quote
  #5 (permalink)  
Old 08-11-07, 07:30 PM
utd utd is offline
Newbie Coder
 
Join Date: Sep 2006
Location: richardson,texas
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Thnx man for ur suggestions..
I got the thing working..
Reply With Quote
  #6 (permalink)  
Old 08-11-07, 09:38 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
I'm glad. Hope I was of some assistance.
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
Sorting a massive multidimensional array dave111 PHP 1 12-12-05 04:09 PM
Serializing a set of arrays dannyallen PHP 2 10-11-04 03:04 AM
Converting MySQL Row Array Data into Session Data mdaoust PHP 0 09-15-04 03:42 PM
linking to iframe not working :( j0d JavaScript 5 01-19-04 08:14 PM


All times are GMT -5. The time now is 05:43 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.