suppose I want to calculate average value of a data-set such as
class Averager {
float total;
size_t count;
float addData (float value) {
this->total += value;
return this->total / ++this->count;
}
}
sooner or later the total or count value will overflow, so I make it doesn't remember the total value by :
cl...
Hi,
after profiling a lot I found out that this method takes up most of the % of calculation time. I don't really see a way to optimize, since it is a horrible function. (it is...)
Maybe someone can show me some nice idea or so?
public static double perceivedLoudness(double L_G, double L_ETQ, double a0) {
double t1 = 1d + 1 / 4d * Ma...
I want to use math functions for data mining and analytics purpose.
I need an opinion about a library that I can use for this purpose with java.
Do you have any recommendations?
...
According to wiki shifts can be used to calculate powers of 2:
A left arithmetic shift by n is
equivalent to multiplying by 2^n
(provided the value does not
overflow), while a right arithmetic
shift by n of a two's complement value
is equivalent to dividing by 2^n and
rounding toward negative infinity.
I was always wond...
Below, the result1 and result2 variable values are reporting different values depending upon whether or not
you compile the code with -g or with -O on GCC 4.2.1 and on GCC 3.2.0 (and I have not tried more recent GCC versions):
double double_identity(double in_double)
{
return in_double;
}
...
double result1 = ceil(log(32.0) / log(...
I bought a blank DVD to record my favorite TV show. It came with 20 digit stickers. 2 of each of '0'-'9'.
I thought it would be a good idea to numerically label my new DVD collection. I taped the '1' sticker on my first recorded DVD and put the 19 leftover stickers in a drawer.
The next day I bought another blank DVD (receiving 20 new st...
A continued fraction is a series of divisions of this kind:
depth 1 1+1/s
depth 2 1+1/(1+1/s)
depth 3 1+1/(1+1/(1+1/s))
. . .
. . .
. . .
The depth is an integer, but s is a floating point number.
What would be an optimal algorithm (performance-wise) to calculate th...
What is the opposite of the Math.tan(double x) function of java?
I know that Tan(X) = oppositeSideLength/AdjacentSideLength
but I have the opposite and adjacent sides so I want to do the opposite operation.
ie: x = Tan^-1(oppositeSideLenght/AdjacentSideLength) (that is how I would enter it in a calculator.
I just looked in the...
I'm playing around with code like this:
<s:Button id="test" label="test" transformX="{Math.floor(test.width/2)}" rotationY="20" x="20" y="20" />
The button is rotated on the Y axis and the rotate pivot is in the middle of the button.
This will create a button that looks something like this:
The rotated button is, visually, filling...
Hi,
I want to compute the moment of inertia of a (2D) concave polygon. I found this on the internet. But I'm not very sure how to interpret the formula...
1) Is this formula correct?
2) If so, is my convertion to C++ correct?
float sum (0);
for (int i = 0; i < N; i++) // N = number of vertices
{
int j = (i + 1) % N;
sum += (...
I read over the wikipedia article, but it seems to be beyond my comprehension. It says it's for optimization, but how is it different than any other method for optimizing things?
An answer that introduces me to linear programming so I can begin diving into some less beginner-accessible material would be most helpful.
...
I have the following code:
typedef __int64 BIG_INT;
typedef double CUT_TYPE;
#define CUT_IT(amount, percent) (amount * percent)
void main()
{
CUT_TYPE cut_percent = 1;
BIG_INT bintOriginal = 0x1FFFFFFFFFFFFFF;
BIG_INT bintAfter = CUT_IT(bintOriginal, cut_percent);
}
bintAfter's value after the calculation is 14411518807...
I'm working on opengl project.
I set up perspective projection and render a transformed rectangle (rotated, scaled)
How i can calculate rectangle's bounding box (rectangle position,size)
Thank you
...
Hey Guys,
I'm confusing myself terribly grasping the concept of plotting on a 3D plane, if I'm looking down the -Z axis, to put an objectinfront of me I just make the Z value Negative and to put it behind I just make it positive.. but.. how do I Put objects to my left or right? Sorry, I realise this is a stupid question but none the les...
How to calculate the Modular Multiplicative inverse of a number in the context of RSA encryption?
...
Okay, so maths isn't my strong point!
I have this data, I i used zunzun.com to create a User Defined Polynomial curve for my data, which came out as y = a + bx1 + cx2 + dx3 + ex4 + fx5
However, when I use the code suggested:
double a = -4.2294409347240979E+01;
double b = 5.5946102161174718E+00;
double c = -1.3446057748924720E-0...
given
d0=0
d1=5+3d0
d2=5+3d1
...
dn=5+3dn-1
how would I write the summation for this up to n?
...
How do I calculate the intersection points of two circles. I would expect there to be either two, one or no intersection points in all cases.
I have the x and y coordinates of the centre-point, and the radius for each circle.
An answer in python would be preferred, but any working algorithm would be acceptable.
...
Hello,
Before I start thanking everybody.
Through my application s/w I will read syncro values which will be in angles.
When I run Python script, the values are collected in particular variables.
Suppose the range is -180 to 180.
And I got angle as -180. According to the requirement it should be +/-1 deg window;ie; between 179 and -1...
I have question that comes from a algorithms book I'm reading and I am stumped on how to solve it (it's been a long time since I've done log or exponent math). The problem is as follows:
Suppose we are comparing implementations of insertion sort and merge sort on the same
machine. For inputs of size n, insertion sort runs in 8n^2 steps,...