which is fastest way to inverse a number in c++?

Started by
16 comments, last by The Communist Duck 13 years, 3 months ago
Yes but that article, that function sets up some other variables and thus it is slower.
The fastest way to batch process is to use MMX for integers and SSE for floats using the CPU.

The GPU way would be way faster. Use CUDA or OpenCL.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Advertisement

'iMalc' said:


That's called "negating", not "inversing", and yes x = -x is the answer.

A bit nitpicking: You're right: The usual name is negation. But on the other hand, negation is a specialization of the inverse with additive math in mind. See e.g. here on wikipedia. This is a similar distinction as with the neutral element, what is 0 for addition and 1 for multiplication.


I'd agree that negating is not inverting at least as far as programming is concerned. One's compliment could easily be interpreted as the "inverse" of a number in a program, which is not the same as the negation of a number.

edit:

" 'inverse' is a noun. The verb is 'invert'. The 'inverse' is the result of inverting."

oh god. You'd think with a browser that underlines everything in red people (including me) would catch such things.
/shame on family
Aarrgh.

'inverse' is a noun. The verb is 'invert'. The 'inverse' is the result of inverting.
'Antheus' said:

This article outlines several other methods.
Yes but that article, that function sets up some other variables and thus it is slower.
The fastest way to batch process is to use MMX for integers and SSE for floats using the CPU.

The GPU way would be way faster. Use CUDA or OpenCL.
No it should be done in the cloud with HTML and variables.

'V-man' said:
'Antheus' said:

This article outlines several other methods.
Yes but that article, that function sets up some other variables and thus it is slower.
The fastest way to batch process is to use MMX for integers and SSE for floats using the CPU.

The GPU way would be way faster. Use CUDA or OpenCL.
No it should be done in the cloud with HTML and variables.


:) If you believe the buzz you could almost believe that.



'Hodgman' said:

'V-man' said:
'Antheus' said:

This article outlines several other methods.
Yes but that article, that function sets up some other variables and thus it is slower.
The fastest way to batch process is to use MMX for integers and SSE for floats using the CPU.

The GPU way would be way faster. Use CUDA or OpenCL.
No it should be done in the cloud with HTML and variables.
:) If you believe the buzz you could almost believe that.
I believe every gd.net meme, and anything posted on dailyWTF...

'V-man' said:
'Antheus' said:

This article outlines several other methods.
Yes but that article, that function sets up some other variables and thus it is slower.
The fastest way to batch process is to use MMX for integers and SSE for floats using the CPU.

The GPU way would be way faster. Use CUDA or OpenCL.
No it should be done in the cloud with HTML and variables.


made me chuckle. All this hype about the cloud can get pretty silly.
Just a wannabe grinding in this game we call Life.
I fail to see how x = -x could possibly be a bottleneck. Unless you were developing in a language (written in a language) repeat previous about 6 times - written in Python.

This topic is closed to new replies.

Advertisement