Repository navigation
1.0.0 is a breaking release. It makes Matrix a value type, fixes several results that
did not match their documentation, adds input checks, and moves the package to current
Apple platforms and Swift Package Manager only.
Added
**and.**power operators with exponentiation precedence (tighter than*).eigreturns complex eigenvalues and right eigenvectors; neweigvals.rank(_:tol:)through the SVD, with NumPy's default tolerance.uniquefor vectors and for matrix rows or columns.isApproximatelyEqualforDouble,VectorandMatrix(default absolute tolerance 1e-14, relative 0).seed:parameter onrandandrandn.std(_:normalization:)with.sample(default) and.population.- DocC documentation, published on GitHub Pages, and a Swift Package Index config.
- Contributing guide, code of conduct, security policy and issue and pull request templates.
Changed
Matrixis astruct:Sendable,Hashable, with exact==.convolveis true 2-D convolution, matchingconv2(A, K, 'same').stduses the sample deviation (N − 1) by default.normalizestill divides by the population deviation.thrsets values below the threshold to 0, as documented.gsvduses LAPACK'sdggsvd3, andUis m × m as LAPACK defines it.- Column statistics and column reads and writes use strided vDSP calls instead of transposing.
- Minimum platforms: macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4, visionOS 1.0. Swift 6 language mode, tools 6.2.
- Tests use Swift Testing. CI runs on GitHub Actions: build, tests, AddressSanitizer and coverage on macOS, and build-only jobs for iOS, tvOS, watchOS and visionOS.
Deprecated
^and.^. Use**and.**.
Fixed
normalize(_:.Column)returned the wrong shape.- Slicing with ranges resolved them against the wrong axis, and
Take/Dropat full size, zero steps and slice bounds were wrong. trioverflowed a heap buffer.a - B(scalar minus vector or matrix) anddetno longer return-0for zero results.- Many functions now check their inputs with
preconditioninstead of reading or writing out of bounds.
Removed
- The tolerance-based
==,<and>overloads on[Double], andComparableonMatrix. - CocoaPods, Carthage, jazzy and the generated Xcode project. Swift Package Manager is the only way to install.
- Quick and Nimble test dependencies.
Migrating from 0.3
- Update your platforms. Raise your deployment targets to macOS 13.3, iOS 16.4, tvOS 16.4,
watchOS 9.4 or visionOS 1.0, and build with Xcode 26 or later. - Install with Swift Package Manager. CocoaPods and Carthage are gone:
.package(url: "https://github.com/AlexanderTar/LASwift.git", from: "1.0.0"). Matrixis a value type. Assigning a matrix copies it. Code that relied on two
variables sharing one matrix, or on a function mutating its argument, must now return and
assign the result.Matrix(M)still makes a copy and is no longer needed for that.flat
is read-only from outside the module. Empty matrices cannot be built: dimensions must be positive.- Equality is exact.
==onMatrixcompares every element exactly, andMatrixis
Hashable. The tolerance-based==,<and>on[Double]and theComparable
conformance ofMatrixare gone. Replacea == bwhere you wanted a tolerance with
isApproximatelyEqual(a, b), and passabsoluteTolerance:orrelativeTolerance:when the default
is too tight. - Powers.
^and.^still compile but warn. Switch to**and.**: they have
exponentiation precedence, soA * B ** 2meansA * (B ** 2). With^, the same
expression parsed as(A * B) ^ 2. eigreturns four matrices. It now returns(V, D, Vi, Di): real and imaginary parts
of the eigenvectors and of the eigenvalues, with right eigenvectors in the columns ofV
andVi. For a matrix with real eigenvalues,ViandDiare zero. Useeigvalswhen you
only need the eigenvalues.convolveis a true convolution. The kernel is flipped, as inconv2(A, K, 'same').
0.3 cross-correlated and zeroed the border elements; now the border is computed too. Flip
your kernel if you relied on correlation. The kernel must have odd dimensions and be
smaller than the matrix.thrzeroes below the threshold. It used to set them tot(onlyt = 0gave
the same result);x.map { Swift.max($0, t) }(for a matrix,map(A) { Swift.max($0, t) })
reproduces the old behaviour.stdis the sample deviation. It divides by N − 1 by default. Pass
normalization: .populationfor the old result.normalize(_:.Column)keeps the matrix shape.randandrandntake an optionalseed:. Pass a seed for reproducible values.- New checks. Mismatched dimensions, empty inputs, out-of-range indices and bad slice
bounds now stop with apreconditionfailure instead of reading or writing out of bounds.
Code that worked by accident may crash now. gsvd.Uis m × m, as LAPACK defines it.- New functions.
rankanduniqueare available. If you defined your own, rename it or
remove it.