36,165 questions
2
votes
1
answer
158
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 ...
3
votes
2
answers
126
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
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:
{
"...
-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
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, ...
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
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
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
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
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 ...
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
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 ...
0
votes
3
answers
150
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 ...
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 ...
0
votes
4
answers
185
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 ...
1
vote
2
answers
107
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>
#...
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
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 ...
-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....
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": [
{
...
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
2
answers
103
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, ...
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 ...
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
0
answers
94
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::...