I&#39;ve got more of the multidimensional array code prototyped and I&#39;ll put it up on GitHub (<a href="http://github.com/DrDoug/numeric/tree/master">http://github.com/DrDoug/numeric/tree/master</a>). The interface elements are shown below:<br>
<br>(provide object u8 u16 u32 u64 s8 s16 s32 s64 f32 f64 cf32 cf64)<br><br>(provide/contract<br> (vtype?<br>  (-&gt; any/c boolean?))<br> (array?<br>  (-&gt; any/c boolean?))<br> (array-shape<br>  (-&gt; array? (listof exact-nonnegative-integer?)))<br>
 (array-type<br>  (-&gt; array? vtype?))<br> (array-order<br>  (-&gt; array? (symbols &#39;row &#39;column)))<br> (array-n-dim<br>  (-&gt; array? exact-nonnegative-integer?))<br> (array-size<br>  (-&gt; array? exact-nonnegative-integer?))<br>
 (describe-array<br>  (-&gt; array? void?))<br> (make-array<br>  (-&gt;* ((listof exact-nonnegative-integer?))<br>       (#:type (or/c vtype? symbol?)<br>        #:order (symbols &#39;row &#39;column)<br>        #:fill any/c)<br>
       array?))<br> (build-array<br>  (-&gt;* ((listof exact-nonnegative-integer?)<br>        procedure?)<br>       (#:type (or/c vtype? symbol?)<br>        #:order (symbols &#39;row &#39;column))<br>       array?))<br> (arange<br>
  (-&gt;* (exact-nonnegative-integer?)<br>       (#:type (or/c vtype? symbol?)<br>        #:order (symbols &#39;row &#39;column))<br>       array?))<br> (transpose<br>  (-&gt; array? array?))<br> (reshape<br>  (-&gt; array? (listof exact-nonnegative-integer?) array?))<br>
 (array-ref<br>  (-&gt;* (array?) () #:rest (listof exact-nonnegative-integer?) any/c))<br> (array-ref*<br>  (-&gt; array? list? any/c))<br> (real<br>  (-&gt; array? array?))<br> (imag<br>  (-&gt; array? array?))<br> (array-&gt;list<br>
  (-&gt; array? list?))<br> (print-array<br>  (-&gt; array? void?))<br> (list-&gt;array<br>  (-&gt;* (list?)<br>       (#:type (or/c vtype? symbol?)<br>        #:order (symbols &#39;row &#39;column))<br>       array?)))<br>
<br>This is prototype code only. It runs, but with limited error checking (although the contracts catch a lot of errors). I&#39;m sure there are fragile areas.<br><br>There are a couple of SRFIs dealing with arrays, but they aren&#39;t of the same ilk as what we&#39;re looking for here. But, this is somewhat of a superset of those and I should avoid being different just out of ignorance.<br>
<br>Per Scott&#39;s suggestion, I have changed the named of the complex floats from c64 and C128 to cf32 and cf64.<br><br>I have both array-ref and array-ref*. The difference is that array-ref* takes the index specification as a list of indices while array-ref takes the indices as parameters. So, (array-ref some-array i j) is equivalent to (array-ref* some-array (list i j)). I&#39;ve found both to be convenient. I&#39;m also open to alternatives.<br>
<br>I&#39;ve added slicing to array ref (and array-ref*). A slice specifies a subarray. So: if we define an array, a:<br><br>(define a (reshape (arange 12) &#39;(3 4))) ;; Creates a 3 x 4 array with a[0,0] = 0, a[0,1] = 1, ..., a[2.3] = 11<br>
<br>a = [[0 1 2 3]<br>       [4 5 6 7]<br>       [8 9 10 11]]<br><br>then (array-ref* a &#39;(0 1)) -&gt; 1, while (array-ref* a &#39;(* 3)) is the 4th column of a and is [3 7 11] and (array-ref* a &#39;(1 *)) is the 2nd row of a and id [4 5 6 7].<br>
<br>An index can also specify indices as (start stop step). So, (array-ref a &#39;(1 (1 * 2))) is every second column starting with index 1 of the first row of a and is [5 7].<br><br>Some examples of index ranges are:<br>
(1), which is equivalent to (1 * *), is index 1 through the last index with a step of 1 (the default)<br>(1 4) is index 1 through 4 with a step of 1<br>(1 * 2) is index 1 through the last index with a step of 2.<br>(* * 2) is every second index starting with 0<br>
<br>This is concise, but maybe not obvious. Also. it differs from the in-range sequence when maybe it should follow that. Some others might prefer a more verbose, but more readable alternative - maybe (#:start 1 #:step 2). Comments are welcome.<br>
<br>So, array-ref can either return a scalar (if the indices are fully specified) or a subarray.<br><br>There are a number of functions to construct arrays: make-array, build-array, arange, and list-&gt; array. [With immutability, the primitive make-array isn&#39;t very useful.]<br>
<br>The functions print-array and describe-array are quick-and-dirty implementations to support the prototyping effort.<br><br>The functions like transpose, reshape, real, imag, and array-list show some of the typical functions we&#39;ll have to provide.<br>
<br>---<br><br>I think it would be good to move this discussion off the general list - unless others want to keep it here. Github has a wiki we can use. It is set up automatically, but I&#39;ve never used it and don&#39;t know how convenient it is. If anyone here has used it in the past let me know if you think it&#39;s a good place to move to. Also, I&#39;ll try to find time to update my Scheme blog with what I&#39;m doing.<br>
<br>As always, comments and suggestions are welcome.<br><br>Doug<br><br>