48 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
38
views
Generic/multi-FS alternative to the XFS_IOC_RESVSP64 ioctl?
The XFS filesystem has (or used to have) a IOCTL named XFS_IOC_RESVSP64 for reserving space: You called it with a given file descriptor, and the XFS driver reserved an amount of space use by for your ...
0
votes
1
answer
45
views
How to serialize protobuf message into a pre-allocated byte array with offset in c#? (Protobuf 3.32.0.0)
The methods AI showed me are not working. However, one method mentioned by AI seems to be usable, but it is private:
private CodedOutputStream(byte[] buffer, int offset, int length)
So, how can I ...
0
votes
1
answer
52
views
Why is in-place assignment slower than creating a new array in NumPy?
I am trying to optimize a code, which has allocations inside a function that is repeatedly called in a loop. I ran some performance tests using jupyter and results were counterintuitive for me. As a ...
4
votes
2
answers
253
views
Why is pre-allocation of arrays slower than dynamic pushing in JavaScript?
I have been testing two methods of array creation and initialization in JavaScript using Node.js. One method involves dynamically pushing elements into the array, while the other method involves pre-...
1
vote
1
answer
54
views
The meaning of 'c(min =0, max =0)' in vapply()
salaries <- list(leaders = c(250, 200), assistant = 100, members = c(300, 200, 180, 120, 100))
> vapply(salaries, range, c(min=0, max=0))
leaders assistant members
min 200 100 100
...
0
votes
1
answer
244
views
Building a string using fold, and would like to speed it up by assigning the correct capacity
I have an implementation in a Rust struct that builds a very large string that will ultimately be written to a file. I wondered if this could be sped up by ensuring the string variable has the ...
2
votes
0
answers
71
views
pre-allocation vs re-allocation in Mac and Windows
I run into an issue while trying to understand the difference (in terms of computational time) between re-allocate a structure each time it is needed, against allocate a priori and then re-fill (a ...
1
vote
1
answer
262
views
Matlab class properties as handles, nested handles and class initialization/constructor and preallocation
I have been wondering how user defined Matlab classes as handle subclasses works. It seems, and also from what I read, that in some cases they reference to each other that might be unexpected or ...
2
votes
1
answer
264
views
Does preallocation of R list improve loop run time? how?
I am running a simulation in R, in which the outputs should be stored in numeric vectors in a variable of the type list. However, I am wondering why when I preallocated the list with numeric vectors, ...
2
votes
1
answer
161
views
Pre-allocate logical array with unassigned elements (not true or false)
I'm looking for the most efficient method of pre-allocating a logical array in MATLAB without specifying true or false at the time of pre-allocation.
When pre-allocating e.g. a ×ばつ5 numeric array I can ...
3
votes
2
answers
317
views
Efficiently store an N-dimensional array of mostly zeros in Matlab
I implemented a finite differences algorithm to solve a PDE.
The grid is a structured 2D domain of size [Nx, Nz], solved Nt times.
I pre-allocate the object containing all solutions:
sol = zeros(Nx, ...
0
votes
1
answer
721
views
how to preallocate a matrix in Matlab for a 'while' loop?
I want to preallocate a matrix in matlab to get rid of out of memory error, but how can i use preallocating for a while loop?
we use preallocating for a for loop like this:
m=10000;
x=zeros(m,1)
for ...
0
votes
0
answers
161
views
How to preallocate VideoWriter file in matlab
My code generates 10 videos in a for loop using the VideoWriter function. I know how to pre-allocate arrays but I am not sure how to make pre-allocation for VideoWriter files. writerObj file in the ...
4
votes
2
answers
248
views
Why can an empty array have a non-null dimension? [duplicate]
If we write, for example:
x = int8.empty(0,5)
whos x outputs:
% Name Size Bytes Class Attributes
% x 0x5 0 int8
Thus, we obtain a 0x5 empty array of class int8.
...
0
votes
0
answers
349
views
Preallocate memory for an unknown size of list in R
I am confused about the preallocation in R. We all know that preallocation will be much faster and it can solve the problems of over-memory. However, if we want to obtain a list with an unknown length,...