Changeset 39532 in project


Ignore:
Timestamp:
01/27/21 05:44:35 (5 weeks ago)
Author:
dieggsy
Message:

srfi-179 docs: add links to procedures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/srfi-179

    r39531 r39532  
    152152==== Procedures
    153153
     154===== translation?
    154155<procedure>(translation? object)</procedure>
    155156
    156157Returns {{#t}} if {{object}} is a translation, and {{#f}} otherwise.
    157158
     159===== permutation?
    158160<procedure>(permutation? object)</procedure>
    159161
     
    168170==== Procedures
    169171
     172===== make-interval
    170173<procedure>(make-interval arg1 #!optional arg2)</procedure>
    171174
     
    179182for $0\leq i<{}${{(vector-length lower-bounds)}}. It is an error if {{lower-bounds}} and {{upper-bounds}} do not satisfy these conditions.
    180183
     184===== interval?
    181185<procedure>(interval? obj)</procedure>
    182186
    183187Returns {{#t}} if {{obj}} is an interval, and {{#f}} otherwise.
    184188
     189===== interval-dimension
    185190<procedure>(interval-dimension interval)</procedure>
    186191
     
    190195then {{interval-dimension}} returns {{(vector-length lower-bounds)}}. It is an error to call {{interval-dimension}} if {{interval}} is not an interval.
    191196
     197===== interval-lower-bound
    192198<procedure>(interval-lower-bound interval i)</procedure>
    193199
     200===== interval-upper-bound
    194201<procedure>(interval-upper-bound interval i)</procedure>
    195202
     
    204211then {{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.
    205212
     213===== interval-lower-bounds->list
    206214<procedure>(interval-lower-bounds->list interval)</procedure>
    207215
     216===== interval-upper-bounds->list
    208217<procedure>(interval-upper-bounds->list interval)</procedure>
    209218
     
    214223then {{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.
    215224
     225===== interval-lower-bounds->vector
    216226<procedure>(interval-lower-bounds->vector interval)</procedure>
    217227
     228===== interval-upper-bounds->vector
    218229<procedure>(interval-upper-bounds->vector interval)</procedure>
    219230
     
    223234then {{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.
    224235
     236===== interval-volume
    225237<procedure>(interval-volume interval)</procedure>
    226238
     
    233245It is an error to call {{interval-volume}} if {{interval}} does not satisfy this condition.
    234246
     247===== interval=
    235248<procedure>(interval= interval1 interval2)</procedure>
    236249
     
    246259It is an error to call {{interval=}} if {{interval1}} or {{interval2}} do not satisfy this condition.
    247260
     261===== interval-subset?
    248262<procedure>(interval-subset? interval1 interval2)</procedure>
    249263
     
    256270for all $0\leq j<d$, otherwise it returns {{#f}}. It is an error if the arguments do not satisfy these conditions.
    257271
     272===== interval-contains-multi-index?
    258273<procedure>(interval-contains-multi-index? interval index-0 index-1 ...)</procedure>
    259274
     
    266281It is an error to call {{interval-contains-multi-index?}} if {{interval}} and {{index-0}},..., do not satisfy this condition.
    267282
     283===== interval-projections
    268284<procedure>(interval-projections interval right-dimension)</procedure>
    269285
     
    303319It is an error to call {{interval-projections}} if its arguments do not satisfy these conditions.
    304320
     321===== interval-for-each
    305322<procedure>(interval-for-each f interval)</procedure>
    306323
     
    309326{{interval-for-each}} calls {{f}} with each multi-index of {{interval}} as arguments, all in lexicographical order.
    310327
     328===== interval-dilate
    311329<procedure>(interval-dilate interval lower-diffs upper-diffs)</procedure>
    312330
     
    330348 (make-interval '#(100 100))
    331349 '#(0 0) '#(-500 -50)) => error</enscript>
     350===== interval-intersect
    332351<procedure>(interval-intersect interval-1 interval-2 ...)</procedure>
    333352
     
    336355It is an error if the arguments are not all intervals with the same dimension.
    337356
     357===== interval-translate
    338358<procedure>(interval-translate interval translation)</procedure>
    339359
     
    342362One could define {{(interval-translate interval translation)}} by {{(interval-dilate interval translation translation)}}.
    343363
     364===== interval-permute
    344365<procedure>(interval-permute interval permutation)</procedure>
    345366
     
    352373For 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)$.
    353374
     375===== interval-rotate
    354376<procedure>(interval-rotate interval dim)</procedure>
    355377
     
    358380More 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.
    359381
     382===== interval-scale
    360383<procedure>(interval-scale interval scales)</procedure>
    361384
     
    364387It is an error if {{interval}} and {{scales}} do not satisfy this condition.
    365388
     389===== interval-cartesian-product
    366390<procedure>(interval-cartesian-product interval . intervals)</procedure>
    367391
     
    378402==== Procedures
    379403
     404===== make-storage-class
    380405<procedure>(make-storage-class getter setter checker maker copier length default)</procedure>
    381406
     
    392417Note that we assume that {{getter}} and {{setter}} generally take ''O''(1) time to execute.
    393418
     419===== storage-class?
    394420<procedure>(storage-class? m)</procedure>
    395421
    396422Returns {{#t}} if {{m}} is a storage class, and {{#f}} otherwise.
    397423
     424===== storage-class-getter
    398425<procedure>(storage-class-getter m)</procedure>
    399426
     427===== storage-class-setter
    400428<procedure>(storage-class-setter m)</procedure>
    401429
     430===== storage-class-checker
    402431<procedure>(storage-class-checker m)</procedure>
    403432
     433===== storage-class-maker
    404434<procedure>(storage-class-maker m)</procedure>
    405435
     436===== storage-class-copier
    406437<procedure>(storage-class-copier m)</procedure>
    407438
     439===== storage-class-length
    408440<procedure>(storage-class-length m)</procedure>
    409441
     442===== storage-class-default
    410443<procedure>(storage-class-default m)</procedure>
    411444
     
    470503==== Procedures
    471504
     505===== make-array
    472506<procedure>(make-array interval getter [ setter ])</procedure>
    473507
     
    542576(a_ 12345 6789)  => 0.
    543577(a_ 0 0) => 1.</enscript>
     578===== array?
    544579<procedure>(array? obj)</procedure>
    545580
    546581Returns {{#t}} if {{obj}} is an array and {{#f}} otherwise.
    547582
     583===== array-domain
    548584<procedure>(array-domain array)</procedure>
    549585
     586===== array-getter
    550587<procedure>(array-getter array)</procedure>
    551588
     
    567604(a_ 2 3) => 0
    568605(a_ 11 0) => is an error</enscript>
     606===== array-dimension
    569607<procedure>(array-dimension array)</procedure>
    570608
    571609Shorthand for {{(interval-dimension (array-domain array))}}. It is an error to call this function if {{array}} is not an array.
    572610
     611===== mutable-array?
    573612<procedure>(mutable-array? obj)</procedure>
    574613
    575614Returns {{#t}} if {{obj}} is a mutable array and {{#f}} otherwise.
    576615
     616===== array-setter
    577617<procedure>(array-setter array)</procedure>
    578618
     
    594634If {{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.
    595635
     636===== make-specialized-array
    596637<procedure>(make-specialized-array interval [ storage-class generic-storage-class ] [ safe? (specialized-array-default-safe?) ])</procedure>
    597638
     
    633674and then simply call, e.g., {{(make-u16-array (make-interval '#(3 3)))}}.
    634675
     676===== specialized-array?
    635677<procedure>(specialized-array? obj)</procedure>
    636678
    637679Returns {{#t}} if {{obj}} is a specialized-array, and {{#f}} otherwise. A specialized-array is an array.
    638680
     681===== array-storage-class
    639682<procedure>(array-storage-class array)</procedure>
    640683
     684===== array-indexer
    641685<procedure>(array-indexer array)</procedure>
    642686
     687===== array-body
    643688<procedure>(array-body array)</procedure>
    644689
     690===== array-safe?
    645691<procedure>(array-safe? array)</procedure>
    646692
     
    655701It is an error to call any of these routines if {{array}} is not a specialized array.
    656702
     703===== array-elements-in-order?
    657704<procedure>(array-elements-in-order? A)</procedure>
    658705
     
    661708It is an error if {{A}} is not a specialized array.
    662709
     710===== specialized-array-share
    663711<procedure>(specialized-array-share array new-domain new-domain->old-domain)</procedure>
    664712
     
    710758This "shearing" operation cannot be achieved by combining the procedures {{array-extract}}, {{array-translate}}, {{array-permute}}, {{array-translate}}, {{array-curry}}, {{array-reverse}}, and {{array-sample}}.
    711759
     760===== array-copy
    712761<procedure>(array-copy array [ result-storage-class generic-storage-class ] [ new-domain #f ] [ mutable? (specialized-array-default-mutable?) ] [ safe? (specialized-array-default-safe?) ])</procedure>
    713762
     
    727776'''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}}.
    728777
     778===== array-curry
    729779<procedure>(array-curry array inner-dimension)</procedure>
    730780
     
    826876((array-getter (curried-a_ 3)) 4)
    827877                    => (3 4)</enscript>
     878===== array-extract
    828879<procedure>(array-extract array new-domain)</procedure>
    829880
     
    850901If {{array}} is a specialized array, the resulting array inherits its mutability and safety from {{array}}.
    851902
     903===== array-tile
    852904<procedure>(array-tile A S)</procedure>
    853905
     
    862914'''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).
    863915
     916===== array-translate
    864917<procedure>(array-translate array translation)</procedure>
    865918
     
    910963It is an error if the arguments do not satisfy these conditions.
    911964
     965===== array-permute
    912966<procedure>(array-permute array permutation)</procedure>
    913967
     
    9541008It is an error to call {{array-permute}} if its arguments do not satisfy these conditions.
    9551009
     1010===== array-rotate
    9561011<procedure>(array-rotate array dim)</procedure>
    9571012
     
    9601015More 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.
    9611016
     1017===== array-reverse
    9621018<procedure>(array-reverse array #!optional flip?)</procedure>
    9631019
     
    10421098(palindrome? "abca") => #f
    10431099(palindrome? "abbc") => #f</enscript>
     1100===== array-sample
    10441101<procedure>(array-sample array scales)</procedure>
    10451102
     
    10811138It is an error if {{array}} and {{scales}} don't satisfy these requirements.
    10821139
     1140===== array-outer-product
    10831141<procedure>(array-outer-product op array1 array2)</procedure>
    10841142
     
    10981156This 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}}.
    10991157
     1158===== array-map
    11001159<procedure>(array-map f array . arrays)</procedure>
    11011160
     
    11331192              (lambda (i)
    11341193                (+ (a_ i) i))))</enscript>
     1194===== array-for-each
    11351195<procedure>(array-for-each f array . arrays)</procedure>
    11361196
     
    11591219It is an error to call {{array-for-each}} if its arguments do not satisfy these conditions.
    11601220
     1221===== array-fold
    11611222<procedure>(array-fold kons knil array)</procedure>
    11621223
     
    11731234It is an error if {{array}} is not an array, or if {{kons}} is not a procedure.
    11741235
     1236===== array-fold-right
    11751237<procedure>(array-fold-right kons knil array)</procedure>
    11761238
     
    11861248It is an error if {{array}} is not an array, or if {{kons}} is not a procedure.
    11871249
     1250===== array-reduce
    11881251<procedure>(array-reduce op A)</procedure>
    11891252
     
    12251288Since $\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.
    12261289
     1290===== array-any
    12271291<procedure>(array-any pred array1 array2 ...)</procedure>
    12281292
     
    12411305It is an error if the arguments do not satisfy these assumptions.
    12421306
     1307===== array-every
    12431308<procedure>(array-every pred array1 array2 ...)</procedure>
    12441309
     
    12571322It is an error if the arguments do not satisfy these assumptions.
    12581323
     1324===== array->list
    12591325<procedure>(array->list array)</procedure>
    12601326
     
    12631329It is guaranteed that {{(array-getter array)}} is called precisely once for each multi-index in {{(array-domain array)}} in lexicographical order.
    12641330
     1331===== list->array
    12651332<procedure>(list->array l domain [ result-storage-class generic-storage-class ] [ mutable? (specialized-array-default-mutable?) ] [ safe? (specialized-array-default-safe?) ])</procedure>
    12661333
     
    12711338It 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.
    12721339
     1340===== array-assign!
    12731341<procedure>(array-assign! destination source)</procedure>
    12741342
     
    12851353'''Note:''' If the domains of {{destination}} and {{source}} are not the same, one can think of {{destination}} as a ''reshaped'' copy of {{source}}.
    12861354
     1355===== array-ref
    12871356<procedure>(array-ref A i0 . i-tail)</procedure>
    12881357
     
    12931362It 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)}}.
    12941363
     1364===== array-set!
    12951365<procedure>(array-set! A v i0 . i-tail)</procedure>
    12961366
     
    13051375'''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.
    13061376
     1377===== specialized-array-reshape
    13071378<procedure>(specialized-array-reshape array new-domain [ copy-on-failure? #f ])</procedure>
    13081379
Note: See TracChangeset for help on using the changeset viewer.