36,167 questions
2
votes
1
answer
150
views
Boost multiarray, how to declare a class member and populate it at run time
I am attempting to move away from std::vector<std::vector<int>> types and use boost::multi_array in its place. I am struggling how to initialize such data members though.
I used to have a ...
Advice
0
votes
3
replies
88
views
Restrict keyword and pointers to pointers
I'm in C and I have an int ** (2 dimensional array, it's basically a matrix, it's actually set up a little bit complicated but there's no internal aliasing, so it's not relevant).
is this int** ...
3
votes
2
answers
125
views
How to properly constrain two-dimensional array types to be square in Ada?
I'm trying to create a package of generic adjacency matrices to define graphs, and the first goal is to define a static version based on two-dimensional array:
with Ada.Containers.Vectors;
generic
...
1
vote
2
answers
110
views
Get previous and next row of a matched row from a 2d array
I have the following code to sort the items based on a timestamp.
$arr = [];
foreach(glob('*.json') AS $item) {
$data = json_decode(file_get_contents($item), true);
$arr[] = [
'taken' =...
-1
votes
2
answers
112
views
How to make it so that the arrays inside the array don't get changed? [duplicate]
I am trying to make a loop that will fill in an array of arrays that will contain every possible colour value in rgb form given the bit depth. However, I have noticed that even after an array is ...
1
vote
1
answer
89
views
How to flatten multidimensional array in Azure Data Factory/Synapse
I want to extract "email" from JSON using ADF/Synapse.
Below is the JSON that I want to flatten and extract all "email" which is in an object in a multidimensional array:
{
"...
2
votes
1
answer
94
views
Convert ADODB RecordSet to a 2 dimensional array
I want to read an Excel file without openening the file and put the result in a two dim. array. For this I use the below code
Sub ReadExcelFileWithoutOpening()
Dim conn As Object
Dim rs As Object
Dim ...
-1
votes
1
answer
170
views
Use of 1D vs. 2D vectors in C++ implementation [closed]
After some extensive search I could not find a clear answer to the following issue. When one is to compare the 1D (vector<type>) vs 2D (<vector<vector<type>>>) vector ...
1
vote
2
answers
183
views
how to efficiently save a large image using stbi_write_png which is stored in a multidimensional array
In my initial question there was some confusion as to what I was really trying to do.
Specifically, when I edit large images i store them in an array of pixels where Pixel image[iwid][ihei] is my ...
1
vote
1
answer
108
views
Is it possible to expand/deduce a parameter pack to/from array dimensions?
I am using the following code for automatic vector/matrix template parameter deduction (I am particullarily interested in automatic deduction from passing initializer lists)
template<class T, ...
1
vote
2
answers
91
views
XML with attributes to array in PHP
I am trying to convert an XML string into multi-dimensioned PHP array. The difficulties are that XML comes with attributes and has nested values. My code works at parent level data but I am not sure ...
2
votes
3
answers
192
views
Is there a performance drawback when declaring 2D arrays using int** compared to int (*)[N] in C?
I have a question about the performance tradeoffs between different ways of storing 2D arrays in memory in C.
I know that if I declare a 2D matrix A with dimensions MxN by the following:
int (*A)[N] = ...
0
votes
0
answers
86
views
I am confused by mdspans' "layout policy", "layout mapping" and "layout mapping policy"
I'm looking at the newly-introduced std::mdspan class template (also described here on SO). One of the template parameters is, according to cppreference:
LayoutPolicy - specifies how to convert ...
0
votes
1
answer
83
views
how to create uniform nested lists and convert them in to multi dimensional arrays?
i would like to create a nested list of arbitrary depth (containing numerical values specifically) with uniform arbitrary lengths at each level and then compress it to a NumPy array of minimum ...
1
vote
2
answers
72
views
Vector from Class objects vector as 2D vector function parameter
Solution requirements:
Pre C++11
Statements:
Function someFunction exists, that accepts 2D vector as vector of string vectors: vector2d.
Class someClass exists, that contains 1D vector of strings: ...
1
vote
1
answer
84
views
Declaring multidimensional arrays in C [duplicate]
#include <stdio.h>
int main() {
int arr[2][3] = {1,2,3,4,5};
printf("%d", (*arr)[4]);
return 0;
}
See the array declaration in the above code. As per my knowledge, this ...
0
votes
1
answer
85
views
Facing issue while with Parse JSON having nested array in TIBCO BW6
In TIBCO BW6, I am trying to parse below JSON having nested array with below XSD.
But getting error : TIBCO-BW-PALETTE-REST-100016: An error occurred while converting json to xml: Content of array ...
0
votes
1
answer
113
views
How to convert a 1 dimensional array buffer to a 2 dimensonal format
I have this intermediary buffer that has the entire contents of a file: char *intermediary_buffer
I need to move this to a different 2D buffer: char **final_buffer Where a new row is started every ...
2
votes
2
answers
116
views
How to print one string in a 2D character array?
I am using Code::Blocks 20.03. I have been trying to print a string from a 2D char array but only receive random characters.
int main() {
char str[5][80];
str[1][80] = "hello world";
...
2
votes
1
answer
123
views
Idiom for owning multi-dimensional arrays, after mdspan standardization?
The C++ standard library, and specifically its part involving containers and ranges, is mostly "one-dimensionally oriented" - things have a start and and end you go from start to end. If you ...
2
votes
1
answer
79
views
Rotation of square Matrix not working correctly after first rotation
Please check the below code, the mat array after the second rotation should be identical to the target array tar. However, it is not happening. Could you please review to check where the logic is ...
1
vote
3
answers
117
views
Recursively convert multidimensional array data into new multidimensional variables with hierarchical metadata included
I have an array of some parameters (like a YAML config file) and this need to be written to database finaly with primary ids and so on.
For example this is a part of my array:
$settings = [
'basic'...
-2
votes
1
answer
74
views
Copy a multidimensional array and replace one certain key in the duplicate
We have a large web app with a lot of files where english language strings are in a file.
Consider this file: sample.php
<?php
$newFlowString['english']['login'] = "login";
$...
2
votes
2
answers
80
views
Pulling values out of one multidimensional array and putting them into several 1D arrays (C)
I am trying to sort the values in the Data array into Column arrays X1,X2, and Y_actual. The code I have written out makes sense to me, and returns the correct array1,array2, and array3 values if I ...
1
vote
2
answers
108
views
The passing of 2-dimensional arrays to functions in C by only stating the size of the second dimension
When passing a 2-dimensional array to a function in C, I normally just pass it by using a single pointer.
Example : void process_array(int* arr, int rows, int cols)
I see 2-dimensional arrays also ...
0
votes
3
answers
147
views
For Loop to Create Data, Save to Array, and Display array on Worksheet
I am trying to use a for loop to create a series of data, assign that data and the index number to an array, and then send that array to a worksheet.
This sends only the data and not the index number ...
1
vote
1
answer
75
views
Adding to a 2 dimensional array in apps script permanently
I am trying to permanently add a row to a 2 dimensional array in apps script, however it only adds the row temporarily and it's gone as soon as the function completes.
I plan to do more with this ...
3
votes
2
answers
124
views
storing all c stuct arrays in only one single memory segment obtained with malloc/calloc
Suppose I have a database in memory that I want to modify.
Let's say the tables are phone information and items.
The phone information consists of a name up to 99 characters and a character code.
The ...
1
vote
1
answer
86
views
Using scipy.ndimage.correlate only calculate elements with full overlap
I am trying to use scipy.ndimage.correlate to replicate the output of IDL convol() function. The IDL function only calculates elements where there is full overlap between the input and the kernel.
So, ...
0
votes
4
answers
183
views
Can I check the value of the array within a two dimensional array in C
char array[8][13];
memset (&array, 0, sizeof(array));
/* this is a rough example this is in a struct that is memset */
if (array[0])
{
printf("this is valid"); /* again this code is ...
0
votes
1
answer
71
views
Zipping two ndarrays in Rust
I can iterate over rows (or columns) of an ndarray in Rust, e.g.:
use ndarray::array;
fn main() {
let a = array![[1, 5], [3, 7]];
let b = array![[2, 4], [8, 6]];
for row in a.rows() {
...
1
vote
2
answers
106
views
How do I use quicksort in C with a multi-dimensional array? I am getting an incorrect result
I am trying to sort the tuples in the 2D array based on a single column value similar to Javascript's sort function.
arr.sort((a,b) => a[0] - b[0])
C Code :
#include<stdio.h>
#...
6
votes
1
answer
76
views
For qsort in C, is there a way to specify the sorting index for the comparator function when sorting a multi-dimensional array? [duplicate]
I have the following code :
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a, const void *b) {
return (((int*)a)[0] - ((int*)b)[0]);
}
int main() {
int arr[][4] = {
...
0
votes
1
answer
66
views
Cut-and-overlap reduction of N-dimensional array
Note: I have no idea what one might call this operation, so I've gone with "cut-and-overlap". Please let me know if there is an accepted terminology for something like this!
Intro
I need to ...
0
votes
0
answers
50
views
Find the page in a 3D matrix that is closest to a given matrix
One can easily concatenate (stack up) four arrays by using:
B = cat(3, A, A, A, A); % here A is 2-dimensional M x N matrix and B is 3-dimensional M x N x 4 stack
How is it possible to concatenate (...
0
votes
0
answers
37
views
How to convolve a 3D array with Lorentzian kernel along axis=2?
I have an array img_data of shape (x, x, n_channels) and I want to convolve / smooth along the axis=2.
Specifically, I would like the output shape to be (x,x,n_channels//3), after convolving the ...
0
votes
2
answers
79
views
Finding All Instances Of A Specific Word Within A Multidimensional Array
I have here a nested array:
const roster = [["Ryu","RyuNormal"], ["Ryu as Ken","RyuKen"], ["Ryu as Akuma","RyuAkuma"], ["Chun-Li",&...
-3
votes
1
answer
51
views
How to make percent chance that there will be a * in a 2D array decrease
My result
I need to make the number of stars decrease with each line, but I have no idea how.
import random
import numpy as np
import sys
size = int(sys.argv[1])
mat = np.full((size, size), '\x1b[35m....
4
votes
3
answers
175
views
How memory address for pointer to arrays is same as an element in 2D array?
Consider the following code:
#include <stdio.h>
int main()
{
int **s = (int**)malloc(3 * sizeof(int*));
for (int i = 0; i < 3; i++)
{
printf("%d\n", s+i);
}
...
0
votes
0
answers
81
views
Created nested json object in vb.net
I am unable to create a json object with nested objects. See the code and the current output versus the desired output.
Goal Output:
{
"carlist" : [
{
"attributes": [
{
...
0
votes
2
answers
72
views
Copy first level keys of a 2d array as a new column of each row
Assuming a 2d array as input, how can each first level key be copied as a new element in its second level row?
Sample input:
$members = [
'myname' => ['userid' => 52, 'age' => 46],
'...
1
vote
2
answers
93
views
Why does this multidimension array output as list?
A list
$tags = 'a','b','c','d','e'
the process
$array = New-Object 'object[,]' 3,5
$array[0,0] = $tags[0]
$array[0,1] = $tags[1]
$array[0,2] = $tags[2]
$array[0,3] = $tags[3]
$...
0
votes
1
answer
69
views
Writing to multidimensional arrays with variable dimension
I've initialized a list of arrays of different dimensions in Python and want to write to the entries of the arrays. If I want to write to the entry list[i, m1, m1, ..., m1, m2, m2, ..., m2] where m1 ...
0
votes
2
answers
102
views
Clever way to write a nested for loop or N dimensional array as a string
I'm working on a tool to create inputs for array simulations, where various inputs are iterated over multiple series to create all combinations of inputs. Some values need to iterate coupled together, ...
3
votes
1
answer
115
views
Why should native sorting functions be called by array_walk() with explicit sorting function parameters?
I ran a few tests on 2d arrays and found that in some contexts, native sorting functions can give unexpected results when array keys are 2, 5, 10, or 13.
$expected = range(0, 11);
$array = array_fill(...
0
votes
3
answers
221
views
Using malloc to create triple pointer from 3d array to be passed to function which takes a triple pointer as an argument and updates its elements
I am currently attempting to create a triple pointer to point to and update the contents of a statically allocated 3d array in C. The updating of the elements of the array will be completed by a ...
0
votes
3
answers
124
views
Group values of a flat array into sets of consecutive strings with the same leading characters
I have a dynamic array, each group of lines start with a specific code "S10.G00.00", "S10.G00.01", "S10.G00.02" ...
The array may be like this:
array:20 [▼
0 => &...
1
vote
1
answer
79
views
How to check non-constant array
when I get my data series with foreach, I get the result in the structure below
in the structure
[N]==1 match result 1 win [N]==2 match result ends in a draw [N]==3 match result away win [O] parts are ...
1
vote
1
answer
130
views
Issue with loading csv file into a 2d array in C
What am I trying:
To Load a csv file into memory of 2d array, then print the array to output.
The format in which I planned to load can be represented like the below give image:
In simple terms, the ...
1
vote
0
answers
93
views
Rust ndarray, statically allocate an array
I have an ndarray array that is used throughout my program:
Note: ndarray and nalgebra are both used here, imported as nd and na respectively.
let test: nd::ArrayBase<nd::OwnedRepr<na::...