Releases: oscbyspro/Numberick
v0.17.0
Added a prime sieve to NBKCoreKit.
GitHub (v0.16.0...v0.17.0)
- #114 A prime sieve
NBKPrimeSieve
public final class NBKPrimeSieve {
/// Creates a new instance and sieves the first page.
public init(cache: Cache = .KiB(32), wheel: Wheel = .x07, culls: Culls = .x11, capacity: Int? = nil)
/// The highest value checked for primality.
public var limit: UInt { get }
/// A list of all primes from zero through `limit`.
public var elements: [UInt] { get }
/// Sieves the next page of numbers.
public func increment()
}
NBKPrimeSieve: Changelog
Time (s) to append primes up to 109 on a MacBook Pro, 13-inch, M1, 2020:
3.6
from7
by skipping even numbers.2.2
from3.6
by using [UInt] as a wannabe-bit-set.1.7
from2.2
by wheeling 3, 5, 7.1.5
from1.7
by using wrapping arithmetic in hotspot.0.9
from1.5
by chunking it (wheeling has not been reimplemented yet).0.8
from0.9
by reimplementing wheeling in increment().0.6
from0.8
with NBKPrimeSieve(cache: .KiB(128), wheel: .x11, culls: .x31).0.58
from0.64
by adding a capacity reservation option.
v0.16.0
I'm working on UIntXL (#33), but I fixed a crash – so here's an update.
GitHub (v0.15.0...v0.16.0)
- #112 No
#if DEBUG
unit testing - #111 Crash in radix
3
integer description - #109 Big integer Fibonacci sequence
- #108 Big integer Karatsuba algorithm
- #107 Req.
init?(magnitude:)
- #106 Req. static binary integer
one
Changes
+ init?(magnitude:)
+ static var one: Self { get }
v0.15.0
Not much because I'm working on UIntXL (#33) at the moment.
GitHub (v0.14.0...v0.15.0)
Changes
bitshift[ed]
is now calledbitShift[ed]
likebitWidth
bitrotate[d]
binary integer methods have been removed
v0.14.0
Fixed a bug and reduced the number of unchecked values.
GitHub (v0.13.0...v0.14.0)
- #101 Crash in DoubleWidth
- #99 Experimental predicate wrappers
- #98 Experimental predicate wrappers
- #96 No vanilla protocol extensions (there's one)
New in NBKCoreKit
- func Swift.BinaryInteger/description(radix: Int, uppercase: Bool) -> String
+ func Numberick.NBKCoreInteger/description(radix: Int, uppercase: Bool) -> String
New in NBKDoubleWidthKit
⚠️ Fixed a division bug that was reported by LiarPrincess.
v0.13.0
GitHub (v0.12.0...v0.13.0)
- #95 StaticString decoding zero fix
- #94 StaticBigInt collection
- #89 Req. init?(words:) method
- #88 Make TwinHeaded private
- #86 Text de/encoding abstraction
- #85 Many algorithms, few namespaces?
- #84 Labels: major/minor instead of words/bits
New in NBKCoreKit
+ struct NBKStaticBigInt
- struct NBKTwinHeaded<Base>
Let there be
lightintegers.
init?(words: some RandomAccessCollection<UInt>)
init?(words: some RandomAccessCollection<UInt>, isSigned: Bool)
New in NBKDoubleWidthKit
func bitshift[ed][direction](major:minor:) // from bitshift[ed][direction](words:bits:)
func bitrotate[d][direction](major:minor:) // from bitrotate[d][direction](words:bits:)
v0.12.0
v0.11.0
Three new models. Minus a model and a method. Plus CocoaPods?
GitHub (v0.10.0...v0.11.0)
- #77 Use
0
rather thanInt.zero
- #74 An endianness abstraction
- #75 No
uninitialized(_:)
- #73 A chunked integer sequence
- #72 Endianness sensitive collection
v2
- #52 CocoaPods support (feat. ypopovych)
New in NBKCoreKit
+ enum NBKEndianness
+ struct NBKTwinHeaded<Base>
+ struct NBKChunkedInt<Base, Element>
- struct NBKLittleEndianOrdered<Base>
Reforge integers like a level 100 blacksmith.
for uint32 in NBKChunkedInt(source, isSigned: false, count: nil, as: UInt32.self) { ... }
[1, 2, 3, 4] == Array(NBKChunkedInt(([0x0201, 0x0403] as [Int16]), as: UInt8.self))
[2, 1, 4, 3] == Array(NBKChunkedInt(([0x0201, 0x0403] as [Int16]).reversed(), as: UInt8.self).reversed())
[3, 4, 1, 2] == Array(NBKChunkedInt(([0x0201, 0x0403] as [Int16]).reversed(), as: UInt8.self))
[4, 3, 2, 1] == Array(NBKChunkedInt(([0x0201, 0x0403] as [Int16]), as: UInt8.self).reversed())
[0x0201, 0x0403] == Array(NBKChunkedInt(([1, 2, 3, 4] as [UInt8]), as: Int16.self))
[0x0102, 0x0304] == Array(NBKChunkedInt(([1, 2, 3, 4] as [UInt8]).reversed(), as: Int16.self).reversed())
[0x0403, 0x0201] == Array(NBKChunkedInt(([1, 2, 3, 4] as [UInt8]), as: Int16.self).reversed())
[0x0304, 0x0102] == Array(NBKChunkedInt(([1, 2, 3, 4] as [UInt8]).reversed(), as: Int16.self))
Or flex on your friends with dynamic directions.
NBKTwinHeaded(elements, reversed: Bool.random())
New in NBKDoubleWidthKit
- NBKDoubleWidth.uninitialized(_:)
v0.10.0
Lowered platform requirements and improved memory-safety.
GitHub (v0.9.0...v0.10.0)
- #71 Endianness sensitive collection
- #70 Remove static indices
- #68 Lower platform requirements
- #67 Rework
uninitialized(_:)
- #65 [U]Int until StaticBigInt
- #62 StaticString until StaticBigInt
New in Numberick
.iOS(.v14), // from 16.4
.macCatalyst(.v14), // from 16.4
.macOS(.v11), // from 13.3
.tvOS(.v14), // from 16.4
.watchOS(.v7), // from 9.4
New in NBKCoreKit
You don't want to know how difficult it was to come up with a decent alternative to initialized junk.
/// A collection that iterates forwards or backwards depending on the platform.
///
/// It iterates front-to-back on little-endian platforms, and back-to-front otherwise.
///
/// ```swift
/// let value = Int256.uninitialized { words in
/// for index in words.indices {
/// words.base.initializeElement(at: words.baseIndex(index), to: UInt.zero)
/// }
/// }
/// ```
///
public struct NBKLittleEndianOrdered<Base>: RandomAccessCollection where Base: RandomAccessCollection { }
New in NBKDoubleWidthKit
New (default) literal types because StaticBigInt does not back-deploy.
+ literal: Digit (by default)
+ literal: StaticString (by default)
- literal: StaticBigInt (by default)
It was made clear on the Swift forums that you may not access uninitialized memory (see: comment).
- public static func uninitialized(_ body: (inout Self) -> Void) -> Self {
+ public static func uninitialized(_ body: (NBKLittleEndianOrdered<UnsafeMutableBufferPointer<UInt>>) -> Void) -> Self
v0.9.0
v0.8.0
Some additions in preparation for big integers.
GitHub
New NBKBinaryInteger APIs
bitWidth >= 1
var nonzeroBitCount: Int { get }
var leadingZeroBitCount: Int { get }
var mostSignificantBit: Bool { get }
New NBKUnsignedInteger APIs
func subtractingReportingOverflow(_ other: Self) -> PVO<Self>
mutating func subtractReportingOverflow(_ other: Self) -> Bool
func subtractingReportingOverflow(_ other: Digit) -> PVO<Self>
mutating func subtractReportingOverflow(_ other: Digit) -> Bool