Questions tagged [multidimensional-array]

Multidimensional-arrays can be described as multi-dimensional tables. Each index used in order to find a given element is called a dimension.

An array is typically a data structure meant to store a collection of elements to which is associated a given index. These elements are often in contiguous memory locations although this is not a requirement.

Multidimensional-arrays can be described as multi-dimensional tables. Each index used in order to find a given element is called a dimension.

Depending on the programming language, such a data structure can be achieved through a specific multi-dimension array data structure or in the shape of an "array of arrays" (also known as jagged arrays or Iliffe vector).

Multidimensional-arrays are often used to put values in a table format (e.g. rows and columns).

Tutorials:

This StackOverflow thread provides some insight on the difference between multi-dimensional arrays and jagged arrays in C#.

Wikipedia article.

35247 questions
5
votes
3 answers

PHP explode and put into array

I have this line of string Fruits-banana|apple|orange:Food-fries|sausages:Desserts-ice cream|apple pie the : (colon) is the separator for the main topic, and the | is the separator for the different type of sub topics. I tried to explode it out and…
Sylph
  • 1,425
  • 3
  • 26
  • 36
5
votes
3 answers

How to get indexOf location of a value in nested array in javascript?

Disclaimer: This question is NOT as same as this one. I have an example of nested array: var testArray = [ true, "", [ 1, {a: 2, b: [3, false]}, [2, []], null ], 4, undefined, [5, "test"], function() {} ]; How to get…
Trung0246
  • 689
  • 1
  • 10
  • 21
5
votes
9 answers

How to get nested array length in Javascript?

I have an example of nested array: var testArray = [1,2,[3,4,[5,6],7],8,9,[10,11],12]; Here is my function for getting nested array length: Array.prototype.getLength = function() { var sum = 0; function getMultiLength(array) { for (count =…
5
votes
0 answers

Unable to get all the common elements in multidimensional unsorted array

Criteria for solving the problem: Reduce the complexity to linear. I can only use Arrays with collection type of Comparable. Duplicates elements should be allowed. My concern: My snippet of code(methods for getting common elements(strings)):…
Fun-zin
  • 113
  • 6
5
votes
2 answers

J: Coordinates with specific value

Let's say we have array 0 1 2 3 4 5 8 7 8 9 There are two indexes that have value 8: (i.10) ([#~8={) 0 1 2 3 4 5 8 7 8 9 6 8 Is there any shorter way to get this result? May be some built-in verb. But more important. What about higher…
Roman
  • 1,309
  • 14
  • 23
5
votes
1 answer

asort(src,dest) to a multidimensional array

I'm trying to abuse asort() (just because) to copy an array src to array dest, no problem there: $ awk 'BEGIN { split("first;second;third",src,";") # make src array for testing asort(src, dest, "@ind_num_asc") # copy array to dest …
James Brown
  • 36,089
  • 7
  • 43
  • 59
5
votes
5 answers

In C/C++, is char* arrayName[][] a pointer to a pointer to a pointer OR a pointer to a pointer?

I understood multi-dimensional arrays as pointers to pointers, but perhaps I am wrong? For example, I though: char * var = char var[] char ** var = char* var[] or char var[][] char *** var = char var[][][] or char* var[][] or char** var[] Is…
Russel
  • 3,609
  • 8
  • 33
  • 32
5
votes
7 answers

Confusion about pointers and multidimensional arrays

If the following is possible: MyFunction(int *array, int size) { for(int i=0 ; i
user366312
  • 16,949
  • 65
  • 235
  • 452
5
votes
2 answers

numpy vectorize multidimensional function

I am having problems to vectorize a multidimensional function. Consider the following example: def _cost(u): return u[0] - u[1] cost = np.vectorize(_cost) >>> x = np.random.normal(0, 1,(10, 2)) >>> cost(x) Traceback (most recent call last): …
Donbeo
  • 17,067
  • 37
  • 114
  • 188
5
votes
1 answer

Flatten/ravel/collapse 3-dimensional xr.DataArray (Xarray) into 2 dimensions along an axis?

I have a dataset where I'm storing replicates for different classes/subtypes (not sure what to call it) and then attributes for each one. Essentially, there are 5 subtype/classes, 4 replicates for each subtype/class, and 100 attributes that are…
O.rka
  • 29,847
  • 68
  • 194
  • 309
5
votes
1 answer

np.ndarray with Periodic Boundary conditions

Problem To impose np.ndarray periodic boundary conditions as laid out below Details Wrap the indexing of a python np.ndarray around the boundaries in n-dimensions This is a periodic boundary condition forming an n-dimensional torus Wrapping only…
Alexander McFarlane
  • 10,643
  • 9
  • 59
  • 100
5
votes
1 answer

Tensorflow nn.conv3d() and max_pool3d

Recently Tensorflow added support for 3d convolution. I'm attempting to train some video stuff. I have a few of questions: My inputs are 16-frame, 3-channel per frame .npy files, so their shape is: (128, 171, 48). 1) The docs for…
JohnAllen
  • 7,317
  • 9
  • 41
  • 65
5
votes
2 answers

F# converting Array2D to array of arrays

In F# is there a concise way of converting a float[,] to float[][]? In case this seems like a stupid thing to do it is so I can use Array.zip on the resulting array of arrays. Any help greatly appreciated.
Sid26
  • 71
  • 3
5
votes
4 answers

iOS JSON Parsing, array with multiple array

I have a JSON array with multiple object and I don't know how do I grab the "url" tag as an NSArray or a NSDictionary and show that image url in Tableview. I can't change the JSON data format.How should I do this? Here is what the JSON response…
Mukesh
  • 777
  • 7
  • 20
5
votes
1 answer

Is using realloc() on a dynamically allocated 2D array a good idea?

I am mainly interested in the viability of shrinking such an array. I'm working on a project where I have used single malloc() calls to each create individual moderately large 2D arrays. (Each only few tens of MiB, at the largest.) The thing is that…
1 2 3
99
100