Common Lisp Package: XARRAY

README:

FUNCTION

Public

AS (CLASS OBJECT &REST OPTIONS)

Convert OBJECT to CLASS. May share structure.

CARRAY (ELEMENT-TYPE DIMENSIONS &REST ELEMENTS)

Return a (simple-array element-type dimensions) containing elements, coerced to element-type.

CARRAY* (DIMENSIONS &REST ELEMENTS)

Return a (simple-array element-type dimensions) containing elements, coerced to element-type, where the elemen-type is obtained using numeric-type-classifier.

CM-INDEX (DIMENSIONS SUBSCRIPTS)

Calculate the column-major flat index from subscripts (list of fixnums) and dimensions (list of fixnums). Works in the corner case when dimensions and subscripts are both nil.

CM-SUBSCRIPTS (DIMENSIONS I)

Return the column-major subscripts (list) for flat index i (fixnum), using dimensions (list of fixnums). No error checking, for internal use only. Works in the corner case when dimension is nil.

CVECTOR (ELEMENT-TYPE &REST ELEMENTS)

Return a (simple-array element-type (*)) containing elements, coerced to element-type.

CVECTOR* (&REST ELEMENTS)

Return a (simple-array element-type (*)) containing elements, coerced to element-type, where the elemen-type is obtained using numeric-type-classifier.

DROP (OBJECT)

Return a view with the unit dimensions dropped.

INT-SEQ (A &OPTIONAL B)

Create integer sequence 0,...,a-1 or, if b is given, a,...,b (with a<=b).

ORIGINAL-ANCESTOR (VIEW)

Find the original ancestor (ie the one that is not a view). Simply returns objects which are not views.

RM-INDEX (DIMENSIONS SUBSCRIPTS)

Return a row-major flat index for given subscripts (coerced to a vector, list also accepted), using dimensions (also coerced to a vector, list also accepted). Checks for boundaries and rank.

RM-SUBSCRIPTS (DIMENSIONS I)

Return i decomposed to a list of subscripts, taking dimensions (which is coerced to a vector) as a row-major indexing scheme. No error checking is performed, meant for internal use.

XCOLLECT (N FUNCTION &OPTIONAL (TARGET-SPEC T))

Collect the result of calling function n times into an array (type of target-spec, or determined using xsimilar). Indexing is (i ...), where i is from 0 to n-1. The rest of the indexes are determined from the first value.

XCONCAT (TARGET-TYPE &REST ARGUMENTS)

Concatenate atoms and/or vectors into a vector.

XCREATE-SIMILAR (TARGET-SPEC OBJECT DIMENSIONS &OPTIONAL MORE-OPTIONS)

If TARGET-SPEC is T or (CONS T OPTIONS), use xsimilar to determine target spec using object (and also merge options), otherwise use target-spec directly to create an object. This function is meant for internal use, when mapping functions need to determine a target spec from one of the arguments.

XMAP (TARGET FUNCTION &REST ARGUMENTS)

Apply function to arguments elementwise, and save the result in target.

XMEAN (A)

Mean of the elements.

XOP (RESULT-SPEC FUNCTION &REST VECTORS)

Generalized outer product of vectors, using function.

XORDER (VECTOR PREDICATE &KEY KEY STABLE-P)

Return a vector of integers starting from 0, representing the permutation of elements in vector that would result if sorted according to predicate (which you can use in slice, etc). Key is passed to sort. If stable-p, stable-sort is used.

XSORT (VECTOR PREDICATE &KEY KEY STABLE-P)

Sort vector using predicate. Calls xorder and returns order as the second value.

Undocumented

COPY-AS (CLASS OBJECT &REST OPTIONS)

Private

CONVERT-SLICE-SUBSCRIPTS (INDEX-SPECIFICATIONS SUBSCRIPTS)

Convert subscripts using index-specifications.

DELETE-DUPLICATE-KEYWORDS (PAIRS)

Delete conses with duplicate keywords. Destructive.

ELEMENT-CONVERSION-FUNCTION (SOURCE DESTINATION)

Return a conversion function that is identity if (subtypep source destination), or constructed with coerce otherwise.

FILL-ARRAY-WITH-LIST (ARRAY LIST)

Fills array with elements from list, coerced to the appropriate type. No error checking, meant to be used internally. Return array.

FLAT->PAIRS (LIST)

Transform a flat list of keyword-option pairs to a list of conses.

INDEX-SPECIFICATION-DIMENSION (INDEX-SPECIFICATION)

Return dimension of parsed index-specification. Internal function, no error checking. Return nil for dropped dimensions.

INVERT-PERMUTATION (PERMUTATION)

Return the inverse of a valid permutation vector (validity is not checked, results are not defined for invalid permutations).

MAKE-SYMBOL* (&REST ARGS)

Build a symbol by concatenating each element of ARGS, and intern it in the current package. Elements can be strings or symbols.

MERGE-OPTIONS (&REST OPTIONS-SPECS)

Merge options specifications. Duplicate pairs are removed, options that come later (both within and between arguments) are used.

NUMERIC-TYPE-CLASSIFIER (LIST)

Numeric type classifier, finds the smallest subtype that can accomodate the elements of list, in the ordering fixnum < integer < float < complex < t. Rational, float (any kind) are classified as double-float, and complex numbers as (complex double-float). Meant to be used by simple array-constructing functions. Upgraded-array-element-type is called on end result.

PAIRS->FLAT (PAIRS)

Flatten a list of conses.

PARSE-INDEX-SPECIFICATION (INDEX-SPECIFICATION DIMENSION)

Parse a index specification, returning either - an integer i, with the dimension dropped, - a pair (start . length), where start is the starting index, and length is the number of valid indexes. If dimension is negative, indexing is decreasing from start. This is used for contiguous indexes - a vector of indexes, for non-contiguous indexing. All resulting indexes are valid, ie they are integers in [0,dimension). Range specifications: Negative integers are interpreted as counted backwards from the right edge of the domain, ie i < 0 denotes element dimension-i. The l Valid index-specification specifications (a and b are integers): a index a, dimension dropped (list a) index a, dimension not dropped (list a b) range between a and b, inclusive. If b < a, reversed. :all all valid indexes, increasing order :rev all valid indexes, decreasing order (vector i1 ... in) vector of indexes, must be a set (no repetition).

PERMUTE-SEQUENCE (PERMUTATION SEQUENCE)

Return permuted sequence as a list. Works even if indexes repeat.

VALID-INTEGER-SUBSET-P (VECTOR DIMENSION)

Return non-nil (t) iff vector is a valid subset (ie with no repetition) of integers 0,1,...,(1- dimension).

VALID-PERMUTATION-P (VECTOR &OPTIONAL (DIMENSION (LENGTH VECTOR) DIMENSION-GIVEN-P))

Return non-nil (t) iff vector is a valid permutation of integers 0,1,...,(1- dimension).

VECTOR-WITHIN-DIMENSION-P (VECTOR DIMENSION)

Return non-nil iff all elements in vector are in [0,dimension).

WITHIN-DIMENSION-P (SUBSCRIPT DIMENSION)

Check if 0 <= subscript < dimension.

XDIMS= (A B)

Return non-nil iff the dimensions of A and B are the same.

Undocumented

MKLIST (OBJ)

MACRO

Private

DEFINE-ELEMENTWISE-OPERATION (OPERATION &OPTIONAL (DOCUMENTATION (FORMAT NIL Elementwise ~A of two arrays, or an array and a scalar. OPERATION)) (NAME (MAKE-SYMBOL* X OPERATION)))

Defines an elementwise operation, with some default methods that return arrays.

DEFINE-FLAT-REDUCTION (NAME MODIFY-MACRO DOCSTRING &BODY BODY)

Define a generic function named NAME which reduces its argument elementwise. body is spliced into the iterate loop, and can be used for early returns, etc. See code for variable names.

MAXF (PLACE &REST VALUES &ENVIRONMENT ENV)

Replace with largest of the place and the given values.

MINF (PLACE &REST VALUES &ENVIRONMENT ENV)

Replace with smallest of the place and the given values.

MULTF (PLACE &REST VALUES &ENVIRONMENT ENV)

Multiply (& set) the first argument by the rest.

GENERIC-FUNCTION

Public

AS* (CLASS OBJECT COPY-P OPTIONS)

Return an object converted to a given class, with other properties (eg element types for arrays) as specified by the optional keyword arguments. The result may share structure with object, unless COPY-P. Similarly to XCREATE, class can be (cons class options). When class is nil, XSIMILAR is called to obtain the result type. Usage note: libraries should specialize this method, but the user interface is AS or COPY-AS.

COLUMN-MAJOR-PROJECTION (OBJECT &REST DIMENSIONS)

Row major projection to an xrefable object. Total size needs to match the product of dimensions. If dimensions is omitted, it is taken to be the xsize of the object.

FLAT (OBJECT)

Flat index for an object.

PERMUTATION (OBJECT &REST PERMUTATION)

View with permutation of indexes.

SLICE (OBJECT &REST INDEX-SPECIFICATIONS)

Slice of an object.

X* (A B &KEY (ELEMENT-TYPE T) &ALLOW-OTHER-KEYS)

Elementwise * of two arrays, or an array and a scalar.

X+ (A B &KEY (ELEMENT-TYPE T) &ALLOW-OTHER-KEYS)

Elementwise + of two arrays, or an array and a scalar.

X- (A B &KEY (ELEMENT-TYPE T) &ALLOW-OTHER-KEYS)

Elementwise - of two arrays, or an array and a scalar.

X/ (A B &KEY (ELEMENT-TYPE T) &ALLOW-OTHER-KEYS)

Elementwise / of two arrays, or an array and a scalar.

X= (A B &OPTIONAL EPS)

Return non-nil if A and B have the same dimensions,, and the sup|A-B| <= eps.

XCREATE (CLASS DIMENSIONS &OPTIONAL OPTIONS)

Return a new object of given type and dimensions, with additional options. Dimensions can be a list, or a single number. xcreate can also be called as (XCREATE (CONS CLASS OPTIONS) DIMENSIONS), in which case it will split the cons, merge OPTIONS and call XCREATE again.

XDIM (OBJECT AXIS-NUMBER)

Return the axis-number dimension of object.

XDIMS (OBJECT)

Return a list of dimensions of object. The list does not share structure with anything, so it can be freely modified.

XDOT (A B)

Dot product of two vectors.

XELTTYPE (OBJECT)

Return the type of elements. If no restriction is imposed, return t.

XMAX (A)

Maximum of the elements.

XMIN (A)

Minimum of the elements.

XPROD (A)

Product of the elements.

XRANK (OBJECT)

Returns the number of dimensions of object.

XREF (OBJECT &REST SUBSCRIPTS)

Accesses the element of the object specified by subscripts.

SETFXREF (VALUE OBJECT &REST SUBSCRIPTS)

Accesses the element of the object specified by subscripts.

XSETF (DESTINATION SOURCE &KEY MAP-FUNCTION (MAP-FUNCTION (ELEMENT-CONVERSION-FUNCTION (XELTTYPE SOURCE) (XELTTYPE DESTINATION))))

Copy the elements of source to destination. Map-function, if given, will be used to map the elements, the default is conversion (if necessary) with coerce.

XSIMILAR (RANK OBJECT)

Return (CONS CLASS OPTIONS) for creating a similar object with new rank. If rank is T, use rank of object. NOTE: for methods, make sure you specialize rank to fixnum if you are not handling T.

XSUM (A)

Sum of the elements.

Private

ANCESTOR-SUBSCRIPTS (OBJECT INDEX)

Map the flat index the subscripts of the ancestor.

Undocumented

RANK (CONDITION)

SUBSCRIPTS (CONDITION)

SLOT-ACCESSOR

Public

XSIZE (OBJECT)

The Return the total number of elements in object.

SETFXSIZE (NEW-VALUE OBJECT)

Set the Return the total number of elements in object.

Private

ANCESTOR (OBJECT)

an underlying object that is accessible with xref

ANCESTOR-DIMENSIONS (OBJECT)

dimensions of ancestor

DIMENSIONS (CONDITION)

dimensions

INDEX-SPECIFICATIONS (OBJECT)

vector of index speficiations

START (OBJECT)

first integer

CLASS

Public

INT-SEQ (A &OPTIONAL B)

A sequence of integers.

Undocumented

COLUMN-MAJOR-PROJECTION-FLAT-VIEW

COLUMN-MAJOR-PROJECTION-VIEW

FLAT-VIEW

PERMUTATION-VIEW

SLICE-VIEW

VIEW

Private

Undocumented

SEQ

CONDITION

Public

Undocumented

XDIM-INVALID-AXIS-NUMBER

XREF-INCOMPATIBLE-TYPE

XREF-SETTING-READONLY

XREF-SUBSCRIPT-OUT-OF-BOUNDS

XREF-WRONG-NUMBER-OF-SUBSCRIPTS