12 votes
Accepted

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

It is true that compilers are getting better and better at auto-vectorization, and for basic coefficient-wise operations like 2*A-4*B a library like Eigen cannot do ...
ggael's user avatar
  • 689
7 votes
Accepted

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

I have looked at your simple code example, and my suspicion is that what you observe in loss of speed is due to the C-heritage requirement that right-hand side expressions be evaluated using ...
hardmath's user avatar
  • 3,359
4 votes
Accepted

Vectorised second order ode solving in python

Is there a way to solve for multiple initial conditions without resorting to a slow python for loop? I think the solution to your problem might be parallelization, ...
Jose Fernando Lopez Fernandez's user avatar
4 votes

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

There are multiple possible explanations: with floats and doubles the different number of computations happen due to, say, ...
Anton Menshov's user avatar
  • 8,672
3 votes

What exactly is Hardware Acceleration?

Hardware acceleration means any code run on specialized hardware, as opposed to software run on general purpose CPUs such as standard x86 processors on your PC. I suppose the term is inherently ...
LedHead's user avatar
  • 1,243
3 votes
Accepted

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

We consider two thin infinite straight parallel wires at distance $2 a$ apart and carrying equal currents $I$ in opposite directions. We need to find an approximate ...
Maxim Umansky's user avatar
3 votes

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

Another approach is to use the fact that true is equal to $1$ and false is equal to $0$. If both conditions in the ...
Ertxiem - reinstate Monica's user avatar
2 votes
Accepted

Solving differential equation by setting vectorization `on` in MATLAB

You have not completely vectorized your code. z(1:10) is the first 10 numbers in the data of z, not the first 10 rows. For that ...
Lutz Lehmann's user avatar
  • 6,064
2 votes
Accepted

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

rmid = 0.5*(r_int + r_ot); rlen = 0.5*(r_ot - r_int); cc = double(abs(circ - rmid) <= rlen);
user7440's user avatar
  • 617
2 votes

integral including a vector

The function integrate.quad is a python wrapper to the DQAGSE function from QUADPACK. This function uses adaptive quadrature, i.e. it will apply a fixed rule (in ...
GertVdE's user avatar
  • 6,179
1 vote
Accepted

Vectorize a part of a huge matrix in C++

So I invented my own solution. Critique, suggestions are highly appreciated. I learned that elements are stored in a matrix as column-major. So I assumed that using ...
The Quantum Physicist's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible