On 10/12/2012, at 12:27 AM, srean wrote: > I will draw your attention to what Numpy folks call broadcasting, Ufuncs and > indexing functions
There are two separate issues in Felix: static and dynamic. If you're in dynamic land, like NumPy, then, lacking dependent typing, Felix would just have to do things the same kind of way as other dynamic systems. Eg if you're using darrays or bsarrays with dynamic sizes in Felix. Felix can then already do every thing NumPy can do. For example map f a turns f into a "ufunc". no need for special technology. Indexing arrays doesn't need any complex rules either: fun (i:int) => a . (f i) already does it. A lot of NumPy technology has to reinvent the wheel which is stock standard in FPLs: closures, mapping, etc. Specific functions, eg indexing triangular matrices dynamically, will have to await use cases (because there's too many and we need at least one use case to test with). > http://docs.scipy.org/doc/numpy/reference/ufuncs.html#broadcasting >From what I can gather, a ufunc is an array functor. In FPL that's done by map: map f a => array a with element e replaced by f e so basically all functions are already ufuncs. It would be easy enough to self-map, eg get rid of the "map" keyword. however its not clear that's desirable. For example matrix multiplication is not an elementwise mapping. The broadcasting rules are problematic. For static typing, we have embeddings, eg double => double ^ 1 // scalar to array of one and broadcasting is roughly extension double ^ 1 => double ^ 20 In a static typing context all such changes should have to be explicit. At the moment, Felix uses a coercion for shape changes. It only allows functorially sound coercions such as: double ^ 20 ^ 20 => double ^ (20 * 20) // convert array of arrays to linear array with tuple index corresponding to the usual indexing rules. Using a universal coercion operator here is not so good, named operator with various "danger" levels might be better. Eg changing 20 x 20 array to 10 x 10 array is nonsense but memory safe. > I wanted to give a few examples of how a typical multidimensional indexing > use cases look like > > https://github.com/ppham/skc-python/blob/e679c20967ae97d30c38a282597f30bb2f9a92d5/skc_utils.py#L148 > > https://github.com/alleveenstra/paithon/blob/4aa40ca4e0306fdaba3ce501f00b97fb466b3a96/collaborativefiltering.py#L61 > > https://github.com/neurospin/nipy/blob/1989e79ba73b0a059a1601fa8a5b049496d7da31/nipy/neurospin/clustering/imm.py#L388 > > from > https://github.com/pmeier82/Neural-Simulation/blob/9cb4103a454d1b8a1fd9fd18c6324c7a32973170/nsim/math/math3d.py#L402 > Cool, thanks! My inclination for dynamics is to make the user just write out stuff long hand and then try to simplify pieces, seeking a suitable abstraction and DSSL. A core problem is that such abstractions are context dependent, eg matrix multiplication is different to element wise array multiplication. We already have actual maths for tensors, with concepts like inner and outer products, so that kind of theory is worth supporting because we know in advance it has great utility and should scale. Whereas a lot of matrix operations are very specific to rank and rank 3. For example quaternions are useful in 3d space, but the abstraction is specific to 3d. A high level abstraction is module theory (subsumes vector spaces). But then you run into all sorts of things, classifying modules, some classes lose various properties. Matrices, for example, already lose symmetry (x * y != y * x). -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language