How to Calculate a Full Data Cube
- 1). Declare an ordinary array to get a grasp of how they work. In Python, you can do this by typing, "array1 = [1,2,3]"; this indicates that array1 is a list of values. In the C and C++ languages, you can declare an array using brackets: "int array1 = [2]"; this indicates that array1 is an array with two "spaces" to hold information.
- 2). Declare a two-dimensional array. For example, in C, you could do this by typing "int array1[3][3]"; think of a two-dimensional array as a checkerboard. Your array, array1, is like a 3-by-3 checkerboard that can hold nine pieces of data. You can access this array by typing, for example, "array1[2][1]"; which would access the square in the second row and first column.
- 3). Declare a multidimensional array using the syntax appropriate to your chosen language. For example, in Python, arrays can be created as "lists." The appropriate syntax in Python would be, "array1 = [[ [ [],[] ] , [ [],[] ] ],[ [ [],[] ] , [ [],[] ] ]]"; this looks confusing, but it's really just a list of two more lists, each of which is a list of two more lists, each of which is also a list of two lists. In C languages, you would declare an array like this: "int array1 = [2][2][2]"; the C array is equivalent to the one in Python; only the syntax is different.
- 4). Access your data cube, or three-dimensional array, by specifying which part of the array you want to access. Think of the array as a three-dimensional cube that is two blocks wide, two blocks deep, and two blocks high. Think of each box as containing a piece of information. In both Python and C, you can access one of those boxes by using brackets. For example, by typing "array1[0][0][0]"; you access the bottom-left corner of the "cube."
Source...