# 1D Sub-Array From 3D Array of Objects

• 07-05-2012, 02:39 AM
mblem22
1D Sub-Array From 3D Array of Objects
Edit: title should be ... Array of Doubles, not objects

Hello -

Wondering how I can get a reference to a 1D array which is part of a 3D array of doubles, so that I can pass it to a method. What I mean is basically this:

double myDouble = myFunction(myArray[i][ALL][j]);

where myFunction takes a 1D array of doubles as an argument. If you are familiar with MATLAB, I basically want the java equivalent of myArray(i)(:)(j).

Is there a built in method somewhere for doing this? Or do I need to make a new array? I would hate to pointlessly use more memory.

Sorry if this is not clear (very tired...). I'd be happy to clarify. Thanks for any help. This one has me quite stumped.
• 07-05-2012, 03:16 PM
mblem22
Re: 1D Sub-Array From 3D Array of Objects
I have also posted this thread at 1D Sub-Array From 3D Array of Doubles
• 07-05-2012, 09:14 PM
JosAH
Re: 1D Sub-Array From 3D Array of Objects
A two dimensional array is an array of rows; so if your array is named 'a', the a[0] is a one dimensional array and it has the elements of the first row; same with a[1], a[2] etc. You can't do the same with the columns of the two dimensional array (matrix) a.

kind regards,

Jos
• 07-05-2012, 10:46 PM
Diargg
Re: 1D Sub-Array From 3D Array of Objects
Quote:

Originally Posted by mblem22
I would hate to pointlessly use more memory.

Does your computer charge you by the bit? If so, you can have some of mine. If this were C++ you could probably do some pointer arithmetic, but here you're stuck with looping over it.