|
Thanks for the responese however, after burning through the night and checking the code hundreds of time, I found the issue. It turned out that the number was being interpreted as a negative number by the BigInteger class. Once I added a 0 to the beginning of the prime number the code worked and matched up with all the test vector's outputs.
|
|
|
|
|
Makes sense, I should probably have thought of that
|
|
|
|
|
Hello,
I try to find some code related Robot voice but not success. Please give me some code to change voice to Robot voice.
About FFT, where I find FFT library for android?
Thanks!
Please help me to complete it.
|
|
|
|
|
FFTW[^] is in C, so you should be able to tie it into any platform easily.
As far as the robot voice deal...
|
|
|
|
|
He's looking for a phase vocoder.
|
|
|
|
|
So why are you telling me? ...maybe you should tell the OP.
|
|
|
|
|
Hi!
I've to print the index of a selected cell in a Table.
The table has eight rows and eight columns. The rows are labled from A to H and
the cloumns are labled from 1 to 8.
If I click the cell in the first row and first column I've to print A1.
Similarly If I click the cell in the first row and Second column I've to print B1
My function has to return the index of each and every cell in the table. How to code that
function in C++?
|
|
|
|
|
char rowLetter = 'A' + selectedCell.row;
int columnNumber = selectedCell.column + 1;
cout << rowLetter << columNumber << endl;
printf("%c%d\n", rowLetter, columNumber);
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am trying to do a problem of solid waste collection vehicle routing using Genetic algorithm in C++. So here raises the question why should I use GA. How do I defense this question? My main logic is solid waste collection problem is a non linear problem thats why for solving it I chose GA. So can it be like I can form a model to prove its non linearity? If its modeling is possible what things do I need to focus?
|
|
|
|
|
Need more detail on the routing problem to give a more detailed answer. But GAs are useful when combining parts of good solutions give you better solutions.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
My client is asking for a copy of the algorithm for his programme should I give it up or should I keep it?
|
|
|
|
|
Probably depends on the specific of the question.
For example if they wanted you to implement a back-pack solution and it was specifically phrased like that as part of the contract (via perhaps associated requirements) then it might be reasonable to document which one you chose but not provide how you implemented it.
However if you implemented a standard business application and there are no specific contractual (or implicitly contractual requirements because it wasn't explicit) and thus the customer thinks you should give then the source code - then no.
In general
1- Is there a specific contractual obligation
2- How significant is the algorithm in terms of the work product.
3- What is your business relationship with the client? So for example if you expect to get jobs from them for the next 10 years then you might want to give something up. But if you want to sell the product to 10 competitors to the client then probably not.
|
|
|
|
|
Thank you for your answer.1) There was no contractual obligation at the start of writing the source code, only after I had started was this asked for.
2)Without the algorithm the programe wouldn't work in anyway.3) first time I have worked for this client, he is proving most troublesome and I cannot see any need for me in the next ten years (although a memeber of his team is planning on jumping ship and maybe taking me with him).
|
|
|
|
|
I first noticed this when I was in high school. But I can't seem to find any references to it on the Internet, did I discover something previously unknown?
I'm sure the algorithm can be made more efficient using other rules for generating prime numbers, but I'm just curious if anyone has even seen this before, and who (if not me), first discovered this.
How I'm generate prime numbers...
1. 2 is not include
2. Insert 3 and 5 into the prime number set
3. The next prime number is 7 = 5 + 3 - 1
4. The next prime number is 11 = 7 + 5 - 1
5. The next prime number is 13 = 11 + 3 - 1
So (Next Prime) = (Last Prime) + (Some Smaller Prime) - 1
Here is some C# code, showing this...
void Test()
{
List<long> primeNumbers = new List<long>();
primeNumbers.Add(3);
primeNumbers.Add(5);
DateTime stopTime = DateTime.Now + new TimeSpan(0, 10, 0);
Console.Write("Calculating prime numbers...");
while (DateTime.Now < stopTime)
{
if (primeNumbers.Count % 100 == 0)
Console.Write(".");
primeNumbers.Add(GetNextPrime(primeNumbers));
}
Console.WriteLine("Calculated " + primeNumbers.Count + " prime numbers.");
Console.WriteLine("The largest being " + primeNumbers.Last() + ".");
}
long GetNextPrime(List<long> primeNumbers)
{
long lastPrime = primeNumbers.Last();
for (int i = 0; i < primeNumbers.Count - 1; i++)
{
long testValue = lastPrime + primeNumbers[i] - 1;
bool fail = false;
for (int j = 0; j < primeNumbers.Count - 1; j++)
{
if (testValue % primeNumbers[j] == 0)
{
fail = true;
break;
}
}
if (fail) continue;
return testValue;
}
throw new Exception("Rule failed");
}
|
|
|
|
|
There is no simple algorithm for generating prime numbers. For example, your method falls apart when you take the next step: 11 + 5 - 1 = 15, which isn't prime.
A foolproof (but slower) method is to try dividing a candidate by all the integers up to the square root of that number. If none can divide it evenly, it's prime.
Also look at: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes[^]
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Hello there,
Prime Number Generating Algorithm:
A Prime Sieve or Prime Number Sieve is defined to be a fast type of algorithm for finding prime numbers. There are quite a lot of prime sieves that can be found. So the question remains: which one should I implement?
First we must ask: exactly how does a Prime Sieve work? What does it do? Well, here's the answer! A prime sieve works by creating a list of all integers up to a what ever limit and then progressively removing numbers that are made up of multiple elements (composite)until only primes numbers remain. This is one of the most known the most efficient ways to obtain a large range of prime numbers.
Live Support Software for Busines
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:40am.
|
|
|
|
|
Hi
The catch with prime numbers is that to this day there's no algorithm that will find them all in any given interval without resorting to any form of trial and error or anyway without making any comparison against a set of pregress data.
Unbelievable as it sounds, that's the current truth.
Should you discover such an algorithm it'd earn you both a Nobel and a very fat place in hystory, hands down.
Keep trying and keep hoping ; )
|
|
|
|
|
In a CAD program, I want to find the (vector) entities that bound a given point.
1) Is a seed fill type algorithm the best choice for this? Or is there a quicker / better / more efficient method?
2) Once I've found my bounding entities, can I make my 'is the boundary contiguous' check fault tolerant to some degree? And what approach would be best? If my line ends aren't coincident, for instance, I could perhaps extended them be a certain tolerance to see if they 'almost cross'? (and then use the 'virtual' vertex in my bonding shape)
Cheers
|
|
|
|
|
A k-d tree ([^]) is good for nearest-neighbor and range searches.
It's like a standard binary search tree, except the discriminant (the value you use to decide on the left or right branches) alternates between the X and Y coordinates at each level.
So at each level, you can eliminate half the search space, depending on if the X or Y coordinates are beyond the point you're searching around. (If neither can be eliminated, you recursively search down both the left and right branches.)
Once you have the entities that are clustered around your point, you can check if they overlap to detect a contiguous entity path around the point.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
I have path which is in '*' (asterisk) shape. All the ends are the nodes such that there is 8nodes and one node in the center. I want to form an algorithm that could start the journey from one end and travel to all the other nodes.Can any one guide me through this. How should i proceed the coding?
|
|
|
|
|
There are many ways to do this. Probably the simplest is depth-first search, which visits each unvisited node connected to the current node, recursively.
To implement this, you need a Boolean "visited" member of the node structure, which is initially false in all nodes.
You call the search function with any node to start. The function then sets "visited" to true, and calls itself recursively with each of the node's unvisited neighbors. When it returns at the top level, you've visited all the nodes.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Hello,
Please put a picture of the shape that shows the nodes and paths (lines connecting the nodes) An asterisk has six points, not eight. Maybe you mean a star, then people need to know if you are including the inside corners.
|
|
|
|
|
Dear members,I am trying to do optimization of water supply network by using particle swarm optimization method,and I have the objective function but my problem is how I can use PSO in Matlab,I have tried to download some codes,but still is difficult for me to use it since I am new in optimization,please any help
|
|
|
|
|
I am trying to do problem in which i have numbers of points. Now i need to find the path that goes through all the points. This is not actually TSP because as per my knowledge in TSP it is possible to travel from all points to every other points. But in my case the path network is fixed and i just need to find the path that goes through all the points provided that all points may not have connection to every other point..so what algorithm am i supposed to follow.
|
|
|
|
|
Go ask our friends Google and Wikipedia about "spanning tree". That will get you started, and probably almost finished too.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|