I'm trying to get GCC (or clang) to consistently use the SSE instruction for sqrt instead of the math library function for a computationally intensive scientific application. I've tried a variety of GCCs on various 32 and 64 bit OS X and Linux systems. I'm making sure to enable sse with -mfpmath=sse (and -march=core2 to satisfy GCCs requ...
I know this will really turn out to be simple, but my brain is just not working. I need a function in C# that will return -1 if the integer passed to the function has a negative sign, return 1 if the integer has a positive sign and return 0 if the number passed is 0. So for example:
int Sign=SignFunction(-82); // Should return -1
int Si...
Hi
I am creating a web shop and have to calculate how much to charge the customer to make sure that the fees are cancelled. The payment system adds the fees and I want the customer to pay them.
The fees are 2.45% and € 1.10.
This means that if the customer shops for € 100, and I report that value to the payment system, we will only ge...
Possible Duplicates:
Open Source Expression Engines (Java)
Convert mathematical string to int
Hello,
If I have a string that says anything along the lines of "x+6", how can I turn that into a function that can be evaluated with me substituting a variable in for x.
For example, say I want to run it into a foreach loop:
...
I'm trying to determine the degree size of the field-of-view of a Droid Incredible smartphone's camera. I need to know this value for an application that I'm developing. Does anyone know how I can find out/calculate it programmatically?
...
Here is the main problem. I have very large database (25,000 or so) of 48 dimensional vectors, each populated with values ranging from 0-255. The specifics are not so important but I figure it might help give context.
I don't need a nearest neighbor, so approximate neighbor searches that are within a degree of accuracy are acceptable....
suppose i a have a multiplicative expression with lots of multiplicands (small expressions)
expression = a*b*c*d*....*w
where for example c is (x-1), d is (y**2-16), k is (x*y-60)..... x,y are numbers
and i know that c,d,k,j maybe zero
Does the order i write the expression matters for faster evaluation?
Is it better to write c*d*...
I have 3d mesh and I would like to draw each face a 2d shape.
What I have in mind is this:
for each face
1. access the face normal
2. get a rotation matrix from the normal vector
3. multiply each vertex to the rotation matrix to get the vertices in a '2d like ' plane
4. get 2 coordinates from the transformed vertices
I don't know if th...
I know how to move, rotate, and scale, but how does skewing work? what would I have to do to a set of verticies to skew them?
Thanks
...
A product of n copies of a set S is denoted Sn. For example, {0, 1}3 is the set of all 3-bit sequences:
{0,1}3 = {(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)}
What's the simplest way to replicate this idea in Python?
...
What is a fast way to compute the (long int) ceiling(log_2(i)), where the input and output are 64-bit integers? Solutions for signed or unsigned integers are acceptable. I suspect the best way will be a bit-twiddling method similar to those found here, but rather than attempt my own I would like to use something that is already well test...
hi all i need to write the next formula in latex, but i can't put it in multiple lines and with the right indentation for the subsequent lines, this is my code.
\begin{displaymath}
\pi_D^B(r) = \{z^{(|D|+1)}|\exists x \in r(z[D]=x[D])\wedge \\
\forall y \in r (y[D]=z[D]\Rightarrow y[T]\subseteq z[T])\wedge \\
\...
My current research project involves studying billiards orbits in four-dimensional polytopes. One sets into motion a point-mass, starting on one of the facets of the polytope, which follows a straight trajectory within the polytope except on collision with a wall, when it is subjected to an elastic response (i.e., its velocity vector is ...
In a project I'm working on the user creates a circle and choose a point on that circle, P=(px,py). For the question's sake, let's assume the center of the circle is at (0,0).
After the previous steps, the user can then change the eccentricity of the ellipse (as it was a circle it was actually an ellipse with e=0). While he changes the...
Note that this question contains some spoilers.
A solution for problem #12 states that
"Number of divisors (including 1 and the number itself) can be calculated taking one element from prime (and power) divisors."
The (python) code that it has doing this is num_factors = lambda x: mul((exp+1) for (base, exp) in factorize(x)) (whe...
Is there a way to round to the nearest number in the Boost library? I mean any number, 2's, 5's, 17's and so on and so forth.
Or is there another way to do it?
...
Over on FSHUB, LethalLavaLand said,
Let me plot my values!
So the question is, how can I plot a data series in F# using built-in .NET 4.0 controls?
...
I need to run "mode" (which value occurs most frequently) on an array of singles in vb6. Is there a quick way do do this on large arrays?
...
I'm using python, and I want a function that takes a string containing a mathematical expression of one variable (x) and returns a function that evaluates that expression using lambdas. Syntax should be such:
f = f_of_x("sin(pi*x)/(1+x**2)")
print f(0.5)
0.8
syntax should allow ( ) as well as [ ] and use standard operator precedence. ...
I just wrote this function to break a number into its prime factors. Is the algorithm I'm using a good one? How might I improve this function? So far it seems to be working quite well.
from copy import copy
# Decorator to memoize using the first argument only
@memoize_first
def prime_factors(n, prime_list=[None], prime_limit=[None]):
...