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.
35,357
questions
0
votes
0
answers
15
views
Plotting an image using data from a 2D Diffustion Reaction dataset
I have a 2D Diffusion Reaction data in shape (1, 128, 128, 101, 2) and I'm not really sure how to plot an image with it.
I tried using imshow and seaborn to plot but it did not work. Using imshow I ...
-1
votes
1
answer
38
views
Switching the column and row of a matrix with the next one inJava
I was trying to switch the rows and columns of a matrix with the next one in java and for some reason for some of the positions the results i get are right and for other they aren´t. Is this the ...
0
votes
1
answer
48
views
Transpose of a square matrix using ArrayList with Collections.swap and space Complexity O(1) in Java
Given an 2D square matrix here i'm trying to print a transpose of a matrix with space complexity SC:O(1).
for(int row = 0; row < originalArray.size(); row++) {
for(int col = row+1; col < ...
-1
votes
0
answers
24
views
Can I put an array inside a 2D array by declaring the whole array? [duplicate]
So this is my code:
float[][] objectHitboxes = new float[1][];
objectHitboxes[0] = {xPos, yPos, width, height};
I am trying to create a 2D array that stores my object hitboxes data. It would be ...
-1
votes
1
answer
61
views
How to pass file extracted data into an array to a print function using ostream&? (C++)
I'm trying to use two functions -
read data from a text file and store it into an array formatted from a struct
print array data by ostream&
const int maxRows =20;
//3 columns across
struct ...
0
votes
1
answer
29
views
Numpy Array multi-dimension input order
What are the input order for a numpy multi-dimensional array?
When I use np.ones((3,2,2)) I expect 3 arrays or size 2x2 but reading on other posts (the numpy documentation wasn't clear) some claim ...
-1
votes
0
answers
31
views
Reshape array from 2 dimension to 1 dimension
i want to reshape a 2D matrix to a 1D matrix
my data looks like this
Original Data
and i want to reshape it into this target data
this is what i do
X = df.iloc`[:, 4:-1].values
X = X.reshape(-1, 111, ...
0
votes
0
answers
20
views
Optimization: Find the minimum cost from renting plans
Given a company will be renting cores for k tasks a day for n days, and a 2D array plans for pricing of cores is given, each sub-array in plans has 4 elements in order representing:
the start day of ...
-8
votes
0
answers
77
views
Dynamic double array into vector C++ [closed]
I want to put dynamic double array into vector but I am receiving wrong results
Vector declaration:
vector<double**> vectordx;
putting array into vector:
vectordx.push_back(valXY.dx);
array ...
0
votes
1
answer
55
views
compare the row elements in th 2D matrix
i need to output the numbers of the rows in which the elements are arranged in ascending order. And I can`t understand how to compare elements. I made some code where I compare.
Console.WriteLine(&...
0
votes
1
answer
60
views
Elements outside of a 2D array
Let’s say I was using a 2D array I[NROWS][NCOLS] as a frame for a picture.
The expression (row<=NROWS && col <=NCOLS) can be used to ensure that a point I[row][col] isn’t in front or ...
0
votes
2
answers
38
views
How do I Take 2D array with variable columns as input from user in Java?
I want to take a 2D array with each element as an input from user.
However, I want the user to specify in each array(i.e the column part or the each individual array) how many elements are there i.e ...
0
votes
1
answer
40
views
python: rotate an array 90 degree - but not symetric dimension
I am implementing a game which uses blocks, that contain of pixels.
I want to be able to rotate those blocks.
Therefore I began to use this nice line:
self.array = zip(*self.array[::-1])
But as it ...
-1
votes
2
answers
81
views
Java remove duplicates from 2d array
I need to do this problem:
" Prepare a rectangular array (with random natural positive dimensions) of int i variables
fill it with random values from the interval [0,10). Create and display a new ...
-1
votes
1
answer
33
views
Removing Value From MultiDimensional array in php [closed]
Help needed, at the bottom of my function im trying to remove a value from an array, so when i unset a value from an array and i do a print_r() with that same variable it shows that it is remove, but! ...
0
votes
1
answer
51
views
Add two matrices
I have a problem "Index was outside the bounds of the array." and can't understand where is a problem
static void Main(string[] args)
{
Console.WriteLine("If you want add elemenets of ...
0
votes
2
answers
49
views
How to take user input in 2D Array without specifying the second dimension i.e the column dimension? [duplicate]
I have used the Scanner class for taking input, this is the code.
int [] [] arr = new int[3][];
for (int row = 0; row < arr.length; row++)
{
for (int col = 0; col < ...
0
votes
1
answer
63
views
Building an (..., N, N) numpy array from a function which returns each (N, N) sub-array
I want to build a numpy array of shape (..., N, N) using a function that returns each (N, N) block. The overall point is to build the (..., N, N) array much faster than by iterating over the first (......
0
votes
1
answer
58
views
How to compare 3 dimensional arrays within O(0)?
So I tried to make a solving algorithm for a rubiks cube that makes use of a 3 dimensional array however since a 3 dimensional array's values can not be compared to another array's values, my if ...
-2
votes
2
answers
59
views
<1 empty item> How can I fix this?
function findLargestNumbers(arrayOfArrays) {
let k = new Array;
for(let i = 0 ; i < arrayOfArrays.length ; i++){
if(arrayOfArrays[i].length == 0){
continue ;
}
...
0
votes
1
answer
43
views
Printing 2D Array outputs adresses [duplicate]
I tried to print a 2D Array but the output containts random integers. I am unsure what causes this problem since I am new to C and suspect it has something to do with memory management.
#include <...
0
votes
1
answer
67
views
Parameterizing the Width of Array Elements in SystemVerilog
Is it possible to parameterize the width of array elements in SystemVerilog?
Currently, I am doing the following:
localparam N = 5;
localparam int widths[0:N - 1] = '{32, 16, 8, 4, 2};
localparam ...
0
votes
1
answer
33
views
SystemVerilog Arrays
Is this array declaration valid?
bit[31:0] shadow_mem[bit[31:0]];
But what does this mean?
We usually declare it as
bit[31:0] shadow_mem[31:0];
Are the two declarations different?
What is the ...
2
votes
4
answers
129
views
Print numbers of a matrix in a wave pattern
I want the output to be 7 4 1 2 5 8 9 6 3 but it's coming out to be
1 4 7 2 5 8 3 6 9. How can I fix it, and what's the logic behind it so that I can print the reverse wave pattern, too?
#include<...
0
votes
1
answer
20
views
changing two dimensional array elements
white_board=[[]]
for x in range(100):
white_board[0].append(0)
for x in range(99):
white_board.append(white_board[0]) #100*100 0 two dimensional array
n=int(input())
posL=[] #dot's position ...
0
votes
2
answers
60
views
Recursively filter a multidimensional array using a 2d array of whitelisted key paths including wildcards
I have a multidimensional array with an indeterminant depth. I want to keep only some keys depending a collection of paths, but I need a generic, recursive function and not a hardcoded filter.
Example:...
0
votes
1
answer
53
views
How to advance row-major and wrap around rows in a Java 2D array?
For a small Java application, I have a constant SIZE x SIZE 2D char array called FIELD that I am trying to move two objects (represented by char symbols) through. I have two methods in my Field class ...
0
votes
0
answers
28
views
How to save in a variable a portion of ndarry image?
I'm facing problem in saving in a variable a portion of an image that is described in the following way:
def extract_face_region(image, landmarks):
landmark_coords = np.array([(landmarks.part(i).x,...
0
votes
1
answer
61
views
I'm trying to make a div have a randomly generated string shift to the left then have a character add to the end to create a scroll-like effect
I've started trying to learn javascript, html and css in codepen over the past few days and I am trying to make a matrix code rain type effect. I do have experience in other programming languages. I ...
0
votes
1
answer
37
views
PHP Multi Dim Array to Javascript (with keys) [duplicate]
I need to convert a multi dimensional PHP array into Javascript.
I have created an array as shown...
foreach ($results as $row)
{
$template[] = array('Id'=>$row["Id"],'Address'=>$row[&...
-2
votes
1
answer
164
views
How to convert CSV decimals into C float values
I need to convert a CSV file of decimal numbers into a C float variable. How can I do that?
data.csv
0.1,0.2,0.3,0.4,0.5
1.1,1.2,1.3,1.4,1.5
2.1,2.2,2.3,2.4,2.5
3.1,3.2,3.3,3.3,3.5
4.1,4.2,4.3,4.4,4.5
...
1
vote
1
answer
60
views
stack smashing detected and and with the flag -Wall gives me the Warning -Wchar-subscripts
it s my first program ever i dont know how to solve this problems i'm searching for tutorials but i don't totally understand what i am doing wrong.
void railFenceCipher(char *stringa){
char ...
0
votes
2
answers
53
views
Accesing to value of 2D array using pointer arithmetic
I'm studying multy-pointers and I watched this video, where explains that, if we want to access the value of a 2D array, we use double indirection like this:
#include <stdio.h>
#include <...
-1
votes
1
answer
82
views
How do I sort arrays in an array by string using custom alphabet in JS?
Why this is not a duplicate: The "original" sorts by characters, not strings. I'm trying to sort by strings. This is a completely different question, it needs to be able to sort the entire ...
0
votes
2
answers
91
views
C - fgets() keeps skipping lines randomly when using the most basic case
Before you remove it, I haven't seen this in any thread. I've seen people who wants to skips line but it fails, or it fails if there's a user input (which is due to weird input buffer thing in stdlibc....
1
vote
1
answer
23
views
How can I set a value for each element of a Matrix of N dimension?
So, this is kinda long and complicated but hear me out, recently I´ve been studing about Matrices and setting coordinates to map the movement of NPCs in videogames and that got me into ...
1
vote
1
answer
25
views
How do I merge the range data of the highlighted cells of my grid's ouput?
I am working on a game and I've come to the point where I am in need of an efficient collision detection system. At the moment, I am using a very heavy handed array of 1 and 0 to indicate a boundary.
...
0
votes
0
answers
68
views
Create array of predefined arrays
With the help of PlatformIO and the U8G2 library, I want to write an application for an ESP8266 microcontroller. The U8G2 offers countless fonts, and I would like to display them on a graphical ...
1
vote
2
answers
46
views
How to Cut a String in AngularJs
I have the phrases:
"Shiloh Match Jolie",
"Zahara Marley Novel",
"Pax Dix Bat",
"Maddox Chivan Jcalie"
I want to get all last character in phrases:
"...
0
votes
0
answers
39
views
NetCDF Values from a reader (Panoply/NC.view) vs Python (rioxarray)
For some reason, values at each time step for a NC file I'm using appear different when I view it through an external reader like Panoply and when I process it through a Python script via rioxarray....
0
votes
0
answers
21
views
Merge parts of elements in multi-dimensional array that have the same key inside elements [duplicate]
I have a multi-dimensional array where multiple array elements will have the same key name inside. Within these matching key array elements are data that I want to combine under one bucket, rather ...
0
votes
0
answers
26
views
Swap row and column of multidimensional array with any length [duplicate]
I have a multi dimension array with any length inside as below:
Array = [[4, 9, 4], [4, 9, 2], [3, 5, 2, 7], [9, 1, 7, 8, 11], [1, 7, 3, 6, 4]]
And I want this array to be made as below:
Array = [[4, ...
-1
votes
1
answer
82
views
2 dimensional array using user prompt()?
var playerinfo = [
["Anisul", 122],
["Rahim", 433],
["Kabir Singh", 788],
["Munna", 56],
["Rasel", 120]
];
function highestRunScorer(playerinfo) {
var highScorer = playerinfo[...
1
vote
2
answers
66
views
Why can't I print out the contents of my simple multidimensional array?
Below is the code I copied from a book to practice on.
I want to print out the content of the multidimensional array.
int[][] matrix = new int[4][];
matrix[0] = new int[2];
matrix[1] = new int[6];
...
0
votes
2
answers
97
views
How to multiply array elements for nth arrays in Python?
I am trying to make method for creating array from nth arrays in Python . I have looked Numpy but the method seems not suit my requirement.
The following is my code works in javascript.
numArr = [[1],[...
0
votes
3
answers
92
views
PHP 8.1 Warning: Trying to access array offset on value of type bool in array construction [closed]
I have a problem with the construction of an array which produces this error in PHP 8.1:
Warning: Trying to access array offset on value of type bool in
C:\xampp\htdocs\sito3\xlsx.php on line 250
I ...
-1
votes
3
answers
59
views
Sort a 2D Array by Comparing Both the First and Second Integers using Java
The original 2D array is
int[][] array = {{4, 7}, {4, 1}, {14, 11}, {10 6}, {13, 4}, {4, 10}, {10, 3}, {9, 14}}
The above array should be sorted to the following:
int[][] array = {{4, 1}, {4, 7}, {4, ...
0
votes
1
answer
34
views
Check if rows in an array contain specific sequence of values and add corresponding values to another array
I'm having some trouble with writing up a code that will go through an array containing rows of 5-bit strings, and depending on the sequence of the bits for it to add a corresponding 4-bit string into ...
1
vote
2
answers
65
views
Assigning the value of 2D array element using (int**) pointer results in EXC_BAD_ACCESS
I am a MacOS user and I want to write a function in C that assigns every element of a 2 dimensional (dynamically allocated) array a value
of 0. But when I compile and run the program an error message
...
0
votes
1
answer
26
views
Rewriting numpy function to handle 2d and 3d inputs
I am trying to rewrite an numpy function such that it can deal with 2d and 3d inputs.
Consider the following code:
import numpy as np
def adstock_geometric(x: np.array, theta: np.array):
x_decayed ...