21 questions from the last 30 days
Advice
1
vote
12
replies
154
views
How can I combine two or more arrays into a unique set without changing the data type in Powershell?
Say I have a combination of the following:
# This is a [string[]] type
$A = [string[]]@("Aasdf","Casdf","Basdfs")
# This is a [string] type
$B = "Dasdfs"
# This ...
-1
votes
2
answers
143
views
Array Updating Strangely
I'm trying to do some simulation of CPU memory allocation in Java. I've got a NEW queue, a READY queue, and then a block of memory, represented by an array of size 256. I'm meant to load in a series ...
Advice
1
vote
5
replies
116
views
CUDA C: How to keep an entire, somewhat complex calculcation on the GPU w/o bringing intermediate results back to host
So I'm trying to learn CUDA C. I had an idea for a simple code that could calculate the simple average of a float array. The idea is that main() will call a host function get_average(), which will ...
2
votes
1
answer
173
views
How do you replace multiple elements of an array in C with elements of a different array
If I wanted to replace large chunks of an array in C with items from another list, are there any solutions that don't involve for loops or writing code like the following?
int64_t foo[size];
foo[value]...
-1
votes
1
answer
144
views
How to use strtok to separate into tokens and append to an array [closed]
I am working on a function where I will be recieving data from an SPI communication and then get the date/month/year from them
I have created a function to do the latter
void set_file_header(const ...
2
votes
4
answers
139
views
Count Common Values between Different 2D Arrays
I have 2 arrays 2d and I would like to compare both and count the common values between them, for instance here is my code:
import numpy as np
def f_m_common(V_R, V_A):
r = len(V_A)
c = len(...
0
votes
3
answers
123
views
Convert JSON file to CSV using jq, expanding nested array data in multiple columns
I need to convert a JSON file to CSV in a bash script, this a sample file:
{
"total": 1,
"jobs": [
{
"deviceData": {
"deviceId": "...
0
votes
1
answer
133
views
Finding an Integer value in A binary file in C [closed]
In C, I first opened a binary file like this---
FILE *BINfile = fopen("./tmp.bin", "rb+");
Then I transferred the data into an unsigned char array (typedef as byte) like this---
(...
2
votes
1
answer
130
views
Python GC for ctypes memory / reference "holding"
I have written a CFD code which I POC'd in Python. In order to accelerate the computationally expensive parts, I have rewritten these methods in C. I am calling them using ctypes which seems to work ...
1
vote
2
answers
85
views
Index array without assigning it to parameter
I have to split a string and use a part of it for further processing. So the idea is:
string='aaa-bbb-ccc-ddd'
parts=(${(@s:-:)string})
print -- $parts[3]
# ccc
I would like to refactor the second ...
-2
votes
1
answer
140
views
Javascript function has no return value when return statement specified for every case
I came across a problem in JavaScript where an item is to be inserted into an ordered array such that the array remains in the correct order. e.g. insertInOrder(19, [1, 2, 10, 20]) should return [1, 2,...
1
vote
1
answer
126
views
Broadcasting DataFrames across NumPy array dimensions
I'm working with a large Pandas DataFrame and a multi-dimensional NumPy array. My goal is to efficiently "broadcast" a specific column of the DataFrame across one or more dimensions of the ...
-2
votes
1
answer
190
views
how to shuffle the words in a 1d array? [duplicate]
I am writing a shuffling program to shuffle the words in an array, not the letters. For this purpose, I have created the code below:
void shuffle(char *str)
{
srand(time(NULL));
int i = 0;
...
2
votes
1
answer
146
views
My Swift for in loop is not stopping when I call an await function
I have a for in loop in my ViewModel that I want to process elements in an array one at a time, and if the API result from each element has a count of 1, then continue to the next element in the array,...
1
vote
1
answer
105
views
Why does my rotation (up / down) break when I rotate 90 degrees left or right, and how do I fix it?
I'm trying to make a simple 3d renderer in CMU Graphics using rotation matrices. When I rotate the camera 90 degrees (left or right), and I try rotating (up / down), it does a "barrel roll" ...