11

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 much better than recent compilers. However, for slightly more complicated expressions like matrix products, reductions, transposition, powers, etc. the compiler cannot do much. On the other hand, ...


5

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 intermediate double precision operations, even when the source variables are single precision and the output location (left-hand side destination) is single precision. ...


4

Before I try to answer your question let me comment on the words "low level" in your question statement. In my opinion, I prefer not to say one programming model(one of SIMD and SIMT) is at a low level. As an example, during my undergraduage diploma project I had experienced many low level issues about GPU programming, which I have not encountered in CPU ...


4

There are multiple possible explanations: with floats and doubles the different number of computations happen due to, say, number of iterations/function evaluations (or something else, as pointed out by @Richard in the comments) there is some type conversions/implementations (say templated code) that are non-optimal with float types as opposed to doubles. I ...


4

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, not vectorization, unfortunately. While Python is going to be slower than C or C++, the for loop in question isn't actually a part of the computation, it's a different problem numerically because ...


2

I think you are comparing using high-level libraries built on GPGPU techniques, like C++ AMP, to programming SIMD at the lowest possible assembly language or intrinsics level. That's not a fair comparison. Since you specifically mentioned C++ AMP, let me use a basic example to argue that your premise isn't true. The introductory AMP example shows how to ...


2

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 you need to write z(1:10,:) like you have already correctly done on the left side. Why the flip in the matrix orientation occurs between the two calls, that is why z(1:10) inherits the column-ness in the first case and the row-ness ...


2

What you're describing is also a critical step in the k-nearest-neighbours method. So no need to reinvent the wheel, we can just look how other people have sped up that algorithm. I don't know about any dictionary like structure that returns this directly, but you could use a k-d tree. If properly implemented, you can get the k closest vectors pretty quickly....


2

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 description of the system in terms of multipole expansion moments. Let's first make a few preliminary comments. The magnetic field is described by the magnetic vector ...


2

Another approach is to use the fact that true is equal to $1$ and false is equal to $0$. If both conditions in the if statement are met, the result is $1$, otherwise it's $0$. segs = 1000000; r_int = 100; r_ot = 2000; x = linspace (0, 1000, segs); y = linspace (0, -1000, segs); [xx, yy] = meshgrid (x, y); circ = xx.*yy; circ_matrix = ( r_int<=circ ) .* (...


2

rmid = 0.5*(r_int + r_ot); rlen = 0.5*(r_ot - r_int); cc = double(abs(circ - rmid) <= rlen);


2

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 ambiguous (e.g. does SSE count as hardware acceleration?), and probably means different specific things in different industries. The Wikipedia page is a good ...


2

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 this case Gauss-Kronrod) on intervals that it will adaptively refine trying to reach the absolute and/or relative tolerance you requested. Since the parameter d alters the behaviour of the ...


1

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 std::copy() with an iterator over a single column will just give consecutive elements, hence better speed. Here's my solution: template <typename T> std::vector<T> ...


1

The cheapest representation is clearly if you convert the image into text, with attributes for the font style. You only need one byte per character (plus a couple of bits for the font style), which is always going to be cheaper than having to store coordinates for line segments etc. That's the power of using ancillary information: if you know that an image ...


1

Probably not, but you should parallelize over the parameters to the greatest extent possible. Use all the cores on your node and as many nodes as you can get your hands on.


1

Matlab is a bit more explicit than Octave: quiver3(4*t,3*cos(t),3*sin(t)) ??? Error using ==> quiver3 at 53 Not enough input arguments. There is no way of using quiver3 with only 3 arguments. What did you want to do?


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