Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 5th, 2013, 04:32 PM
 ballsystemlord
Contributing User

Join Date: Apr 2013
Posts: 41
Time spent in forums: 5 h 56 m
Reputation Power: 1
On implimenting a subsitution algorithm efficently

I've created a algoithm to reicive a number and out put 2 different numbers. I can think of no mathmatical way to impiment it so I decided that I'd have to use either a switch statement or a indexed array. I implimented a very much simplified version of this array using short (16bit) ints and larger long long ints (64 bit). The amount of calculations for the int 64 was 4 times the amount of the int 16. I then compiled them thinking that the int 64 would out strip the int 16 because of the SIMD extentions provided by me proccessor. In reallity, however, the int 16 worked 16% faster then the int 64 (weven though I told the comlier to not use SIMD extentions on it.) Both of them were compiled without optimization. Now if I were to impliment the full substitution algorithm I would be using a collosel amount of ram.

So, does anybody know of a quick and ram effecient way of implimenting a substitution algorithim. I can use any size of int I please; I am not sure which size would be best.

PS: The amount of ram nessesary is easy to calculate just take the int size, lets say 16, and multiply (2**int-size)*2. That's why I need a better way of implimenting this.

#2
June 6th, 2013, 02:13 AM
 Lux Perpetua
Contributing User

Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,939
Time spent in forums: 1 Month 1 Week 3 h 27 m 29 sec
Reputation Power: 1312
I read your post twice, and I still don't know what you're trying to do. That said:
Quote:
 Originally Posted by ballsystemlord PS: The amount of ram nessesary is easy to calculate just take the int size, lets say 16, and multiply (2**int-size)*2. That's why I need a better way of implimenting this.
This would pretty severely limit your int size. In particular, 64 would be pretty much out of the question.

#3
June 10th, 2013, 11:42 AM
 ballsystemlord
Contributing User

Join Date: Apr 2013
Posts: 41
Time spent in forums: 5 h 56 m
Reputation Power: 1
Quote:
 Originally Posted by Lux Perpetua I read your post twice, and I still don't know what you're trying to do. That said: This would pretty severely limit your int size. In particular, 64 would be pretty much out of the question.

Yes, that's why I need a better idea.

I can't find to much in the way of patterns in the substitution algorithm.

Here's a simple but applicable example:
I create a code it turns all "100"s to "001"s and all "200" to "300"s.
Now first off, is the fact that I would have to for each number create a switch statement with an ont put and input value. I could of course use an array instead but I would still have to manually type in assignments for each number.
Second is the size of the resualting array/switch statements (as is clearly visible from the above calculation I gave you.)

I'm trying to find a more efficent way of doing this and I figured that other people had done similer so I might learn from them.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > On implimenting a subsitution algorithm efficently