Hi everyone,
I finally got around to writing my affine indexing package, called affi. It is ASDF-installable, and has a tutorial.
Highlights:
- an affine index class that allows the implementation of array slices, index permutations, reverse indexing, all provided via convenience functions - an iterator driver for iter - support for column-major affine indexes too (make-affi-cm)
- map-subarray, a convenience function for mapping arrays, which is also a proof of concept (you can do all kinds of fancy operations using iter, for example)
Examples (when the target is nil, a new array is created):
AFFI> *m* ;; the original array #2A((0 1 2 3) (4 5 6 7) (8 9 10 11)) AFFI> (map-subarray *m* nil :permutation '(1 0)) ;; transpose #2A((0 4 8) (1 5 9) (2 6 10) (3 7 11)) AFFI> (map-subarray *m* nil :source-range '(all 1)) ;; 2nd column #(1 5 9) AFFI> (map-subarray *m* nil :source-range '(all 1) :drop-which nil) #2A((1) (5) (9)) AFFI> (map-subarray *m* nil :source-range '((1 2) rev)) #2A((7 6 5 4) (11 10 9 8))
The package is enough for my present purposes, but I am happy to include new features if you can think of them. Presently it is not super-optimized, I will do that once the interface stabilizes (it is not slow of course).
Note that this package is orthogonal to the ffa package, neither depends on the other. So even if you don't like ffa, you can still benefit from fancy array slicing.
I would appreciate comments and suggestions,
Tamas
Tamas,
Very interesting. Does this map onto the GSL notion of views in any way, even conceptually? I know we discussed this before, I'm just wondering if a restricted set of affine indices could be used with GSL.
Liam
On Sun, May 18, 2008 at 12:30 PM, Tamas K Papp tpapp@princeton.edu wrote:
Hi everyone,
I finally got around to writing my affine indexing package, called affi. It is ASDF-installable, and has a tutorial.
Highlights:
- an affine index class that allows the implementation of array
slices, index permutations, reverse indexing, all provided via convenience functions
an iterator driver for iter
support for column-major affine indexes too (make-affi-cm)
map-subarray, a convenience function for mapping arrays, which is
also a proof of concept (you can do all kinds of fancy operations using iter, for example)
Examples (when the target is nil, a new array is created):
AFFI> *m* ;; the original array #2A((0 1 2 3) (4 5 6 7) (8 9 10 11)) AFFI> (map-subarray *m* nil :permutation '(1 0)) ;; transpose #2A((0 4 8) (1 5 9) (2 6 10) (3 7 11)) AFFI> (map-subarray *m* nil :source-range '(all 1)) ;; 2nd column #(1 5 9) AFFI> (map-subarray *m* nil :source-range '(all 1) :drop-which nil) #2A((1) (5) (9)) AFFI> (map-subarray *m* nil :source-range '((1 2) rev)) #2A((7 6 5 4) (11 10 9 8))
The package is enough for my present purposes, but I am happy to include new features if you can think of them. Presently it is not super-optimized, I will do that once the interface stabilizes (it is not slow of course).
Note that this package is orthogonal to the ffa package, neither depends on the other. So even if you don't like ffa, you can still benefit from fancy array slicing.
I would appreciate comments and suggestions,
Tamas
Gsll-devel mailing list Gsll-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel
Hi Liam,
On Tue, May 20, 2008 at 06:07:14PM -0400, Liam Healy wrote:
Very interesting. Does this map onto the GSL notion of views in any way, even conceptually? I know we discussed this before, I'm just wondering if a restricted set of affine indices could be used with GSL.
Yes, I think it does allow the handling of GSL's views, including
- matrix views (GSL has i*tda+j, which is an affine mapping, so we can use submatrix views, etc)
- vector views on a matrix (row, column, or contiguous subviews of those)
But affi allows much more, including views of multidimensional arrays, or implementing a transpose or index permutation with "views". You can even do an affi that traces out the diagonal of a matrix... The possibilities are endless.
I have to admit that I don't have a very good understanding on how and where GSL uses views, so at this point I can't offer my thoughts on how to best integrate this with the semantincs GSLL if you want to, especially if you want to do it in a Lispy manner and not merely mirroring GSL's views. But I am happy to discuss things, or add anything you need to affi.
Best,
Tamas