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
2 answers

How can I convert a 2D array to a 2D list with Streams?

I've tried this StackOverflow answer's code, but I get the error Cannot infer type argument(s) for map(Function): //data is int[][] Arrays.stream(data) .map(i -> Arrays.stream(i) .collect(Collectors.toList())) …
ack
  • 1,181
  • 1
  • 17
  • 36
5
votes
2 answers

Efficient way to write a python dictionary with Numpy Nd-Array values into a Json File

How do I efficiently write a Python dictionary, where the values are Numpy Nd-Arrays to a Json File? I obtain an error saying that the Numpy Nd-Array is not Json-Serializable. Is there any way to overcome this?
AlexGuevara
  • 932
  • 11
  • 28
5
votes
2 answers

Searching specific rows in a multi-dimensional array

I'm new to java programming and I can't wrap my head around one final question in one of my assignments. We were told to create a static method that would search a 2-D array and compare the numbers of the 2-D array to an input number...so like…
Cameron
  • 51
  • 1
  • 5
5
votes
3 answers

Enhanced for loop in 2D Array - JavaScript

I created the following 2D array in Javascript // Create basic linear array var ImgArray = new Array(4); // Do the 2D array for each or the linear array slots for (i=0; i < 4 ; i++) { ImgArray[i] = new Array(4) } Now i want to iterate through…
Carlos
  • 5,405
  • 21
  • 68
  • 114
5
votes
6 answers

Get highest value in multi multidimensional array

i need to get the the max or highest value in a multi dimensional array. here is my array $array: [pay] => Array ( [0] => Array ( [title] => Array ( [name] => 'hi' ) …
John Jaoill
  • 159
  • 2
  • 9
5
votes
1 answer

How do you declare a global std::vector 2d array across multiple files? c++

I have a header file in which there is a 2d array extern declaration, and a cpp file in which there is the actual definition for the array for it to link to. I would like to replace this array with a 2d vector, but my compiler keeps telling me: …
5
votes
2 answers

How do I interpolate a 2D gridded point cloud to a continuous area?

I have a 2 dimensional Numpy NDarray filled with floats between 0 and about 8. This 2 dimensional arrays size is (1000, 1600) and there are about 1400 values, (the points in the point cloud), the remaining values are None, so matplotlib does not…
5
votes
2 answers

using array_walk_recursive() for stdClass objects

I have looked through a few answers on here but that don't seem to utilise this method? I have an array of items, and the items are objects. The object can have a key which is 'children' and 'children' is an array of objects etc. Is there a way to…
Ryan Hipkiss
  • 648
  • 1
  • 7
  • 20
5
votes
1 answer

Assign a list of values to a struct in C#?

I have a struct (.NET 3.5): struct ColumnHeadings { public string Name ; public int Width ; } ; And when I try to assign a list of values to that struct I get a 'cannot implicitly convert type string/int…
John M
  • 14,338
  • 29
  • 91
  • 143
5
votes
3 answers

Sort Multidimensional Array in VB.NET

I have a 2X50 array like this- R-125212,11 C-254645,25 R-456598,96 M-456878,35 O-980857,89 And so on... Now I want to sort this array with the values of the 2nd Column. So the output should look…
nsssayom
  • 364
  • 1
  • 5
  • 21
5
votes
4 answers

PHP Search multidimensional array for value & get corresponding element value

I am using PHP & I have a multi dimensional array which I need to search to see if the value of a "key" exists and if it does then get the value of the "field". Here's my array: Array ( [0] => Array ( [key] => 31 [field] =>…
LargeTuna
  • 2,694
  • 7
  • 46
  • 92
5
votes
4 answers

How do I switch rows and columns in a 2D array?

I am working on a code that will create a visual Sierpinski triangle to 3D print, and in order for it to work I have to use a Pascal triangle algorithm that will create an array so I can use to tell my algorithm that will create my triangles where…
5
votes
1 answer

How do I create an 2-D array in Haskell?

I'm trying to learn Haskell by creating a board game. I currently have a game that is [[Char]] and I'm trying to create another board of the same columns and rows filled with the character "a". How do I go about doing so? Also can you explain how…
5
votes
1 answer

Aliasing of multi-dimensional arrays

It is well known that a 2D array is an array of arrays, and that it is required by standard to be a contiguously allocated nonempty set of objects (6.2.5 Types §20) - object being a 1D array here. It is also well known that for all common…
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
5
votes
1 answer

Julia: Making empty/initialized multidimensional arrays of self defined types

I am making a type of my own called KeyVal defined as below: type KeyVal first::Int second::Float64 end And I am trying to make an empty/or initialized at zero matrix that its elements are of type KeyVal. Normally with other types I do…