1D Sub-Array From 3D Array of Doubles

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.

(This thread is also posted at 1D Sub-Array From 3D Array of Objects)

Re: 1D Sub-Array From 3D Array of Doubles

Here's a way to think about it: every time you use brackets to refer to an element in an array, the number of dimensions is reduced by one.

Look at this code:

Code Java:

int[][] numbers = {{1, 2}, {3, 4}};
int[] nums = numbers[1];

Because numbers is an array *of arrays*, if we refer to one of it's elements, an array is returned. We started with a 2D array (numbers), then got a 1D array by referencing an element in the 2D array.

Following this logic, to get a 1D array from a 3D array, the general syntax would be:

oneDArray = threeDArray[indexA][indexB];