[plt-dev] flvector

From: Jakub Piotr Cłapa (jpc-ml at zenburn.net)
Date: Sun Dec 20 07:00:59 EST 2009

On 09-12-19 15:54, Matthew Flatt wrote:
> At Fri, 18 Dec 2009 10:02:23 -0700, Doug Williams wrote:
>> Attached is a zip file with some homogeneous vector and array code I was
>> working on in the past. The code in vtype.ss abstracts the definitions of
>> the various SFRI 4 vector types (and regular Scheme vectors). The vector
>> types it knows about are object (i.e., straight Scheme heterogeneous
>> vectors), u(8,16,32,64), s(8,16,32,64), and f(32,64). There are also complex
>> vectors of the numeric types cu(8,16,32,64), cs(8,16,32,64), and cf(32,64).
>> [...]
>> The intent is to provide a homogeneous array implementation similar to the
>> underlying arrays in Matlab (or numpy in Python). This is what I would like
>> to make more efficient and better integrated into the rest of PLT Scheme.
>
> Can you say more about what the arrays are used for?
>
> I can see the use for many flavors of vectors when dealing with foreign
> libraries. But is there another reason to bother with "signed 16-bit
> integer" instead of just using exact integers?

For memory usage, speed and "correctness":

1. The memory footprint of an array of int16 should be lower.
2. If you have two large arrays than performing element-wise 
multiplication using the JITed promitives should be faster than when 
using exact integers.
3. And whats probably the most important: When you test a numerical 
algorithm which will be reimplmeneted in C or assembly (for some DSP 
processor or sth like that) you want the prototype to work with the same 
array types.

>> 2) How would array slicing best look syntactically? I have a simple slicing
>> capability there now so you can see what it looks like. But basically, for
>> any dimension, you can specify a list (start end step) and any element can
>> be wildcarded using * - also, the whole dimension can be wildcarded.
>> Efficient slicing (e.g., no copying required) is an important element of the
>> design.
>
> I'm not sure. I really liked using "domains" in Titanium, but I don't
> have much experience with that kind of construct in other languages.

In Python (and Matlab) you can slice multi-dimensional arrays [1] using 
start, stop and step (stride) values for each axis.

[1] 
http://www.scipy.org/Tentative_NumPy_Tutorial#head-864862d3f2bb4c32f04260fac61eb4ef34788c4c

-- 
regards,
Jakub Piotr Cłapa


Posted on the dev mailing list.