arrayfire-0.9.0.0: Haskell bindings to the ArrayFire general-purpose GPU library
CopyrightDavid Johnson (c) 2019-2026
LicenseBSD 3
MaintainerDavid Johnson <code@dmj.io>
StabilityExperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

ArrayFire.Index

Description

Functions for indexing into an Array

Synopsis

Documentation

index Source #

Arguments

:: Array a

Array argument

-> [Seq]

Seq to use for indexing

-> Array a 

Index into an Array by Seq

lookup Source #

Arguments

:: Array a

Input Array

-> Array Int

Indices

-> Int

Dimension

-> Array a 

Lookup an Array by keys along a specified dimension

assignSeq Source #

Arguments

:: Array a

Destination array

-> [Seq]

Indices defining the range to assign into

-> Array a

Source array

-> Array a

Result with values written at the specified indices

Assign values into an Array range defined by Seq indices

>>> let a = vector @Double 5 [1..]
>>> assignSeq a [Seq 1 3 1] (vector @Double 3 [0,0,0])

indexGen Source #

Arguments

:: Array a

Input array

-> [Index]

List of Index values (one per dimension)

-> Array a

Indexed result

Index into an Array using generalized Index values (arrays or sequences)

>>> let a = matrix @Double (3,3) [[1..],[1..],[1..]]
>>> indexGen a [seqIdx (Seq 0 1 1) False, seqIdx (Seq 0 1 1) False]

assignGen Source #

Arguments

:: Array a

Destination array

-> [Index]

List of Index values defining the range to assign into

-> Array a

Source array

-> Array a

Result with values written at the specified indices

Assign values into an Array using generalized Index values

>>> let a = matrix @Double (3,3) [[1..],[1..],[1..]]
>>> let b = matrix @Double (2,2) [[0,0],[0,0]]
>>> assignGen a [seqIdx (Seq 0 1 1) False, seqIdx (Seq 0 1 1) False] b

afSpan :: Seq Source #

A special Seq value representing the entire axis of an Array. Hard-coded from include/af/seq.h because FFI cannot import static const values.

full :: Index Source #

Select the full extent of a dimension. Use in tuple indices where you want all elements along an axis.

arr ! (range 0 2, full, at 1)

class ToIndexList a where Source #

Convert index expressions to a list of Index. Supports a single Index or tuples of up to four Index values (matching ArrayFire's maximum of 4 dimensions).

Methods

toIndexList :: a -> [Index] Source #

Instances

Instances details
ToIndexList Index Source # 
Instance details

Defined in ArrayFire.Index

Methods

toIndexList :: Index -> [Index] Source #

ToIndexList (Index, Index) Source # 
Instance details

Defined in ArrayFire.Index

Methods

toIndexList :: (Index, Index) -> [Index] Source #

ToIndexList (Index, Index, Index) Source # 
Instance details

Defined in ArrayFire.Index

ToIndexList (Index, Index, Index, Index) Source # 
Instance details

Defined in ArrayFire.Index

idx :: Seq -> Index Source #

Lift a Seq to an Index for use in tuple-based indexing.

(!) :: ToIndexList ix => Array a -> ix -> Array a infixl 9 Source #

Index an Array. Accepts a single Index or a tuple of up to four.

arr ! at 0                      -- 1D: element 0
arr ! range 1 3                 -- 1D: rows 1-3
arr ! (range 0 2, at 1)         -- 2D
arr ! (range 0 2, full, at 1)   -- 3D, full second axis

(.~) :: ToIndexList ix => ix -> Array a -> Array a -> Array a infixr 4 Source #

Assign into a range of an Array. Lens-style: use with (&).

arr & range 1 3 .~ src
arr & (range 0 1, at 2) .~ src