Questions tagged [vectorization]

For questions about converting multiple operations a single "vectorized" operation. Example questions might include how to alter code to ensure certain "vectorized" instructions are used.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
93 views

Solving differential equation by setting vectorization `on` in MATLAB

This is a follow up to my previous question posted here. I've set up an ode system in MATLAB and I'm trying to vectorize the code to increase the speed of computation. The follow is the code for my ...
  • 459
0 votes
1 answer
268 views

How to compare 2D vector fields and minimize the difference?

I want to compare the field of two electrical currents and compare the resulting field to a magnetic dipol field and find magnetic momentum that minimizes the difference of the two fields. My current ...
1 vote
0 answers
62 views

Help with vectorized computation where vector multiplication would need to create an additional dimension

I want to use vectorized computation (with python and numpy) to do some calculation involving bessel functions. As is often the case, I need to calculate the sums of bessel functions of (infinit) ...
2 votes
1 answer
1k views

Vectorised second order ode solving in python

I am trying to write a python program that simulates the motion of a large number of particles by numerically integrating a second order ordinary differential equation. I first split the ODE into two ...
1 vote
2 answers
261 views

How to vectorize 2 nested for loop with one complex condition in the inner loop?

Octave calculations is too slow specially when you deal with scientific calculations that can span a very very large matrix, even just iterating. I have to vectorize it to speed up the calculation. ...
  • 113
4 votes
2 answers
602 views

Compiled c++ code runs much faster with double than float. Explanation?

I am still rather new on here and I hope question is suitable for this forum otherwise please help me migrate it to greener pastures. I am an electrical engineer specializing in applying mathematics ...
1 vote
1 answer
123 views

What exactly is Hardware Acceleration?

I'm able to find many definitions and notions to this term including, Implementing the algorithm (or part of it) in hardware :- Instructions like FMAD; FPGAs Parallelizing the algorithm at the ...
  • 287
3 votes
1 answer
2k views

integral including a vector

I need to calculate the integral of this function def f(z): return ((1-2*z)*np.exp(-d/z))/(((1-z)**(2+d))*(z**(2-d))) Here d is a constant. I am using this ...
  • 163
1 vote
0 answers
260 views

Vectorize function integration

I need to implement the following in python: For a given discrete time series $Z_t$ ($t={0...T}$), find the smallest $t$ such that: $$c\sum_{s=0}^t e^{[k(Z_t-Z_s)+m(t-s)]} \geq \frac{p^*}{1-p^*} $$ ...
  • 163
3 votes
1 answer
2k views

Vectorize a part of a huge matrix in C++

I have a large matrix, side-length is about $n\geq 1000$. I need to do element-wise multiplication of this matrix with another matrix many, many times. I make this process by: Vectorizing (through ...
5 votes
1 answer
1k views

Why do libraries need hand-vectorized code instead of compiler auto vectorization

C++ eigen library does vectorization for different architecture, like SSE, NEON etc. In their documentation they mentioned that, Eigen vectorization is not compiler dependent. But most modern ...
0 votes
1 answer
49 views

Vectorization Algorithm using only rectangle

As stated in the title I have a raster image (black or white) with no complex or fuzzied components (only horizontal or vertical text, italic or bold are allowed). I need to express that raster image ...
  • 101
0 votes
2 answers
142 views

Matlab Vectorization of columns in a 2D matrix and single element multiplication

MATLAB. I am trying to vectorize a loop in which each column vector of a 2D matrix (n-by-n) is found by multiplying each single element in a diagonal matrix with a column vector in another n-by-n 2D ...
3 votes
2 answers
1k views

Why is SIMD programming on such a low level in CPU's compared to GPU's?

Just speaking from my experience in c++ - Its really tricky to take advantage of the SIMD capabilities of modern CPU's for more complex algorithms. If I see an opportunity from a high level OO ...
4 votes
1 answer
397 views

Fast way to repeatedly solve a small nonlinear equation system

A small nonlinear equation system (sizes around 12 ✕ 12) needs to be solved repeatedly (millions of times); each time with some variation in parameters/coefficients (although the equation set is ...
  • 149
0 votes
1 answer
321 views

quiver3 gives non-conformant arguments?

Does anyone know why I'm seeing these errors? I'm not giving it a matrix. ...
  • 101
5 votes
3 answers
596 views

Manipulating Matrices in Matlab

Suppose I have a matrix $A$ of size $n_1 \times n_2 \times n_3$ Now, I have another matrix $B$ of size $n_1 \times n_2 \times n_3 \times N$ where $N<n_3$ I'd like to create the following matrix ...
9 votes
3 answers
4k views

How do I know if my code is being vectorized by the compiler?

As exemplified by Jed Brown's answer to Costs of lookups versus calculations, using vectorized vs non-vectorized floating point operations results in much faster code. Many modern compilers claim ...
7 votes
1 answer
1k views

How do I vectorize this 4-D matrix operation in Matlab?

I need to do a large number of matrix operations in Matlab, but one of the matrices is 4-D and my normal instincts for correct vectorization are failing me. Right now I'm using a loop. Maybe somebody ...
  • 285
12 votes
2 answers
12k views

Octave: calculate distance between two matrices of vectors

Suppose I have two matrices Nx2, Mx2 representing N, M 2d vectors respectively. Is there a simple and good way to calculate distances between each vector pair (n, m)? The easy but inefficient way is ...