[Matrix-SIG] Numerical python on SourceForge?

skaller skaller@maxtal.com.au
Mon, 10 Jan 2000 02:42:04 +1100


Travis Oliphant wrote:
> 
> >
> > - What parts? Is it important to be compatible with jpython or viper?
> >   If nD-arrays go into the core, become they part of the language?
> 
> My vote is to eliminate Python Numeric Types and make them all rank-0
> arrays.  This would possibly involve changing rank-0 arrays in Numeric so
> that don't have so much overhead. 

	No. This is wrong.
From the Fish tutorial, where #= means 'same shape':

--------- array shape combinators ---------------
     zerodim sh #= {:sh} 
     undim {:int_shape } #= int_shape 
     succdim 7 {6:sh} #= {7,6:sh} 
     lendim {3,2:sh } = 3 
     preddim {3,2:sh } #= {2:sh} 
     numdim {4,3:sh} = 2 
---------------------------------------------------

Here, 'fill .. with' is used to initialise an array:

---------------------------------------------------
 >-|> let a3 = fill {:int_shape} with [5];;
 a3 : [int]
 #a3 = { : int_shape } 

defines a zero dimensional array. 
Just as a one dimensional array can be thought of as a line segment, or
vector, 
a zero dimensional array can be construed a point with a single
associated value. 
Such arrays should not be confused with the value of its unique entry
(which has a different
type) nor with the vector of length one, namely 

 >-|> let a4 = fill {1:int_shape} with [5];;
 a4 : [int]
 #a4 = { 1 : int_shape } 
-----------------------------------------------------

PLEASE NOTE: a scalar is NOT a rank zero array.
Fish provides a 'get' function to get the single value
of a zero dimensional array.

The point is: there is no need to identify python
floats with a rank 0 array of float, in fact such identification
is WRONG. There is a distinct difference between
these two types, even though they are isomorphic
(and also isomorphic to a rank 1 array of dimension 1)

It is very important to get the shape calculus exactly right.
The Fish type/shape system was developed by one of the worlds
leading categories-in-computing theorists, Barry Jay.

In particular, the fears that the overhead of rank-0 NumPy
arrays are too high to identify them with Python numeric
scalars are unfounded, because the identification
itself is incorrect. 

The right way to do this is as follows: in Python,
every 'scalar' type has a type object. We need a corresponding
'shape' object -- we can probably use the type object for this.
For arrays, the shape must consist of a list of lists of integers
and a scalar shape:

	mk_shape([[7,6],[3,4]],FloatType)

or, 

	mk_shape(([7,6],[3,4]], "F") # "F" for float

or, alternatively, a list of integers and
any shape:

	mk_shape([7,6], mk_shape([3,4], FloatShape))

Note that the second form would require scalar shape objects,
whereas the first will work with ordinary type objects
or perhaps a string code.

------------------------------------------
See
	http://www-staff.mcs.uts.edu.au/~cbj/FISh/

for more information on Fish and array shape calculus.

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850