Re: Optimizing a bigint fibonacci

2017-12-06 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 10:16:16 UTC, helxi wrote: On Wednesday, 6 December 2017 at 10:00:48 UTC, Biotronic wrote: AliasSeq!(a, b) = tuple( a * (2*b - a), a*a + b*b); [...] Nice. But why the AliasSeq? Just playing around a bit. The alternative is to

Re: Optimizing a bigint fibonacci

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:59:12 UTC, codephantom wrote: On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: This is question not directly related to language concepts, it's got more to do with the application. I would appreciate if anyone would point to me how I could optimize

Re: Optimizing a bigint fibonacci

2017-12-06 Thread helxi via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 10:00:48 UTC, Biotronic wrote: On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: [...] Here's my version:, based on fast squaring: auto fib(ulong n) { import std.bigint : BigInt; import std.meta : AliasSeq; import std.typecons : tuple;

Re: Optimizing a bigint fibonacci

2017-12-06 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: This is question not directly related to language concepts, it's got more to do with the application. I would appreciate if anyone would point to me how I could optimize this bit of code Here's my version:, based on fast squaring: au

Re: Optimizing a bigint fibonacci

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:12:08 UTC, helxi wrote: This is question not directly related to language concepts, it's got more to do with the application. I would appreciate if anyone would point to me how I could optimize this bit of code Compile it with ldc ;-)

Re: Optimizing a bigint fibonacci

2017-12-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 06, 2017 09:12:08 helxi via Digitalmars-d-learn wrote: > void main() > { > import std.stdio, std.datetime; > > auto t0 = Clock.currTime; > writeln(fib(100_000)); > writeln(Clock.currTime - t0); > } On a complete sidenote, if you want to correctly time stuff, you sho