Can this implementation of Damm algorithm be optimized?
Era Scarecrow via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 11 17:10:02 PST 2017
On Sunday, 12 February 2017 at 00:43:55 UTC, Nestor wrote:
> I fail to see where you are declaring QG10Matrix2, because
> apparently it's an array of chars, but buildMatrix2 returns an
> array of int (2560 elements??) with lots of -1 values.
I declared it here:
http://forum.dlang.org/post/fiamjuhiddbzwvaplxkr@forum.dlang.org
and it's not chars, it's ints. Part of it is to avoid the mem
access penalty for non divisible by 4 addresses, and another is
that the array returns not chars, but numbers from 0-2560, which
is the answer *256 (<<8), which offers hopefully some slight
speed gain on longer inputs.
Also the size of the array is guesstimated, and the -1's just
signify the padding (which can be any value, but -1 makes it
obvious). Since it's a 10x10 array it's based on, but using 4bits
per section, there's 6 elements lost, and 6 whole rows lost. It's
a necessary loss to gain speed; Thankfully it's only using 10k
(2560 members) and not 700k as was my original guess when i was
calculating it wrong earlier.
Doing it wrong earlier, the compiler kept crashing... :P running
out of memory.
More information about the Digitalmars-d-learn
mailing list