vectorization Questions
1
I was playing around with Compiler Explorer and ran into an anomaly (I think). If I want to make the compiler vectorize a sin calculation using libmvec, I would write:
#include <cmath>
#def...
Eugine asked 20/9, 2016 at 9:54
6
Solved
I was trying to embed some documents on postgresql with the help of pgvector extension and langchain. Unfortunately I'm having trouble with the following error:
(psycopg2.errors.UndefinedObject) ty...
Eastbourne asked 10/5, 2023 at 16:28
2
Solved
I have a 1D numpy numpy array with integers, where I want to replace zeros with the previous non-zero value if and only if the next non-zero value is the same.
For example, an array of:
in: x = n...
Euratom asked 14/1, 2018 at 16:3
1
Solve_ivp is an initial value problem solver function from Scipy.
In a few words
scipy.integrate.solve_ivp(fun, t_span, y0, method=’RK45’, t_eval=None, dense_output=False, events=None, vectorized=...
Frazier asked 18/2, 2020 at 9:48
4
Solved
Suppose I have a matrix that is 100000 x 100
import numpy as np
mat = np.random.randint(2, size=(100000,100))
I wish to go through this matrix, and if each row contains entirely either 1 or 0 I...
Buroker asked 25/6, 2019 at 15:49
2
Solved
I have a 3D numpy array of shape (t, n1, n2):
x = np.random.rand(10, 2, 4)
I need to calculate another 3D array y which is of shape (t, n1, n1) such that:
y[0] = np.cov(x[0,:,:])
...and so o...
Kalle asked 3/11, 2016 at 5:59
13
Solved
You can apply a function to every item in a vector by saying, for example, v + 1, or you can use the function arrayfun. How can I do it for every row/column of a matrix without using a for loop?
Volscian asked 21/2, 2010 at 19:58
4
I'm trying to install postgres vector extension on my mac but am getting
ERROR: extension "vector" has no installation script nor update path for version "0.4.0".
Here's what I...
Gaffrigged asked 7/3, 2023 at 15:32
3
Solved
I want to write applications in JavaScript that require a large amount of numerical computation. However, I'm very confused about the state of efficient linear-algebra-like computation in client-si...
Minny asked 21/3, 2017 at 2:51
1
Solved
std::replace implementation can be optimized using vectorization (by specializing the library implementation or by the compiler).
The vectorized implementation would compare and replace several ele...
Danille asked 2/3, 2024 at 10:39
4
Solved
I'd like to vectorize calls like numpy.arange(0, cnt_i) over a vector of cnt values and concatenate the results like this snippet:
import numpy
cnts = [1,2,3]
numpy.concatenate([numpy.arange(cnt) ...
Eternity asked 17/11, 2013 at 6:35
3
Solved
Suppose we have a sample dataframe like the one below:
df = pd.DataFrame({'A': [np.nan, 0.5, 0.5, 0.5, 0.5],
'B': [np.nan, 3, 4, 1, 2],
'C': [10, np.nan, np.nan, np.nan, np.nan]})
>>> ...
Pavonine asked 18/2, 2024 at 10:38
6
Solved
I'm looking to calculate highly parallelized trig functions (in block of like 1024), and I'd like to take advantage of at least some of the parallelism that modern architectures have.
When I compi...
Nosebleed asked 24/2, 2011 at 20:9
2
Solved
I am trying to vectorize the following function to drop the sapply loop. I am calculating cumulative skewness.
cskewness <- function(.x) {
skewness <- function(.x) {
sqrt(length(.x)) * sum(...
Emden asked 5/1, 2024 at 20:46
3
Solved
I have a data set and am trying to compare whether any value in a string appears in any of a set of columns in the same row.
A subset of the data looks like:
df <- data.frame(ID=c(1,2,3,4,5),
...
Stauder asked 5/1, 2024 at 12:28
5
Solved
I have np matrix and I want to convert it to a 3d array with one hot encoding of the elements as third dimension. Is there a way to do with without looping over each row
eg
a=[[1,3],
[2,4]]
sh...
Trumpery asked 30/4, 2016 at 21:15
11
Solved
Suppose a1, b1, c1, and d1 point to heap memory, and my numerical code has the following core loop.
const int n = 100000;
for (int j = 0; j < n; j++) {
a1[j] += b1[j];
c1[j] += d1[j];
}
This...
Scornful asked 17/12, 2011 at 20:40
2
Solved
Consider the following small search function:
template <uint32_t N>
int32_t countsearch(const uint32_t *base, uint32_t needle) {
uint32_t count = 0;
// #pragma clang loop vectorize(disable)...
Ambriz asked 22/7, 2018 at 4:0
12
Solved
Can you tell me when to use these vectorization methods with basic examples?
I see that map is a Series method whereas the rest are DataFrame methods. I got confused about apply and applymap meth...
Foggy asked 5/11, 2013 at 20:20
5
Solved
Is there an analog for reduce for a pandas Series?
For example, the analog for map is pd.Series.apply, but I can't find any analog for reduce.
My application is, I have a pandas Series of list...
Conventionalism asked 26/1, 2016 at 0:18
3
Solved
Are for loops really "bad"? If not, in what situation(s) would they be better than using a more conventional "vectorized" approach?1
I am familiar with the concept of "vectorization", and how pand...
Corvus asked 3/1, 2019 at 18:54
3
Numpy doesn't yet have a radix sort, so I wondered whether it was possible to write one using pre-existing numpy functions. So far I have the following, which does work, but is about 10 times slowe...
Gangplank asked 1/12, 2015 at 15:22
2
Solved
I have two large sets of 2D points and need to calculate a distance matrix. I need it to be fast so I used NumPy broadcasting. Of two ways to calculate distance matrix I don't understand why one is...
Aretino asked 30/7, 2021 at 13:21
4
Solved
I am trying to calculate a distance matrix for a long list of locations identified by Latitude & Longitude using the Haversine formula that takes two tuples of coordinate pairs to produce the d...
Carolinecarolingian asked 28/12, 2015 at 23:22
1
Solved
Consider the following valarray-like class:
#include <stdlib.h>
struct va
{
void add1(const va& other);
void add2(const va& other);
size_t* data;
size_t size;
};
void va::add1(...
Darbies asked 17/8, 2023 at 10:58
1 Next >
© 2022 - 2025 — McMap. All rights reserved.