Skip to content

Releases: oscbyspro/Numberick

v0.17.0

06 Dec 13:10
Compare
Choose a tag to compare

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 from 7 by skipping even numbers.
  • 2.2 from 3.6 by using [UInt] as a wannabe-bit-set.
  • 1.7 from 2.2 by wheeling 3, 5, 7.
  • 1.5 from 1.7 by using wrapping arithmetic in hotspot.
  • 0.9 from 1.5 by chunking it (wheeling has not been reimplemented yet).
  • 0.8 from 0.9 by reimplementing wheeling in increment().
  • 0.6 from 0.8 with NBKPrimeSieve(cache: .KiB(128), wheel: .x11, culls: .x31).
  • 0.58 from 0.64 by adding a capacity reservation option.

v0.16.0

12 Nov 11:06
Compare
Choose a tag to compare

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

29 Oct 10:50
Compare
Choose a tag to compare

Not much because I'm working on UIntXL (#33) at the moment.

GitHub (v0.14.0...v0.15.0)

  • #103 Camel case bitShift like bitWidth
  • #102 Slices no bounds
  • #100 Are bit rotations worth it? Nah

Changes

  • bitshift[ed] is now called bitShift[ed] like bitWidth
  • bitrotate[d] binary integer methods have been removed

v0.14.0

13 Oct 14:36
Compare
Choose a tag to compare

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

30 Sep 08:38
Compare
Choose a tag to compare

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 light integers.

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

17 Sep 06:58
Compare
Choose a tag to compare

Some minor things, code quality stuff.

I'm working on a big integer feature branch, that's why.

GitHub (v0.11.0...v0.12.0)

  • #80 No description defaults
  • #79 Miscellaneous v0.12.0
  • #78 Dynamic radix solution

v0.11.0

04 Sep 10:59
Compare
Choose a tag to compare

Three new models. Minus a model and a method. Plus CocoaPods?

GitHub (v0.10.0...v0.11.0)

  • #77 Use 0 rather than Int.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

26 Aug 13:46
Compare
Choose a tag to compare

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

17 Aug 08:14
Compare
Choose a tag to compare

GitHub (v0.8.0...v0.9.0)

  • #58 Lower min Swift version to 5.7
  • #51 Single digit multiplication with addition
  • #50 Rework sign and magnitude init
  • #49 Req. base 10 ASCII description
  • #48 Req. LosslessStringConvertible

v0.8.0

06 Aug 08:59
Compare
Choose a tag to compare

Some additions in preparation for big integers.

GitHub

  • #47 Req. nonzero bit width
  • #43 Req. additional bit counts
  • #34 Recoverable unsigned subtraction

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