Very small changes
Considering ways to take the algorithm and turn it into OpenCL/Boost::Compute functions/code which would offer a large speed increase. Also, if I can figure out how to start from any arbitrary digit (which is supposed to be possible) then multi-threading would also give great speedups.
This commit is contained in:
parent
7b3fc5cdf8
commit
ec2a96b0ad
2 changed files with 14 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
cfg/
|
||||
*.txt
|
||||
main
|
||||
.gdb_history
|
||||
|
|
13
Spigot.cpp
13
Spigot.cpp
|
@ -15,6 +15,12 @@ void Spigot::pump(void) {
|
|||
int tempPreDigit = 0;
|
||||
int j = this->spigotListLength - 1;
|
||||
int i = j;
|
||||
|
||||
/*
|
||||
* This could be handled using boost::compute
|
||||
* with a BOOST_COMPUTE_FUNCTION that just
|
||||
* multiplies every item by 10.
|
||||
*/
|
||||
while(i >= 0) {
|
||||
this->spigotList[i] *= 10;
|
||||
i--;
|
||||
|
@ -22,6 +28,13 @@ void Spigot::pump(void) {
|
|||
this->carry = 0;
|
||||
i = j;
|
||||
// note this does *not* handle the i=0 case
|
||||
/*
|
||||
* This might also be able to be sped up
|
||||
* with OpenCL/boost::compute by creating
|
||||
* another custom function, but because
|
||||
* the carry has to be passed along this might
|
||||
* not work well
|
||||
*/
|
||||
while(i > 0) {
|
||||
this->spigotList[i] += this->carry;
|
||||
this->carry = (this->spigotList[i] / (i * 2 + 1)) * i;
|
||||
|
|
Loading…
Reference in a new issue