oscbyspro / Numberick

An arithmagick overhaul in Swift
Apache License 2.0
15 stars 3 forks source link

[NBKPrimeSieve] Mini rework #118

Closed oscbyspro closed 12 months ago

oscbyspro commented 12 months ago

Smaller default sieve

I think the default was too large, so I'll lower it to 4 KiB from 32 KiB.

The new default sieves all primes <= 65535 on creation, i.e. the first 1900 primes.

Convenience init and failable main init

I'll add some culling options, which means that the main initializer must be allowed to fail. The reason being that the bit pattern cull must cull every values that are not on the wheel, meaning wheel <= culls. I'll add a parameterless init method that cannot fail because it picks all the defaults.

Time (s) to append primes up to 109 on a MacBook Pro, 13-inch, M1, 2020:

0.56 from 0.58 by using unsafe buffer pointers in hotspot.

0.52 from 0.56 by increasing the culls to x67 from x31.

oscbyspro commented 12 months ago

Apparently [UInt8].SubSequence is not a valid type on Linux :expressionless: