[Gsll-devel] announcement: affi (affine indexing)

Tamas K Papp tpapp at Princeton.EDU
Sun May 18 16:30:35 UTC 2008


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




More information about the gsll-devel mailing list