6.10 Pointwise Operations
Most of the operations documented in this section are simple macros that apply array-map to a function and their array arguments.
procedure
f : (-> R) (array-map f arr0) → (Array R) f : (A -> R) arr0 : (Array A) (array-map f arr0 arr1 arrs ...) → (Array R) f : (A B Ts ... -> R) arr0 : (Array A) arr1 : (Array B) arrs : (Array Ts)
Examples: | |||||||||||||||||||||||||||
|
> (array-map * (array #[-4.3 -1.2 -0.2]) (array -2.81)) - : (Array Nonnegative-Flonum)
(array #[12.083 3.372 0.562])
When explicitly instantiating array-map’s types using inst, instantiate R (the return type’s element type) first, then the arguments’ element types in order.
syntax
(inline-array-map f arrs ...)
syntax
(array+ arrs ...)
syntax
(array* arrs ...)
syntax
(array- arr0 arrs ...)
syntax
(array/ arr0 arrs ...)
syntax
(array-min arr0 arrs ...)
syntax
(array-max arr0 arrs ...)
Examples: | ||||||||||||
|
syntax
(array-scale arr x)
syntax
(array-abs arr)
syntax
(array-sqr arr)
syntax
(array-sqrt arr)
syntax
(array-conjugate arr)
syntax
(array-real-part arr)
syntax
(array-imag-part arr)
syntax
(array-make-rectangular arr0 arr1)
syntax
(array-magnitude arr)
syntax
(array-angle arr)
syntax
(array-make-polar arr0 arr1)
syntax
(array< arr0 arr1 arrs ...)
syntax
(array<= arr0 arr1 arrs ...)
syntax
(array> arr0 arr1 arrs ...)
syntax
(array>= arr0 arr1 arrs ...)
syntax
(array= arr0 arr1 arrs ...)
syntax
(array-not arr)
syntax
(array-and arr ...)
syntax
(array-or arr ...)
syntax
(array-if cond-arr true-arr false-err)
(: array-factorial ((Array Integer) -> (Array Integer))) (define (array-factorial arr) (array-if (array<= arr (array 0)) (array 1) (array* arr (array-factorial (array- arr (array 1))))))
6.10.1 Broadcasting
parameter
(array-broadcasting) → (U Boolean 'permissive)
(array-broadcasting broadcasting) → void? broadcasting : (U Boolean 'permissive)
procedure
(array-shape-broadcast dss [broadcasting]) → Indexes
dss : (Listof Indexes) broadcasting : (U Boolean 'permissive) = (array-broadcasting)
Examples: | |||||||||||||||||
|
procedure
(array-broadcast arr ds) → (Array A)
arr : (Array A) ds : Indexes
Examples: | |||||||||
|
When array-strictness is #f, array-broadcast always returns a nonstrict array.
When array-strictness is #t, array-broadcast returns a strict array when arr is nonstrict and the result has more elements than arr.