Skip to content

Releases: arrayfire/arrayfire-haskell

0.8.0.0

11 Jun 18:20
aa5aa84

Choose a tag to compare

[🔥] 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 pass
  • varAll / varAllWeighted now take VarianceType instead of Bool

Data / Array

  • fromVector — zero-copy Storable Vector → Array ingestion
  • bitNot — bitwise complement
  • eval — explicitly flush the ArrayFire JIT queue
  • deviceGC — 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 destination
  • indexGen — generalised indexing by a list of Index values
  • assignGen — 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 4
  • span renamed to afSpan (avoids shadowing Prelude.span)

Breaking / type changes

  • meanAll, meanAllWeighted, varAll, varAllWeighted, stdevAll, medianAll, corrCoef, det — return Scalar a (via new AFResult typeclass) instead of (Double, Double)
  • sort, sortIndex, sortByKey — take Order (Asc | Desc) instead of Bool
  • imin, imax, sortIndex, topk — index output corrected to Array Word32 (was Array a)
  • isZero, isInf, isNaN, allTrue, anyTrue — return Array CBool (was Array a)
  • where' — returns Array Word32 (was Array a)
  • cplx, cplx2, cplx2Batched — return Array (Complex a) (was Array a)
  • real, imag — signature tightened to Array (Complex a) -> Array a
  • bitAnd, bitOr, bitXor, bitShiftL, bitShiftR — return Array a (was Array CBool)
  • gemmbeta parameter removed (was silently a no-op; zero-filled internally)
  • countByKey / allTrueByKey / anyTrueByKey — output value type corrected to Word32 / CBool
  • Index type — phantom type parameter removed; simpler unparameterised sum type

Bug fixes

  • signum — fixed for unsigned types (was wrapping via negate) and IEEE 754 negative zero; now uses cast(gt x 0) - cast(lt x 0)
  • afBackendCpu — was incorrectly bound to AF_BACKEND_DEFAULT
  • toConnectivityAFConnectivity 8 was mapped to Conn4 instead of Conn8
  • histogram — removed spurious double-cast around af_histogram
  • getDefaultRandomEngine — fixed double-free (missing af_retain_random_engine before finalizer)
  • Eq (Array a) — checks dimensions first before allTrueAll (broadcast was producing wrong results for mismatched shapes)
  • FFI output slots — all alloca output pointers zero-initialised via calloca (was reading uninitialised stack for real-valued arrays)
  • pi — uses realToFrac (Prelude.pi :: Double) instead of a truncated literal

FFI / internals

  • AFResult typeclass with associated Scalar a type family: real/integral instances yield Double, complex instances yield Complex Double; used to give scalar-returning functions (meanAll, varAll, stdevAll, medianAll, corrCoef, det, etc.) precise return types instead of the untyped (Double, Double) pair
  • calloca added — zero-initialised stack allocation replacing the old zeroOutArray C helper (which is removed)
  • All op* helpers in FFI.hs now wrap unsafePerformIO with mask_ to prevent segfaults from async exceptions during FFI calls
  • op1 generalised to Array a -> … -> Array b (removing the redundant op1d)
  • op2p generalised to (Array a, Array b) (was (Array a, Array a))
  • New op2p2kv helper for key-value two-output FFI calling convention
  • VarBias type introduced (VarianceDefault | VarianceSample | VariancePopulation) backed by AFVarBias in Internal/Defines.hsc

Tests

  • Comprehensive IndexSpec covering index, afSpan, lookup, assignSeq, indexGen, assignGen, (!), (.~), rangeStep, and indexing round-trip properties
  • AlgorithmSpec: all *ByKey segmented reduction functions
  • BLASSpec: gemm (identity, alpha-scaling, transpose); matmul/transpose/dot algebraic properties
  • LAPACKSpec: QR/SVD/Cholesky reconstruction; eigSH eigenvalue ordering, eigenvector orthonormality, matrix reconstruction; pinverse Moore–Penrose conditions
  • StatisticsSpec: meanVar (population and sample); meanVarWeighted
  • NumericalSpec: power-iteration eigenvalue convergence
  • ArithSpec/ArraySpec: bitNot, cplx/real/imag round-trips, signum for unsigned and float-zero edge cases
  • ExceptionSpec: AFException FFI boundary propagation; toAFExceptionType for all documented AFErr codes
  • Random: fixed-seed reproducibility, distinct-seed divergence, distribution shape/range
  • Semiring/Ring laws via QuickCheck.Classes for scalar and array instances; test suite fails if lawsCheck fails

CI / build

  • Nix flake: CUDA backend support (cudatoolkit, nvidia_x11, allowUnfree)
  • Nix flake: darwin (x86_64 via Rosetta 2) build and devShell support
  • CI: switched from cachix/install-nix-action to ners/simply-nix@main with reclaim_space: true
  • CI: Haddock docs published to GitHub Pages on push to master
  • Switched from hspec to hspec-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

27 May 03:44
0021480

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 0.7.0.0...0.7.1.0

0.7.0.0

02 Oct 00:35

Choose a tag to compare

  • Use latest GHC (9.2.2 / 9.4.2)
  • Use latest arrayfire (3.8.2)
  • Fix tests for product and variance functions
  • Update various scripts (nix, .ghci, etc.)

Hackage Link

0.6.0.0

15 Nov 08:17

Choose a tag to compare

  • Documentation fix for negate
  • Change public interface on BLAS functions to constrain on AFType
  • Adjust cabal file, account for different environments correctly

0.5.1.0

12 Nov 03:57

Choose a tag to compare

  • Updated documentation for column-major order
  • Bugfix of double free
  • Add hackage docs upload scripts

0.5.0.0

09 Nov 22:01

Choose a tag to compare

  • Add strong types for logical operators (CBool)
  • Adjust smart constructors to work column-major oriented.
  • Light doc fixes.

0.4.0.0

06 Nov 18:44

Choose a tag to compare

  • Removed Ord instance since compare was ambiguous.
  • Show Array transposed by default.

0.3.0.0

06 Nov 15:47

Choose a tag to compare

  • Update Eq / Ord to operate element-wise along Array.

0.2.0.0

06 Nov 03:14
3d7d66d

Choose a tag to compare

  • Updated external interface for real and imag
  • Removed functions that are not present in the 3.6.4 API (af_pinverse, etc.)
  • Adjust cabal flags

0.1.0.0

06 Nov 02:50
27bef52

Choose a tag to compare

🎉 Initial Alpha Release 🎉

  • Based on 3.6.4 version of the API.