[squeak-dev] Re: Scientific Squeak

nice ncellier at ifrance.com
Sat Apr 19 18:36:01 UTC 2008


Danny Chan wrote:
> 
> Sounds interesting. There are two things I need in a matrix package, I would 
> be interested if this can be done with Smallapack:
> 
> I need the ability to generate views into a data set like it is possible in 
> python or Matlab. For example, in python I can do something like this to raw 
> image data in a 2 dimensional matrix:
> 
> # selects a sub matrix containing every second pixel in each dimension
> redChannel = image[::2, ::2]               
> # selects a square of 50 pixels in the top left of the image
> topLeft = redChannel[0:50, 0:50]
> 
> Each of the sub matrices is a view into the data and does not copy values.
> 

It is possible to access an arbitrary sequence or rows.
Also possible to access an arbitrary sequence of columns.
So, you can do it in two stages by now. (Easy to enhance).
Also, message names are different depending on the type of argument.
	aMatrix atRow: anInteger.
	aMatrix atRows: aCollection.
I once tried generalized access messages to unify this, but used triple 
dispatching at that time to handle generalizedAt:and:put:, something 
quite horrible. I would tend to reify rows and columns accessors if i 
had to implement it today.

Current implementation is to answer a copy like matlab.
However, it is easy to implement some kind of viewport object not 
creating a copy if that is what you want.

There is no specific language in Smallapack, so you won't get these 
short array notations, unless you implement your own language and 
interpreter.

> Another thing I need quite often is the ability to change the interpretaion of 
> the matrix data buffer on the fly. In python:
> 
> # charData is an array with n elements of type char
> charData.dtype = dtype('int16')
> # now charData is an array with n/2 elements of type short, interpreting the 
> sequence of two bytes as one short
> 
> 
> If this is not possible, what would be needed to make Smallapack support this? 
> 
> Danny
> 

Smallapack supports only Floating point datatypes of Lapack (float, 
double, float complex, double complex).
It was intended to perform linear algebra, not image processing.

As for the cast hack, I used such horrible thing in Smallapack to 
extract real part of a complex matrix, pretending they were just made of 
twice many reals...

It is possible to extend Smallapack to handle int, it is just a matter 
of implementing a subclass.
But there is no fast primitive for int implemented in BLAS/LAPACK.
However, quite sure BitBlt is already addressing the problem.

Cheers

Nicolas




More information about the Squeak-dev mailing list