Rename Data.NumIdr.Array.Order to Rep
This commit is contained in:
parent
bc08b4942e
commit
eeb2967f6f
|
@ -15,7 +15,7 @@ modules = Data.NP,
|
||||||
Data.NumIdr.Array,
|
Data.NumIdr.Array,
|
||||||
Data.NumIdr.Array.Array,
|
Data.NumIdr.Array.Array,
|
||||||
Data.NumIdr.Array.Coords,
|
Data.NumIdr.Array.Coords,
|
||||||
Data.NumIdr.Array.Order,
|
Data.NumIdr.Array.Rep,
|
||||||
Data.NumIdr.Homogeneous,
|
Data.NumIdr.Homogeneous,
|
||||||
Data.NumIdr.Matrix,
|
Data.NumIdr.Matrix,
|
||||||
Data.NumIdr.Interfaces,
|
Data.NumIdr.Interfaces,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Data.NP
|
||||||
import Data.Permutation
|
import Data.Permutation
|
||||||
import Data.NumIdr.Interfaces
|
import Data.NumIdr.Interfaces
|
||||||
import Data.NumIdr.PrimArray
|
import Data.NumIdr.PrimArray
|
||||||
import Data.NumIdr.Array.Order
|
import Data.NumIdr.Array.Rep
|
||||||
import Data.NumIdr.Array.Coords
|
import Data.NumIdr.Array.Coords
|
||||||
import Data.NumIdr.Array.Shape
|
import Data.NumIdr.Array.Shape
|
||||||
|
|
||||||
|
|
71
src/Data/NumIdr/Array/Rep.idr
Normal file
71
src/Data/NumIdr/Array/Rep.idr
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
module Data.NumIdr.Array.Rep
|
||||||
|
|
||||||
|
import Data.Vect
|
||||||
|
|
||||||
|
%default total
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- Array orders
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
||| An order is an abstract representation of the way in which array
|
||||||
|
||| elements are stored in memory. Orders are used to calculate strides,
|
||||||
|
||| which provide a method of converting an array coordinate into a linear
|
||||||
|
||| memory location.
|
||||||
|
public export
|
||||||
|
data Order : Type where
|
||||||
|
||| C-like order, or contiguous order. This order stores elements in a
|
||||||
|
||| row-major fashion (the last axis is the least significant).
|
||||||
|
COrder : Order
|
||||||
|
||| Fortran-like order. This order stores elements in a column-major
|
||||||
|
||| fashion (the first axis is the least significant).
|
||||||
|
FOrder : Order
|
||||||
|
|
||||||
|
|
||||||
|
public export
|
||||||
|
Eq Order where
|
||||||
|
COrder == COrder = True
|
||||||
|
FOrder == FOrder = True
|
||||||
|
COrder == FOrder = False
|
||||||
|
FOrder == COrder = False
|
||||||
|
|
||||||
|
|
||||||
|
||| Calculate an array's strides given its order and shape.
|
||||||
|
export
|
||||||
|
calcStrides : Order -> Vect rk Nat -> Vect rk Nat
|
||||||
|
calcStrides _ [] = []
|
||||||
|
calcStrides COrder v@(_::_) = scanr (*) 1 $ tail v
|
||||||
|
calcStrides FOrder v@(_::_) = scanl (*) 1 $ init v
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- Array representations
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
public export
|
||||||
|
data Rep : Type where
|
||||||
|
Bytes : Order -> Rep
|
||||||
|
Boxed : Order -> Rep
|
||||||
|
Linked : Rep
|
||||||
|
Delayed : Rep
|
||||||
|
|
||||||
|
public export
|
||||||
|
B : Rep
|
||||||
|
B = Boxed COrder
|
||||||
|
|
||||||
|
public export
|
||||||
|
L : Rep
|
||||||
|
L = Linked
|
||||||
|
|
||||||
|
public export
|
||||||
|
D : Rep
|
||||||
|
D = Delayed
|
||||||
|
|
||||||
|
|
||||||
|
public export
|
||||||
|
data LinearRep : Rep -> Type where
|
||||||
|
BytesIsL : LinearRep (Bytes o)
|
||||||
|
BoxedIsL : LinearRep (Boxed o)
|
Loading…
Reference in a new issue