For given floating point numbers x and a, I would like to compute r (and n) such that x = a*n + r . In C/C++ this function is called fmod. However I do not see a convenient function in .NET. Math.DivRem is only for integers ...
...
How would I print the multiples of a list of given numbers in a merged, sorted list?
I.e.
take 10 (multiples [4,5])
gives
4,5,8,10,12,15,16,20,24,25
I've got it working for lists of size 2 or 1 but I need a more general solution :)
...
I was looking at this post, and it is close to what I need:
http://stackoverflow.com/questions/1669165/php-how-to-count-60-days-from-the-add-date
However, in that post, the calculation is performed by adding 60 days to the current date. What I need to do is calculate the date based on a variable date (and not the current date).
Someth...
I have two tables of concern here: users and race_weeks. User has many race_weeks, and race_week belongs to User. Therefore, user_id is a fk in the race_weeks table.
I need to perform some challenging math on fields in the race_weeks table in order to return users with the most all-time points.
Here are the fields that we need to m...
If you look at the top right you'll see on a radar an enemy unit line of sight.
I was wondering what is the most efficient or easiest way (little code, fairly accurate. doesnt need to be perfect) to detect if something is in your line of sight? I may or may not need to render it (i likely wont).
I dont know the formula nor used any mat...
Relating to this question i was wondering if .NET has any libs (or a function) i can use to detect if one point collides with another.
I am not sure what angles i should use but is there some function like this
func(point src, rect target, angle, distanceOfVision, listPointOrRectOfWalls)
Pretty unlikely but i dont know a formula or h...
Can anyone recommend some good starting points for understanding Transformation Matrices for dummies like me with poor math skills.
I'm willing to learn the math, and I'm not a complete idiot (I hope) but the examples I'm finding seem to require a huge leap from what I know, to what I need to know.
...
I want to switch from Java to a scripting language for the Math based modules in my app. This is due to the readability, and functional limitations of mathy Java.
For e.g, in Java I have this:
BigDecimal x = new BigDecimal("1.1");
BigDecimal y = new BigDecimal("1.1");
BigDecimal z = x.multiply(y.exp(new BigDecimal("2"));
As you can s...
Consider the set of non-decreasing surjective (onto) functions from (-inf,inf) to [0,1].
(Typical CDFs satisfy this property.)
In other words, for any real number x, 0 <= f(x) <= 1.
The logistic function is perhaps the most well-known example.
We are now given some constraints in the form of a list of x-values and for each x-value, a pa...
I've got a rather strange problem. For a Distributed Hash Table I need to be able to do some simple math operations on MD5 hashes. These include a sum (numeric sum represented by the hash) and a modulo operation. Now I'm wondering what the best way to implement these operations is.
I'm using hashlib to calculate the hashes, but since the...
Hello everyone.
I'm implementing the NTRUEncrypt algorithm, according to an NTRU tutorial, a polynomial f has an inverse g such that f*g=1 mod x, basically the polynomial multiplied by its inverse reduced modulo x gives 1. I get the concept but in an example they provide, a polynomial f = -1 + X + X^2 - X4 + X6 + X9 - X10 which we will ...
Hello,
NB: I'll present this question in degrees purely for simplicity, radians, degrees, different zero-bearing, the problem is essentially the same.
Does anyone have any ideas on the code behind rotational interpolation? Given a linear interpolation function: Lerp(from, to, amount), where amount is 0...1 which returns a value between ...
I can't solve it:
You are given 8 integers:
A, B, C representing a line on a plane with equation A*x + B*y = C
a, b, c representing another line
x, y representing a point on a plane
The two lines are not parallel therefore divide plane into 4 pieces.
Point (x, y) lies inside of one these pieces.
Problem:
Write a fast algorithm tha...
Hi,
Is there an efficient way to get the least non-negative residue modulo n, where n is positive, in C?
This is quite easy if the number is non-negative, then it's just a % n (where a is the non-negative integer).
However when a is negative, it appears the behaviour, in C89, is implementation defined (thanks kennyTM). I.e. -2 % 11 = ...
Hi,
I'm trying to implement the Solovoy-Strassen primality test for arbritrary large integers. I will also be writing a bignum (cannot use 3rd party implementation as this is an academic project). I have decided on the following structure for the bignum:
struct {
uint64_t *tab;
int size; // number of limbs
int sign;
}
I will be...
Hi, I know is a rather simple question but I just can't find an appropriate example in google or anywhere.
I've got this piece
int numberOfPlays = int.Parse(textBox2.Text);
numberOfPlays = (numberOfPlays++);
textBox2.Text = (numberOfPlays.ToString());
MessageBox.Show(numberOfPlays.ToString());
So basically what I want to do is to ge...
Hi,
I would like to populate an 2 dimensional array, from a vector.
I think the best way to explain myself is to put some examples (with a array of [3,5] length).
When vector is: [1, 0]
[
[4, 3, 2, 1, 0],
[4, 3, 2, 1, 0],
[4, 3, 2, 1, 0]
]
When vector is: [-1, 0]
[
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]
]
...
#include<stdio.h>
#include<math.h>
int main ()
{
FILE *fp;
fp=fopen("output","w");
float t,y=0,x=0,e=5,f=1,w=1;
for (t=0;t<10;t=t+0.01)
{
if( y==inf && y== nan)
break;
fprintf(fp,"%lf\t%lf\n",y,x);
y = y + ((e*(1 - x*x)*y) - x + f*cos(w*t))*t;
x = x + y*t;
}
return...
Hi. I'm trying to write a Matrix3x3 multiply using the Vector Floating Point on the iPhone, however i'm encountering some problems. This is my first attempt at writing any ARM assembly, so it could be a faily simple solution that i'm not seeing.
I've currently got a small application running using a maths library that i've written. I'm ...
I have a program that takes as input an array of lat/long points. I need to perform a check on that array to ensure that all of the points are within a certain radius. So, for example, the maximum radius I will allow is 100 miles. Given an array of lat/long (coming from a MySQL database, could be 10 points could be 10000) I need to fi...