Idris2Doc : Data.NumIdr.Array.Array

Data.NumIdr.Array.Array

(source)

Definitions

dataArray : VectrkNat->Type->Type
  The type of an array.

Arrays are the central data structure of NumIdr. They are an `n`-dimensional
grid of values, where `n` is a value known as the *rank* of the array. Arrays
of rank 0 are single values, arrays of rank 1 are vectors, and arrays of rank
2 are matrices.

Each array has a *shape*, which is a vector of values giving the dimensions
of each axis of the array. The shape is also sometimes used to determine the
array's total size.

Arrays are indexed by row first, as in the standard mathematical notation for
matrices.

@ rk The rank of the array
@ s The shape of the array
@ a The type of the array's elements

Totality: total
Visibility: export
Constructor: 
MkArray : (rep : Rep) -> {autorc : RepConstraintrepa} -> (s : VectrkNat) ->PrimArrayrepsa->Arraysa
  Internally, arrays are stored via one of a handful of representations.

@ s The shape of the array
@ rep The internal representation of the array
@ rc A witness that the element type satisfies the representation constraint

Hints:
Applicative (Arrays)
Castab=>Cast (Arraysa) (Arraysb)
Eqa=>Eq (Arraysa)
Foldable (Arrays)
Fractionala=>Fractional (Arraysa)
Functor (Arrays)
Monad (Arrays)
Monoida=>Monoid (Arraysa)
Numa=>Multa (Arraysa) (Arraysa)
Numa=>Mult (Arraysa) a (Arraysa)
Nega=>Neg (Arraysa)
Numa=>Num (Arraysa)
Semigroupa=>Semigroup (Arraysa)
Showa=>Show (Arraysa)
Traversable (Arrays)
Zippable (Arrays)
unsafeMkArray : (rep : Rep) -> {autorc : RepConstraintrepa} -> (s : VectrkNat) ->PrimArrayrepsa->Arraysa
Totality: total
Visibility: export
shape : Arraysa->VectrkNat
  The shape of the array.

Totality: total
Visibility: export
size : Arraysa->Nat
  The size of the array, i.e. the total number of elements.

Totality: total
Visibility: export
rank : Arraysa->Nat
  The rank of the array.

Totality: total
Visibility: export
getRep : Arraysa->Rep
  The internal representation of the array.

Totality: total
Visibility: export
getRepC : (arr : Arraysa) ->RepConstraint (getReparr) a
  The representation constraint of the array.

Totality: total
Visibility: export
getPrim : (arr : Arraysa) ->PrimArray (getReparr) sa
  Extract the primitive backend array.

Totality: total
Visibility: export
shapeEq : (arr : Arraysa) ->s=shapearr
Totality: total
Visibility: export
dataShapeView : Arraysa->Type
  A view for extracting the shape of an array.

Totality: total
Visibility: public export
Constructor: 
Shape : (s : VectrkNat) ->ShapeViewarr
viewShape : (arr : Arraysa) ->ShapeViewarr
  The covering function for the view `ShapeView`. This function takes an array
of type `Array s a` and returns `Shape s`.

Totality: total
Visibility: export
repeat : {defaultBrep : Rep} ->RepConstraintrepa=> (s : VectrkNat) ->a->Arraysa
  Create an array by repeating a single value.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
zeros : {defaultBrep : Rep} ->RepConstraintrepa=>Numa=> (s : VectrkNat) ->Arraysa
  Create an array filled with zeros.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
ones : {defaultBrep : Rep} ->RepConstraintrepa=>Numa=> (s : VectrkNat) ->Arraysa
  Create an array filled with ones.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
fromVect : {defaultBrep : Rep} ->LinearReprep=>RepConstraintrepa=> (s : VectrkNat) ->Vect (products) a->Arraysa
  Create an array given a vector of its elements. The elements of the vector
are arranged into the provided shape using the provided order.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
fromStream : {defaultBrep : Rep} ->LinearReprep=>RepConstraintrepa=> (s : VectrkNat) ->Streama->Arraysa
  Create an array by taking values from a stream.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
fromFunctionNB : {defaultBrep : Rep} ->RepConstraintrepa=> (s : VectrkNat) -> (VectrkNat->a) ->Arraysa
  Create an array given a function to generate its elements.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
fromFunction : {defaultBrep : Rep} ->RepConstraintrepa=> (s : VectrkNat) -> (Coordss->a) ->Arraysa
  Create an array given a function to generate its elements.

@ s The shape of the constructed array
@ rep The internal representation of the constructed array

Totality: total
Visibility: export
array : {defaultBrep : Rep} ->RepConstraintrepa=>Vectssa->Arraysa
  Construct an array using a structure of nested vectors.
To explicitly specify the shape and order of the array, use `array'`.

Totality: total
Visibility: export
index : Coordss->Arraysa->a
  Index the array using the given coordinates.

Totality: total
Visibility: export
(!!) : Arraysa->Coordss->a
  Index the array using the given coordinates.

This is the operator form of `index`.

Totality: total
Visibility: export
Fixity Declarations:
infixl operator, level 10
infixl operator, level 10
infixl operator, level 10
indexUpdate : Coordss-> (a->a) ->Arraysa->Arraysa
  Update the entry at the given coordinates using the function.

Totality: total
Visibility: export
indexSet : Coordss->a->Arraysa->Arraysa
  Set the entry at the given coordinates to the given value.

Totality: total
Visibility: export
indexRange : (rs : CoordsRanges) ->Arraysa->Array (newShapers) a
  Index the array using the given range of coordinates, returning a new array.

Totality: total
Visibility: export
(!!..) : Arraysa-> (rs : CoordsRanges) ->Array (newShapers) a
  Index the array using the given range of coordinates, returning a new array.

This is the operator form of `indexRange`.

Totality: total
Visibility: export
Fixity Declaration: infixl operator, level 11
indexSetRange : (rs : CoordsRanges) ->Array (newShapers) a->Arraysa->Arraysa
  Set the sub-array at the given range of coordinates to the given array.

Totality: total
Visibility: export
indexUpdateRange : (rs : CoordsRanges) -> (Array (newShapers) a->Array (newShapers) a) ->Arraysa->Arraysa
  Update the sub-array at the given range of coordinates by applying
a function to it.

Totality: total
Visibility: export
indexNB : VectrkNat->Arraysa->Maybea
  Index the array using the given coordinates, returning `Nothing` if the
coordinates are out of bounds.

Totality: total
Visibility: export
(!?) : Arraysa->VectrkNat->Maybea
  Index the array using the given coordinates, returning `Nothing` if the
coordinates are out of bounds.

This is the operator form of `indexNB`.

Totality: total
Visibility: export
Fixity Declarations:
infixl operator, level 10
infixl operator, level 10
infixl operator, level 10
indexUpdateNB : VectrkNat-> (a->a) ->Arraysa->Maybe (Arraysa)
  Update the entry at the given coordinates using the function. `Nothing` is
returned if the coordinates are out of bounds.

Totality: total
Visibility: export
indexSetNB : VectrkNat->a->Arraysa->Maybe (Arraysa)
  Set the entry at the given coordinates using the function. `Nothing` is
returned if the coordinates are out of bounds.

Totality: total
Visibility: export
indexRangeNB : (rs : VectrkCRangeNB) ->Arraysa->Maybe (Array (newShapesrs) a)
  Index the array using the given range of coordinates, returning a new array.
If any of the given indices are out of bounds, then `Nothing` is returned.

Totality: total
Visibility: export
(!?..) : Arraysa-> (rs : VectrkCRangeNB) ->Maybe (Array (newShapesrs) a)
  Index the array using the given range of coordinates, returning a new array.
If any of the given indices are out of bounds, then `Nothing` is returned.

This is the operator form of `indexRangeNB`.

Totality: total
Visibility: export
Fixity Declaration: infixl operator, level 11
indexUnsafe : VectrkNat->Arraysa->a
  Index the array using the given coordinates.
WARNING: This function does not perform any bounds check on its inputs.
Misuse of this function can easily break memory safety.

Totality: total
Visibility: export
(!#) : Arraysa->VectrkNat->a
  Index the array using the given coordinates.
WARNING: This function does not perform any bounds check on its inputs.
Misuse of this function can easily break memory safety.

This is the operator form of `indexUnsafe`.

Totality: total
Visibility: export
Fixity Declaration: infixl operator, level 10
indexRangeUnsafe : (rs : VectrkCRangeNB) ->Arraysa->Array (newShapesrs) a
  Index the array using the given range of coordinates, returning a new array.
WARNING: This function does not perform any bounds check on its inputs.
Misuse of this function can easily break memory safety.

Totality: total
Visibility: export
(!#..) : Arraysa-> (rs : VectrkCRangeNB) ->Array (newShapesrs) a
  Index the array using the given range of coordinates, returning a new array.
WARNING: This function does not perform any bounds check on its inputs.
Misuse of this function can easily break memory safety.

This is the operator form of `indexRangeUnsafe`.

Totality: total
Visibility: export
Fixity Declaration: infixl operator, level 11
mapArray' : (a->a) ->Arraysa->Arraysa
  Map a function over an array.

You should almost always use `map` instead; only use this function if you
know what you are doing!

Totality: total
Visibility: export
mapArray : (a->b) -> (arr : Arraysa) ->RepConstraint (getReparr) b=>Arraysb
  Map a function over an array.

You should almost always use `map` instead; only use this function if you
know what you are doing!

Totality: total
Visibility: export
zipWithArray' : (a->a->a) ->Arraysa->Arraysa->Arraysa
  Combine two arrays of the same element type using a binary function.

You should almost always use `zipWith` instead; only use this function if
you know what you are doing!

Totality: total
Visibility: export
zipWithArray : (a->b->c) -> (arr : Arraysa) -> (arr' : Arraysb) ->RepConstraint (mergeRep (getReparr) (getReparr')) c=>Arraysc
  Combine two arrays using a binary function.

You should almost always use `zipWith` instead; only use this function if
you know what you are doing!

Totality: total
Visibility: export
reshape : (s' : Vectrk'Nat) -> (arr : Arraysa) ->LinearRep (getReparr) => {auto0_ : products=products'} ->Arrays'a
  Reshape the array into the given shape.

@ s' The shape to convert the array to

Totality: total
Visibility: export
convertRep : (rep : Rep) ->RepConstraintrepa=>Arraysa->Arraysa
  Change the internal representation of the array's elements.

Totality: total
Visibility: export
delayed : (Arraysa->Arrays'a) ->Arraysa->Arrays'a
  Temporarily convert an array to a delayed representation to make modifying
it more efficient, then convert it back to its original representation.

Totality: total
Visibility: export
resize : (s' : VectrkNat) ->a->Arraysa->Arrays'a
  Resize the array to a new shape, preserving the coordinates of the original
elements. New coordinates are filled with a default value.

@ s' The shape to resize the array to
@ def The default value to fill the array with

Totality: total
Visibility: export
resizeLTE : (s' : VectrkNat) -> {auto0_ : Allid (zipWithLTEs's)} ->Arraysa->Arrays'a
  Resize the array to a new shape, preserving the coordinates of the original
elements. This function requires a proof that the new shape is strictly
smaller than the current shape of the array.

@ s' The shape to resize the array to

Totality: total
Visibility: export
enumerateNB : Arraysa->List (VectrkNat, a)
  List all of the values in an array along with their coordinates.

Totality: total
Visibility: export
enumerate : Arraysa->List (Coordss, a)
  List all of the values in an array along with their coordinates.

Totality: total
Visibility: export
elements : Arraysa->Vect (products) a
  List all of the values in an array in row-major order.

Totality: total
Visibility: export
concat : (axis : Finrk) ->Arraysa->Array (replaceAtaxisds) a->Array (updateAtaxis (\{arg:0}=>{arg:0}+d) s) a
  Join two arrays along a particular axis, e.g. combining two matrices
vertically or horizontally. All other axes of the arrays must have the
same dimensions.

@ axis The axis to join the arrays on

Totality: total
Visibility: export
stack : (axis : Fin (Srk)) ->Vectn (Arraysa) ->Array (insertAtaxisns) a
  Stack multiple arrays along a new axis, e.g. stacking vectors to form a matrix.

@ axis The axis to stack the arrays along

Totality: total
Visibility: export
joinAxes : Arrays (Arrays'a) ->Array (s++s') a
  Join the axes of a nested array structure to form a single array.

Totality: total
Visibility: export
splitAxes : (rk : Nat) ->Arraysa->Array (takerks) (Array (droprks) a)
  Split an array into a nested array structure along the specified axes.

Totality: total
Visibility: export
transpose : Arraysa->Array (reverses) a
  Construct the transpose of an array by reversing the order of its axes.

Totality: total
Visibility: export
.T : Arraysa->Array (reverses) a
  Construct the transpose of an array by reversing the order of its axes.

This is the postfix form of `transpose`.

Totality: total
Visibility: export
swapAxes : (i : Finrk) -> (j : Finrk) ->Arraysa->Array (swapElemsijs) a
  Swap two axes in an array.

Totality: total
Visibility: export
permuteAxes : (p : Permutationrk) ->Arraysa->Array (permuteVectps) a
  Apply a permutation to the axes of an array.

Totality: total
Visibility: export
swapInAxis : (axis : Finrk) ->Fin (indexaxiss) ->Fin (indexaxiss) ->Arraysa->Arraysa
  Swap two coordinates along a specific axis (e.g. swapping two rows in a matrix).

@ axis The axis to swap the coordinates along. Slices of the array
perpendicular to this axis are taken when swapping.

Totality: total
Visibility: export
permuteInAxis : (axis : Finrk) ->Permutation (indexaxiss) ->Arraysa->Arraysa
  Permute the coordinates along a specific axis (e.g. permuting the rows in
a matrix).

@ axis The axis to permute the coordinates along. Slices of the array
perpendicular to this axis are taken when permuting.

Totality: total
Visibility: export
lerp : Nega=>a->Arraysa->Arraysa->Arraysa
  Linearly interpolate between two arrays.

Totality: total
Visibility: export
normSq : Numa=>Arraysa->a
  Calculate the square of an array's Eulidean norm.

Totality: total
Visibility: export
norm : ArraysDouble->Double
  Calculate an array's Eucliean norm.

Totality: total
Visibility: export
normalize : ArraysDouble->ArraysDouble
  Normalize the array to a norm of 1.

If the array contains all zeros, then it is returned unchanged.

Totality: total
Visibility: export
pnorm : Double->ArraysDouble->Double
  Calculate the Lp-norm of an array.

Totality: total
Visibility: export