HomeAboutCodePastes
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordieggsy <dieggsy@protonmail.com>2021-01-26 23:45:33 -0500
committerdieggsy <dieggsy@protonmail.com>2021-01-26 23:45:33 -0500
commiteb4a22a6d955e0219acd3123a8cbdd5f45d05c69 (patch)
tree1f8b1c0e0b6c594276a3dc54867cf79d0fd094fa
parentb44f77b563b79425f7acb5210292fe7e01f68f3e (diff)
downloadsrfi-179-eb4a22a6d955e0219acd3123a8cbdd5f45d05c69.tar.gz
Add links (headings) for procedures
-rw-r--r--srfi-179.svnwiki71
1 files changed, 71 insertions, 0 deletions
diff --git a/srfi-179.svnwiki b/srfi-179.svnwiki
index bfeded9..edabdc2 100644
--- a/srfi-179.svnwiki
+++ b/srfi-179.svnwiki
@@ -151,10 +151,12 @@ This document refers to ''translations'' and ''permutations''. A translation is
==== Procedures
+===== translation?
<procedure>(translation? object)</procedure>
Returns {{#t}} if {{object}} is a translation, and {{#f}} otherwise.
+===== permutation?
<procedure>(permutation? object)</procedure>
Returns {{#t}} if {{object}} is a permutation, and {{#f}} otherwise.
@@ -167,6 +169,7 @@ Intervals are a data type distinct from other Scheme data types.
==== Procedures
+===== make-interval
<procedure>(make-interval arg1 #!optional arg2)</procedure>
Create a new interval. {{arg1}} and {{arg2}} (if given) are nonempty vectors (of the same length) of exact integers.
@@ -178,10 +181,12 @@ If {{arg2}} is given, then {{arg1}} is taken to be {{lower-bounds}} and {{arg2}}
(< (vector-ref lower-bounds i) (vector-ref upper-bounds i))
for $0\leq i<{}${{(vector-length lower-bounds)}}. It is an error if {{lower-bounds}} and {{upper-bounds}} do not satisfy these conditions.
+===== interval?
<procedure>(interval? obj)</procedure>
Returns {{#t}} if {{obj}} is an interval, and {{#f}} otherwise.
+===== interval-dimension
<procedure>(interval-dimension interval)</procedure>
If {{interval}} is an interval built with
@@ -189,8 +194,10 @@ If {{interval}} is an interval built with
(make-interval lower-bounds upper-bounds)
then {{interval-dimension}} returns {{(vector-length lower-bounds)}}. It is an error to call {{interval-dimension}} if {{interval}} is not an interval.
+===== interval-lower-bound
<procedure>(interval-lower-bound interval i)</procedure>
+===== interval-upper-bound
<procedure>(interval-upper-bound interval i)</procedure>
If {{interval}} is an interval built with
@@ -203,8 +210,10 @@ $0 \leq i<$ {{(vector-length lower-bounds)}},
then {{interval-lower-bound}} returns {{(vector-ref lower-bounds i)}} and {{interval-upper-bound}} returns {{(vector-ref upper-bounds i)}}. It is an error to call {{interval-lower-bound}} or {{interval-upper-bound}} if {{interval}} and {{i}} do not satisfy these conditions.
+===== interval-lower-bounds->list
<procedure>(interval-lower-bounds->list interval)</procedure>
+===== interval-upper-bounds->list
<procedure>(interval-upper-bounds->list interval)</procedure>
If {{interval}} is an interval built with
@@ -213,8 +222,10 @@ If {{interval}} is an interval built with
then {{interval-lower-bounds->list}} returns {{(vector->list lower-bounds)}} and {{interval-upper-bounds->list}} returns {{(vector->list upper-bounds)}}. It is an error to call {{interval-lower-bounds->list}} or {{interval-upper-bounds->list}} if {{interval}} does not satisfy these conditions.
+===== interval-lower-bounds->vector
<procedure>(interval-lower-bounds->vector interval)</procedure>
+===== interval-upper-bounds->vector
<procedure>(interval-upper-bounds->vector interval)</procedure>
If {{interval}} is an interval built with
@@ -222,6 +233,7 @@ If {{interval}} is an interval built with
(make-interval lower-bounds upper-bounds)
then {{interval-lower-bounds->vector}} returns a copy of {{lower-bounds}} and {{interval-upper-bounds->vector}} returns a copy of {{upper-bounds}}. It is an error to call {{interval-lower-bounds->vector}} or {{interval-upper-bounds->vector}} if {{interval}} does not satisfy these conditions.
+===== interval-volume
<procedure>(interval-volume interval)</procedure>
If {{interval}} is an interval built with
@@ -232,6 +244,7 @@ then, assuming the existence of {{vector-map}}, {{interval-volume}} returns
(apply * (vector->list (vector-map - upper-bounds lower-bounds)))
It is an error to call {{interval-volume}} if {{interval}} does not satisfy this condition.
+===== interval=
<procedure>(interval= interval1 interval2)</procedure>
If {{interval1}} and {{interval2}} are intervals built with
@@ -245,6 +258,7 @@ respectively, then {{interval=}} returns
(and (equal? lower-bounds1 lower-bounds2) (equal? upper-bounds1 upper-bounds2))
It is an error to call {{interval=}} if {{interval1}} or {{interval2}} do not satisfy this condition.
+===== interval-subset?
<procedure>(interval-subset? interval1 interval2)</procedure>
If {{interval1}} and {{interval2}} are intervals of the same dimension $d$, then {{interval-subset?}} returns {{#t}} if
@@ -255,6 +269,7 @@ and
(<= (interval-upper-bound interval1 j) (interval-upper-bound interval2 j))
for all $0\leq j<d$, otherwise it returns {{#f}}. It is an error if the arguments do not satisfy these conditions.
+===== interval-contains-multi-index?
<procedure>(interval-contains-multi-index? interval index-0 index-1 ...)</procedure>
If {{interval}} is an interval with dimension $d$ and {{index-0}}, {{index-1}}, ..., is a multi-index of length $d$, then {{interval-contains-multi-index?}} returns {{#t}} if
@@ -265,6 +280,7 @@ for $0\leq j < d$, and {{#f}} otherwise.
It is an error to call {{interval-contains-multi-index?}} if {{interval}} and {{index-0}},..., do not satisfy this condition.
+===== interval-projections
<procedure>(interval-projections interval right-dimension)</procedure>
Conceptually, {{interval-projections}} takes a $d$-dimensional interval $[l_0,u_0)\times [l_1,u_1)\times\cdots\times[l_{d-1},u_{d-1})$ and splits it into two parts
@@ -302,12 +318,14 @@ More precisely, if {{interval}} is an interval and {{right-dimension}} is an exa
(- d 1)))))</enscript>
It is an error to call {{interval-projections}} if its arguments do not satisfy these conditions.
+===== interval-for-each
<procedure>(interval-for-each f interval)</procedure>
This routine assumes that {{interval}} is an interval and {{f}} is a routine whose domain includes elements of {{interval}}. It is an error to call {{interval-for-each}} if {{interval}} and {{f}} do not satisfy these conditions.
{{interval-for-each}} calls {{f}} with each multi-index of {{interval}} as arguments, all in lexicographical order.
+===== interval-dilate
<procedure>(interval-dilate interval lower-diffs upper-diffs)</procedure>
If {{interval}} is an interval with lower bounds $\ell_0,\dots,\ell_{d-1}$ and upper bounds $u_0,\dots,u_{d-1}$, and {{lower-diffs}} is a vector of exact integers $L_0,\dots,L_{d-1}$ and {{upper-diffs}} is a vector of exact integers $U_0,\dots,U_{d-1}$, then {{interval-dilate}} returns a new interval with lower bounds $\ell_0+L_0,\dots,\ell_{d-1}+L_{d-1}$ and upper bounds $u_0+U_0,\dots,u_{d-1}+U_{d-1}$, as long as this is a nonempty interval. It is an error if the arguments do not satisfy these conditions.
@@ -329,18 +347,21 @@ Examples:
(interval-dilate
(make-interval '#(100 100))
'#(0 0) '#(-500 -50)) => error</enscript>
+===== interval-intersect
<procedure>(interval-intersect interval-1 interval-2 ...)</procedure>
If all the arguments are intervals of the same dimension and they have a nonempty intersection, then {{interval-intersect}} returns that intersection; otherwise it returns {{#f}}.
It is an error if the arguments are not all intervals with the same dimension.
+===== interval-translate
<procedure>(interval-translate interval translation)</procedure>
If {{interval}} is an interval with lower bounds $\ell_0,\dots,\ell_{d-1}$ and upper bounds $u_0,\dots,u_{d-1}$, and {{translation}} is a translation with entries $T_0,\dots,T_{d-1}$ , then {{interval-translate}} returns a new interval with lower bounds $\ell_0+T_0,\dots,\ell_{d-1}+T_{d-1}$ and upper bounds $u_0+T_0,\dots,u_{d-1}+T_{d-1}$. It is an error if the arguments do not satisfy these conditions.
One could define {{(interval-translate interval translation)}} by {{(interval-dilate interval translation translation)}}.
+===== interval-permute
<procedure>(interval-permute interval permutation)</procedure>
The argument {{interval}} must be an interval, and the argument {{permutation}} must be a valid permutation with the same dimension as {{interval}}. It is an error if the arguments do not satisfy these conditions.
@@ -351,18 +372,21 @@ We have chosen the following convention: If the permutation is $(\pi_0,\ldots,\p
For example, if the argument interval represents $[0,4)\times[0,8)\times[0,21)\times [0,16)$ and the permutation is {{#(3 0 1 2)}}, then the result of {{(interval-permute interval permutation)}} will be the representation of $[0,16)\times [0,4)\times[0,8)\times[0,21)$.
+===== interval-rotate
<procedure>(interval-rotate interval dim)</procedure>
Informally, {{(interval-rotate interval dim)}} rotates the axes of {{interval}} {{dim}} places to the left.
More precisely, {{(interval-rotate interval dim)}} assumes that {{interval}} is an interval and {{dim}} is an exact integer between 0 (inclusive) and {{(interval-dimension interval)}} (exclusive). It computes the permutation {{(vector dim ... (- (interval-dimension interval) 1) 0 ... (- dim 1))}} (unless {{dim}} is zero, in which case it constructs the identity permutation) and returns {{(interval-permute interval permutation)}}. It is an error if the arguments do not satisfy these conditions.
+===== interval-scale
<procedure>(interval-scale interval scales)</procedure>
If {{interval}} is a $d$-dimensional interval $[0,u_1)\times\cdots\times[0,u_{d-1})$ with all lower bounds zero, and {{scales}} is a length-$d$ vector of positive exact integers, which we'll denote by $\vec s$, then {{interval-scale}} returns the interval $[0,\operatorname{ceiling}(u_1/s_1))\times\cdots\times[0,\operatorname{ceiling}(u_{d-1}/s_{d-1}))$.
It is an error if {{interval}} and {{scales}} do not satisfy this condition.
+===== interval-cartesian-product
<procedure>(interval-cartesian-product interval . intervals)</procedure>
Implements the Cartesian product of the intervals in {{(cons interval intervals)}}. Returns
@@ -377,6 +401,7 @@ Conceptually, a storage-class is a set of functions to manage the backing store
==== Procedures
+===== make-storage-class
<procedure>(make-storage-class getter setter checker maker copier length default)</procedure>
Here we assume the following relationships between the arguments of {{make-storage-class}}. Assume that the "elements" of the backing store are of some "type", either heterogeneous (all Scheme types) or homogeneous (of some restricted type).
@@ -391,22 +416,30 @@ If the arguments do not satisfy these conditions, then it is an error to call {{
Note that we assume that {{getter}} and {{setter}} generally take ''O''(1) time to execute.
+===== storage-class?
<procedure>(storage-class? m)</procedure>
Returns {{#t}} if {{m}} is a storage class, and {{#f}} otherwise.
+===== storage-class-getter
<procedure>(storage-class-getter m)</procedure>
+===== storage-class-setter
<procedure>(storage-class-setter m)</procedure>
+===== storage-class-checker
<procedure>(storage-class-checker m)</procedure>
+===== storage-class-maker
<procedure>(storage-class-maker m)</procedure>
+===== storage-class-copier
<procedure>(storage-class-copier m)</procedure>
+===== storage-class-length
<procedure>(storage-class-length m)</procedure>
+===== storage-class-default
<procedure>(storage-class-default m)</procedure>
If {{m}} is an object created by
@@ -469,6 +502,7 @@ Arrays are a data type distinct from other Scheme data types.
==== Procedures
+===== make-array
<procedure>(make-array interval getter [ setter ])</procedure>
Assume first that the optional argument {{setter}} is not given.
@@ -541,12 +575,15 @@ Example:
(a! 1.0 0 0) => undefined
(a_ 12345 6789) => 0.
(a_ 0 0) => 1.</enscript>
+===== array?
<procedure>(array? obj)</procedure>
Returns {{#t}} if {{obj}} is an array and {{#f}} otherwise.
+===== array-domain
<procedure>(array-domain array)</procedure>
+===== array-getter
<procedure>(array-getter array)</procedure>
If {{array}} is an array built by
@@ -566,14 +603,17 @@ Example:
(a_ 3 3) => 1
(a_ 2 3) => 0
(a_ 11 0) => is an error</enscript>
+===== array-dimension
<procedure>(array-dimension array)</procedure>
Shorthand for {{(interval-dimension (array-domain array))}}. It is an error to call this function if {{array}} is not an array.
+===== mutable-array?
<procedure>(mutable-array? obj)</procedure>
Returns {{#t}} if {{obj}} is a mutable array and {{#f}} otherwise.
+===== array-setter
<procedure>(array-setter array)</procedure>
If {{array}} is an array built by
@@ -593,6 +633,7 @@ With no argument, returns {{#t}} if newly constructed specialized arrays are mut
If {{bool}} is {{#t}} then the next call to {{specialized-array-default-mutable?}} will return {{#t}}; if {{bool}} is {{#f}} then the next call to {{specialized-array-default-mutable?}} will return {{#f}}; otherwise it is an error.
+===== make-specialized-array
<procedure>(make-specialized-array interval [ storage-class generic-storage-class ] [ safe? (specialized-array-default-safe?) ])</procedure>
Constructs a mutable specialized array from its arguments.
@@ -632,16 +673,21 @@ It is an error if the arguments of {{make-specialized-array}} do not satisfy the
(make-specialized-array interval u16-storage-class #f))</enscript>
and then simply call, e.g., {{(make-u16-array (make-interval '#(3 3)))}}.
+===== specialized-array?
<procedure>(specialized-array? obj)</procedure>
Returns {{#t}} if {{obj}} is a specialized-array, and {{#f}} otherwise. A specialized-array is an array.
+===== array-storage-class
<procedure>(array-storage-class array)</procedure>
+===== array-indexer
<procedure>(array-indexer array)</procedure>
+===== array-body
<procedure>(array-body array)</procedure>
+===== array-safe?
<procedure>(array-safe? array)</procedure>
{{array-storage-class}} returns the storage-class of {{array}}. {{array-safe?}} is true if and only if the arguments of {{(array-getter array)}} and {{(array-setter array)}} (including the value to be stored in the array) are checked for correctness.
@@ -654,12 +700,14 @@ Please see [[#make-specialized-array|{{make-specialized-array}}]] for how {{(arr
It is an error to call any of these routines if {{array}} is not a specialized array.
+===== array-elements-in-order?
<procedure>(array-elements-in-order? A)</procedure>
Assumes that {{A}} is a specialized array, in which case it returns {{#t}} if the elements of {{A}} are in order and stored adjacently in {{(array-body A)}} and {{#f}} otherwise.
It is an error if {{A}} is not a specialized array.
+===== specialized-array-share
<procedure>(specialized-array-share array new-domain new-domain->old-domain)</procedure>
Constructs a new specialized array that shares the body of the specialized array {{array}}. Returns an object that is behaviorally equivalent to a specialized array with the following fields:
@@ -709,6 +757,7 @@ It is an error if {{array}} is not a specialized array, or if {{new-domain}} is
;; ((4 4) (4 5) (4 6) (4 7) (4 8))</enscript>
This "shearing" operation cannot be achieved by combining the procedures {{array-extract}}, {{array-translate}}, {{array-permute}}, {{array-translate}}, {{array-curry}}, {{array-reverse}}, and {{array-sample}}.
+===== array-copy
<procedure>(array-copy array [ result-storage-class generic-storage-class ] [ new-domain #f ] [ mutable? (specialized-array-default-mutable?) ] [ safe? (specialized-array-default-safe?) ])</procedure>
Assumes that {{array}} is an array, {{result-storage-class}} is a storage class that can manipulate all the elements of {{array}}, {{new-domain}} is either {{#f}} or an interval with the same volume as {{(array-domain array)}}, and {{mutable?}} and {{safe?}} are booleans.
@@ -726,6 +775,7 @@ It is an error if the arguments do not satisfy these conditions.
'''Note:''' If {{new-domain}} is not the same as {{(array-domain array)}}, one can think of the resulting array as a ''reshaped'' version of {{array}}.
+===== array-curry
<procedure>(array-curry array inner-dimension)</procedure>
If {{array}} is an array whose domain is an interval $[l_0,u_0)\times\cdots\times[l_{d-1},u_{d-1})$, and {{inner-dimension}} is an exact integer strictly between $0$ and $d$, then {{array-curry}} returns an immutable array with domain $[l_0,u_0)\times\cdots\times[l_{d-\text{inner-dimension}-1},u_{d-\text{inner-dimension}-1})$, each of whose entries is in itself an array with domain $[l_{d-\text{inner-dimension}},u_{d-\text{inner-dimension}})\times\cdots\times[l_{d-1},u_{d-1})$.
@@ -825,6 +875,7 @@ Example:
(define curried-a_ (array-getter curried-a))
((array-getter (curried-a_ 3)) 4)
=> (3 4)</enscript>
+===== array-extract
<procedure>(array-extract array new-domain)</procedure>
Returns a new array with the same getter (and setter, if appropriate) of the first argument, defined on the second argument.
@@ -849,6 +900,7 @@ It is an error if the arguments of {{array-extract}} do not satisfy these condit
If {{array}} is a specialized array, the resulting array inherits its mutability and safety from {{array}}.
+===== array-tile
<procedure>(array-tile A S)</procedure>
Assume that {{A}} is an array and {{S}} is a vector of positive, exact integers. The routine {{array-tile}} returns a new immutable array $T$, each entry of which is a subarray of {{A}} whose domain has sidelengths given (mostly) by the entries of {{S}}. These subarrays completely "tile" {{A}}, in the sense that every entry in {{A}} is an entry of precisely one entry of the result $T$.
@@ -861,6 +913,7 @@ If {{A}} is a specialized array, the subarrays of the result inherit safety and
'''Note:''' The routines {{array-tile}} and {{array-curry}} both decompose an array into subarrays, but in different ways. For example, if {{A}} is defined as {{(make-array (make-interval '#(10 10)) list)}}, then {{(array-tile A '#(1 10))}} returns an array with domain {{(make-interval '#(10 1))}}, each element of which is an array with domain {{(make-interval '#(1 10))}} (i.e., a two-dimensional array whose elements are two-dimensional arrays), while {{(array-curry A 1)}} returns an array with domain {{(make-interval '#(10))}}, each element of which has domain {{(make-interval '#(10))}} (i.e., a one-dimensional array whose elements are one-dimensional arrays).
+===== array-translate
<procedure>(array-translate array translation)</procedure>
Assumes that {{array}} is a valid array, {{translation}} is a valid translation, and that the dimensions of the array and the translation are the same. The resulting array will have domain {{(interval-translate (array-domain array) translation)}}.
@@ -909,6 +962,7 @@ that employs the same getter as the original array.
It is an error if the arguments do not satisfy these conditions.
+===== array-permute
<procedure>(array-permute array permutation)</procedure>
Assumes that {{array}} is a valid array, {{permutation}} is a valid permutation, and that the dimensions of the array and the permutation are the same. The resulting array will have domain {{(interval-permute (array-domain array) permutation)}}.
@@ -953,12 +1007,14 @@ Finally, if {{array}} is not a mutable array, then {{array-permute}} returns
(π-1 multi-index))))</enscript>
It is an error to call {{array-permute}} if its arguments do not satisfy these conditions.
+===== array-rotate
<procedure>(array-rotate array dim)</procedure>
Informally, {{(array-rotate array dim)}} rotates the axes of {{array}} {{dim}} places to the left.
More precisely, {{(array-rotate array dim)}} assumes that {{array}} is an array and {{dim}} is an exact integer between 0 (inclusive) and {{(array-dimension array)}} (exclusive). It computes the permutation {{(vector dim ... (- (array-dimension array) 1) 0 ... (- dim 1))}} (unless {{dim}} is zero, in which case it constructs the identity permutation) and returns {{(array-permute array permutation)}}. It is an error if the arguments do not satisfy these conditions.
+===== array-reverse
<procedure>(array-reverse array #!optional flip?)</procedure>
We assume that {{array}} is an array and {{flip?}}, if given, is a vector of booleans whose length is the same as the dimension of {{array}}. If {{flip?}} is not given, it is set to a vector with length the same as the dimension of {{array}}, all of whose elements are {{#t}}.
@@ -1041,6 +1097,7 @@ The following example using {{array-reverse}} was motivated by [[https://funcall
(palindrome? "abba") => #t
(palindrome? "abca") => #f
(palindrome? "abbc") => #f</enscript>
+===== array-sample
<procedure>(array-sample array scales)</procedure>
We assume that {{array}} is an array all of whose lower bounds are zero, and {{scales}} is a vector of positive exact integers whose length is the same as the dimension of {{array}}.
@@ -1080,6 +1137,7 @@ Finally, if {{array}} is immutable, then {{array-sample}} returns
(map * multi-index (vector->list scales)))))</enscript>
It is an error if {{array}} and {{scales}} don't satisfy these requirements.
+===== array-outer-product
<procedure>(array-outer-product op array1 array2)</procedure>
Implements the outer product of {{array1}} and {{array2}} with the operator {{op}}, similar to the APL function with the same name.
@@ -1097,6 +1155,7 @@ This operation can be considered a partial inverse to {{array-curry}}. It is an
This implies that if {{(array-getter A)}} is expensive to compute (for example, if it's returning an array, as does {{array-curry}}) then the elements of {{A}} should be pre-computed if necessary and stored in a specialized array, typically using {{array-copy}}, before that specialized array is passed as an argument to {{array-outer-product}}. In the examples below, the code for Gaussian elimination applies {{array-outer-product}} to shared specialized arrays, which are of course themselves specialized arrays; the code for matrix multiplication and {{inner-product}} applies {{array-outer-product}} to curried arrays, so we apply {{array-copy}} to the arguments before passage to {{array-outer-product}}.
+===== array-map
<procedure>(array-map f array . arrays)</procedure>
If {{array}}, {{(car arrays)}}, ... all have the same domain and {{f}} is a procedure, then {{array-map}} returns a new immutable array with the same domain and getter
@@ -1132,6 +1191,7 @@ or even
(let ((a_ (array-getter a)))
(lambda (i)
(+ (a_ i) i))))</enscript>
+===== array-for-each
<procedure>(array-for-each f array . arrays)</procedure>
If {{array}}, {{(car arrays)}}, ... all have the same domain and {{f}} is an appropriate procedure, then {{array-for-each}} calls
@@ -1158,6 +1218,7 @@ It is expected that {{array-map}} and {{array-for-each}} will specialize the con
arrays)))))</enscript>
It is an error to call {{array-for-each}} if its arguments do not satisfy these conditions.
+===== array-fold
<procedure>(array-fold kons knil array)</procedure>
If we use the defining relations for fold over lists from [[https://srfi.schemers.org/srfi-1/|SRFI 1]]:
@@ -1172,6 +1233,7 @@ then {{(array-fold kons knil array)}} returns
(fold kons knil (array->list array))
It is an error if {{array}} is not an array, or if {{kons}} is not a procedure.
+===== array-fold-right
<procedure>(array-fold-right kons knil array)</procedure>
If we use the defining relations for fold-right over lists from [[https://srfi.schemers.org/srfi-1/|SRFI 1]]:
@@ -1185,6 +1247,7 @@ then {{(array-fold-right kons knil array)}} returns
(fold-right kons knil (array->list array))
It is an error if {{array}} is not an array, or if {{kons}} is not a procedure.
+===== array-reduce
<procedure>(array-reduce op A)</procedure>
We assume that {{A}} is an array and {{op}} is a procedure of two arguments that is associative, i.e., {{(op (op x y) z)}} is the same as {{(op x (op y z))}}.
@@ -1224,6 +1287,7 @@ We find with $m=1{,}000{,}000{,}000$:
(block-sum A) => 1.6449340658482325</enscript>
Since $\pi^2/6\approx{}${{1.6449340668482264}}, we see using the first method that the difference $\pi^2/6-{}${{1.644934057834575}}${}\approx{}${{9.013651380840315e-9}} and with the second we have $\pi^2/6-{}${{1.6449340658482325}}${}\approx{}${{9.99993865491433e-10}}. The true difference should be between $\frac 1{1{,}000{,}000{,}001}\approx{}${{9.99999999e-10}} and $\frac 1{1{,}000{,}000{,}000}={}${{1e-9}}. The difference for the first method is about 10 times too big, and, in fact, will not change further because any further terms, when added to the partial sum, are too small to increase the sum after rounding-to-nearest in double-precision IEEE-754 floating-point arithmetic.
+===== array-any
<procedure>(array-any pred array1 array2 ...)</procedure>
Assumes that {{array1}}, {{array2}}, etc., are arrays, all with the same domain, which we'll call {{interval}}. Also assumes that {{pred}} is a procedure that takes as many arguments as there are arrays and returns a single value.
@@ -1240,6 +1304,7 @@ The functions {{(array-getter array1)}}, etc., are applied only to those values
It is an error if the arguments do not satisfy these assumptions.
+===== array-every
<procedure>(array-every pred array1 array2 ...)</procedure>
Assumes that {{array1}}, {{array2}}, etc., are arrays, all with the same domain, which we'll call {{interval}}. Also assumes that {{pred}} is a procedure that takes as many arguments as there are arrays and returns a single value.
@@ -1256,12 +1321,14 @@ The functions {{(array-getter array1)}}, etc., are applied only to those values
It is an error if the arguments do not satisfy these assumptions.
+===== array->list
<procedure>(array->list array)</procedure>
Stores the elements of {{array}} into a newly allocated list in lexicographical order. It is an error if {{array}} is not an array.
It is guaranteed that {{(array-getter array)}} is called precisely once for each multi-index in {{(array-domain array)}} in lexicographical order.
+===== list->array
<procedure>(list->array l domain [ result-storage-class generic-storage-class ] [ mutable? (specialized-array-default-mutable?) ] [ safe? (specialized-array-default-safe?) ])</procedure>
Assumes that {{l}} is an list, {{domain}} is an interval with volume the same as the length of {{l}}, {{result-storage-class}} is a storage class that can manipulate all the elements of {{l}}, and {{mutable?}} and {{safe?}} are booleans.
@@ -1270,6 +1337,7 @@ Returns a specialized array with domain {{domain}} whose elements are the elemen
It is an error if the arguments do not satisfy these assumptions, or if any element of {{l}} cannot be stored in the body of {{result-storage-class}}, and this last error shall be detected and raised.
+===== array-assign!
<procedure>(array-assign! destination source)</procedure>
Assumes that {{destination}} is a mutable array and {{source}} is an array, and that the elements of {{source}} can be stored into {{destination}}.
@@ -1284,6 +1352,7 @@ If assigning any element of {{destination}} affects the value of any element of
'''Note:''' If the domains of {{destination}} and {{source}} are not the same, one can think of {{destination}} as a ''reshaped'' copy of {{source}}.
+===== array-ref
<procedure>(array-ref A i0 . i-tail)</procedure>
Assumes that {{A}} is an array, and every element of {{(cons i0 i-tail)}} is an exact integer.
@@ -1292,6 +1361,7 @@ Returns {{(apply (array-getter A) i0 i-tail)}}.
It is an error if {{A}} is not an array, or if the number of arguments specified is not the correct number for {{(array-getter A)}}.
+===== array-set!
<procedure>(array-set! A v i0 . i-tail)</procedure>
Assumes that {{A}} is a mutable array, that {{v}} is a value that can be stored within that array, and that every element of {{(cons i0 i-tail)}} is an exact integer.
@@ -1304,6 +1374,7 @@ It is an error if {{A}} is not a mutable array, if {{v}} is not an appropriate v
'''Note:''' In the sample implementation, checking whether the multi-indices are exact integers and within the domain of the array, and checking whether the value is appropriate for storage into the array, is delegated to the underlying definition of the array argument. If the first argument is a safe specialized array, then these items are checked; if it is an unsafe specialized array, they are not. If it is a generalized array, it is up to the programmer whether to define the getter and setter of the array to check the correctness of the arguments.
+===== specialized-array-reshape
<procedure>(specialized-array-reshape array new-domain [ copy-on-failure? #f ])</procedure>
Assumes that {{array}} is a specialized array, {{new-domain}} is an interval with the same volume as {{(array-domain array)}}, and {{copy-on-failure?}}, if given, is a boolean.