Releases: arrayfire/arrayfire-haskell
0.8.0.0
[🔥] 0.8.0.0
Version 0.8 significantly expands the API with new BLAS, LAPACK, and Algorithm functions including gemm, eigSH, pinverse, and nine segmented by-key reductions, along with ergonomic indexing via the (!) and (.~) infix operators. Scalar-returning functions (meanAll, varAll, stdevAll, corrCoef, det, etc.) now return a precise Scalar a type via the new AFResult typeclass rather than an untyped (Double, Double) pair, and several other return types have been corrected throughout (CBool for boolean ops, Word32 for index arrays, Complex a for complex construction). A number of long-standing bugs are fixed: signum for unsigned types and IEEE 754 negative zero, a double-free in getDefaultRandomEngine, uninitialized FFI output slots (replaced by zero-init calloca), and incorrect Eq behaviour for arrays with mismatched shapes. Test coverage has been substantially expanded with property-based tests for BLAS/LAPACK algebraic laws, Moore–Penrose conditions, eigendecomposition correctness, semiring/ring laws via QuickCheck.Classes, exception FFI propagation, and a complete IndexSpec. On the build side, the Nix flake gains CUDA and darwin (x86_64 via Rosetta 2) support, and CI now uses ners/simply-nix with automatic Haddock deployment to GitHub Pages.
BLAS
gemm— general matrix multiply (α·op(A)·op(B) + β·C) with scalar scaling and in-place accumulation
LAPACK
eigSH— symmetric/Hermitian eigendecomposition (cuSOLVER on CUDA, Jacobi fallback on CPU/OpenCL)pinverse— Moore–Penrose pseudoinverse
Algorithm
sumByKey,sumByKeyNaN,productByKey,productByKeyNaN,minByKey,maxByKey,allTrueByKey,anyTrueByKey,countByKey— segmented (key-value) reductions
Statistics
meanVar,meanVarWeighted— mean and variance in a single passvarAll/varAllWeightednow takeVarianceTypeinstead ofBool
Data / Array
fromVector— zero-copyStorable Vector → ArrayingestionbitNot— bitwise complementeval— explicitly flush the ArrayFire JIT queuedeviceGC— trigger device-side garbage collection (af_device_gc)inverseDeconv— inverse deconvolution (Image module)
Index
assignSeq— write a source array into a sequential slice of a destinationindexGen— generalised indexing by a list ofIndexvaluesassignGen— generalised slice assignment(!)— infix indexing operator (arr ! at 0,arr ! range 1 3,arr ! (range 0 2, at 1));infixl 9(.~)— infix lens-style slice assignment (arr & range 1 3 .~ src);infixr 4spanrenamed toafSpan(avoids shadowingPrelude.span)
Breaking / type changes
meanAll,meanAllWeighted,varAll,varAllWeighted,stdevAll,medianAll,corrCoef,det— returnScalar a(via newAFResulttypeclass) instead of(Double, Double)sort,sortIndex,sortByKey— takeOrder(Asc | Desc) instead ofBoolimin,imax,sortIndex,topk— index output corrected toArray Word32(wasArray a)isZero,isInf,isNaN,allTrue,anyTrue— returnArray CBool(wasArray a)where'— returnsArray Word32(wasArray a)cplx,cplx2,cplx2Batched— returnArray (Complex a)(wasArray a)real,imag— signature tightened toArray (Complex a) -> Array abitAnd,bitOr,bitXor,bitShiftL,bitShiftR— returnArray a(wasArray CBool)gemm—betaparameter removed (was silently a no-op; zero-filled internally)countByKey/allTrueByKey/anyTrueByKey— output value type corrected toWord32/CBoolIndextype — phantom type parameter removed; simpler unparameterised sum type
Bug fixes
signum— fixed for unsigned types (was wrapping vianegate) and IEEE 754 negative zero; now usescast(gt x 0) - cast(lt x 0)afBackendCpu— was incorrectly bound toAF_BACKEND_DEFAULTtoConnectivity—AFConnectivity 8was mapped toConn4instead ofConn8histogram— removed spurious double-cast aroundaf_histogramgetDefaultRandomEngine— fixed double-free (missingaf_retain_random_enginebefore finalizer)Eq (Array a)— checks dimensions first beforeallTrueAll(broadcast was producing wrong results for mismatched shapes)- FFI output slots — all
allocaoutput pointers zero-initialised viacalloca(was reading uninitialised stack for real-valued arrays) pi— usesrealToFrac (Prelude.pi :: Double)instead of a truncated literal
FFI / internals
AFResulttypeclass with associatedScalar atype family: real/integral instances yieldDouble, complex instances yieldComplex Double; used to give scalar-returning functions (meanAll,varAll,stdevAll,medianAll,corrCoef,det, etc.) precise return types instead of the untyped(Double, Double)paircallocaadded — zero-initialised stack allocation replacing the oldzeroOutArrayC helper (which is removed)- All
op*helpers inFFI.hsnow wrapunsafePerformIOwithmask_to prevent segfaults from async exceptions during FFI calls op1generalised toArray a -> … -> Array b(removing the redundantop1d)op2pgeneralised to(Array a, Array b)(was(Array a, Array a))- New
op2p2kvhelper for key-value two-output FFI calling convention VarBiastype introduced (VarianceDefault | VarianceSample | VariancePopulation) backed byAFVarBiasinInternal/Defines.hsc
Tests
- Comprehensive
IndexSpeccoveringindex,afSpan,lookup,assignSeq,indexGen,assignGen,(!),(.~),rangeStep, and indexing round-trip properties AlgorithmSpec: all*ByKeysegmented reduction functionsBLASSpec:gemm(identity, alpha-scaling, transpose); matmul/transpose/dot algebraic propertiesLAPACKSpec: QR/SVD/Cholesky reconstruction;eigSHeigenvalue ordering, eigenvector orthonormality, matrix reconstruction;pinverseMoore–Penrose conditionsStatisticsSpec:meanVar(population and sample);meanVarWeightedNumericalSpec: power-iteration eigenvalue convergenceArithSpec/ArraySpec:bitNot,cplx/real/imaground-trips,signumfor unsigned and float-zero edge casesExceptionSpec:AFExceptionFFI boundary propagation;toAFExceptionTypefor all documentedAFErrcodes- Random: fixed-seed reproducibility, distinct-seed divergence, distribution shape/range
- Semiring/Ring laws via
QuickCheck.Classesfor scalar and array instances; test suite fails iflawsCheckfails
CI / build
- Nix flake: CUDA backend support (
cudatoolkit,nvidia_x11,allowUnfree) - Nix flake: darwin (x86_64 via Rosetta 2) build and
devShellsupport - CI: switched from
cachix/install-nix-actiontoners/simply-nix@mainwithreclaim_space: true - CI: Haddock docs published to GitHub Pages on push to
master - Switched from
hspectohspec-discover
What's Changed
- Add nix build to CI by @dmjio in #67
- Add darwin build and dev support. by @dmjio in #69
- Expand API: BLAS, reductions, statistics, index ops, bitwise; type & FFI fixes by @dmjio in #68
Full Changelog: 0.7.1.0...0.8.0.0
0.7.1.0
What's Changed
- Fix tests for ArrayFire 3.8.3 by @twesterhout in #51
- Switch to Nix flakes; make the tests pass with newest ArrayFire by @twesterhout in #55
- Fix joinMany by @twesterhout in #56
- Fix (**) and use property tests for Floating by @twesterhout in #57
- Relax some tests that are satisfied only up to some floating point error. by @leftaroundabout in #59
- Export the special
spanvalue for not-indexing an array dimension. by @leftaroundabout in #61 - Correct
signumfunction according to the Haskell report. by @leftaroundabout in #60 - Adjust lookup function to use
Intindices by @dmjio in #63 - Add CI. Generalize
op2type parameter. by @dmjio in #64
New Contributors
- @leftaroundabout made their first contribution in #59
Full Changelog: 0.7.0.0...0.7.1.0
0.7.0.0
- Use latest GHC (
9.2.2/9.4.2) - Use latest arrayfire (
3.8.2) - Fix tests for
productandvariancefunctions - Update various scripts (
nix,.ghci, etc.)