The array-operations Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The array-operations Reference Manual

This is the array-operations Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 02:54:37 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

#+CAPTION: Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.
[[http://www.repostatus.org/badges/latest/abandoned.svg]]

| This is an *alpha* release.  All the code works and unit tests are expected to run perfectly, but the operations are not optimized and the API change. |


* Introduction

=array-operations= is a Common Lisp library that facilitates working with Common Lisp arrays using syntax and semantics that work well with the rest of the language.

/The library previously available under this name is deprecated, but you can find it [[https://github.com/tpapp/array-operations-old][here]]./


* A quick tour of the library

** Shorthand for frequently used Common Lisp array functions

The library defines the following short function names that are synomyms for Common Lisp operations:

| array-operations | Common Lisp                   |
|------------------+-------------------------------|
| size             | array-total-size              |
| rank             | array-rank                    |
| dim              | array-dimension               |
| dims             | array-dimensions              |
| nrow             | /number of rows in matrix/    |
| ncol             | /number of columns in matrix/ |

The =array-operations= package has the nickname =ao=, so you can use, for example, =(ao:size my-array)= without =use='ing the package.

** Displaced arrays for fun and profit

#+BEGIN_QUOTE
displaced array n. an array which has no storage of its own, but which is instead indirected to the storage of another array, called its target, at a specified offset, in such a way that any attempt to access the displaced array implicitly references the target array.  (CLHS Glossary)
#+END_QUOTE

Displaced arrays are one of the niftiest features of Common Lisp.  When an array is displaced to another array, it shares structure with (part of) that array.  The two arrays do not need to have the same dimensions, in fact, the dimensions do not be related at all as long as the displaced array fits inside the original one.  The row-major index of the former in the latter is called the /offset/ of the displacement.

Displaced arrays are usually constructed using =make-array=, but this library also provides =displace= for that purpose:
#+BEGIN_SRC lisp
  (defparameter *a* #2A((1 2 3) (4 5 6)))
  (ao:displace *a* 2 1) ; => #(2 3)
#+END_SRC
=flatten= displaces to a row-major array:
#+BEGIN_SRC lisp
  (ao:flatten *a*) ; => #(1 2 3 4 5 6)
#+END_SRC
The real fun starts with =split=, which splits off subarrays nested within a given axis:
#+BEGIN_SRC lisp
  (ao:split *a* 1) ; => #(#(1 2 3) #(4 5 6))
  (defparameter *b* #3A(((0 1) (2 3))
                        ((4 5) (6 7))))
  (ao:split *b* 0) ; => #3A(((0 1) (2 3)) ((4 5) (6 7)))
  (ao:split *b* 1) ; => #(#2A((0 1) (2 3)) #2A((4 5) (6 7)))
  (ao:split *b* 2) ; => #2A((#(0 1) #(2 3)) (#(4 5) #(6 7)))
  (ao:split *b* 3) ; => #3A(((0 1) (2 3)) ((4 5) (6 7)))
#+END_SRC
Note how splitting at =0= and the rank of the array returns the array itself.

Now consider =sub=, which returns a specific array, composed of the elements that would start with given subscripts:
#+BEGIN_SRC lisp
  (ao:sub *b* 0) ; => #2A((0 1) (2 3))
  (ao:sub *b* 0 1) ; => #(2 3)
  (ao:sub *b* 0 1 0) ; => 2
#+END_SRC
There is also a =(setf sub)= function.

=partition= returns a consecutive chunk of an array separated along its first subscript:
#+BEGIN_SRC lisp
  (ao:partition #2A((0 1)
                    (2 3)
                    (4 5)
                    (6 7)
                    (8 9))
                1 3) ; => #2A((2 3) (4 5))
#+END_SRC
and also has a =(setf partition)= pair.

=combine= is the opposite of =split=:
#+BEGIN_SRC lisp
  (ao:combine #(#(0 1) #(2 3))) ; => #2A((0 1) (2 3))
#+END_SRC

=subvec= returns a displaced subvector:
#+BEGIN_SRC lisp
  (ao:subvec #(0 1 2 3 4) 2 4) ; => #(2 3)
#+END_SRC
There is also a =(setf subvec)= function, which is like =(setf subseq)= except for demanding matching lengths.

Finally, =reshape= can be used to displace arrays into a different shape:
#+BEGIN_SRC lisp
  (ao:reshape *a* '(3 2)) ; => #2A((1 2) (3 4) (5 6))
#+END_SRC
You can use =t= for one of the dimensions, to be filled in automatically:
#+BEGIN_SRC lisp
  (ao:reshape *b* '(1 t)) ; => #2A((0 1 2 3 4 5 6 7))
#+END_SRC

=reshape-col= and =reshape-row= reshape your array into a column or row matrix, respectively.

** Dimension specifications

Functions in the library accept the following in place of dimensions:
- a list of dimensions (as for =make-array=),
- a positive integer, which is used as a single-element list,
- another array, the dimensions of which are used.

The last one allows you to specify dimensions with other arrays.  For example, to reshape an array =a1= to look like =a2=, you can use
#+BEGIN_SRC lisp
  (ao:reshape a1 a2)
#+END_SRC
instead of the longer form
#+BEGIN_SRC lisp
  (ao:reshape a1 (ao:dims a2))
#+END_SRC

** Array creation and transformations

When the resulting element type cannot be inferred, functions that create and transform arrays are provided in pairs: one of these will allow you to specify the array-element-type of the result, while the other assumes it is =t=.  The former ends with a =*=, and the =element-type= is always its first argument.  I give examples for the versions without =*=, use the other when you are optimizing your code and you are sure you can constrain to a given element-type.

*Element traversal order of these functions is unspecified*.  The reason for this is that the library may use parallel code in the future, so it is unsafe to rely on a particular element traversal order.

=generate= (and =generate*=) allow you to generate arrays using functions.
#+BEGIN_SRC lisp
  (ao:generate (lambda () (random 10)) 3) ; => #(6 9 5)
  (ao:generate #'identity '(2 3) :position) ; => #2A((0 1 2) (3 4 5))
  (ao:generate #'identity '(2 2) :subscripts)
  ;; => #2A(((0 0) (0 1)) ((1 0) (1 1)))
  (ao:generate #'cons '(2 2) :position-and-subscripts)
  ;; => #2A(((0 0 0) (1 0 1)) ((2 1 0) (3 1 1)))
#+END_SRC
Depending on the last argument, the function will be called with the (row-major) position, the subscripts, both, or no argument.

=permute= can permutate subscripts (you can also invert, complement, and complete permutations, look at the docstring and the unit tests).  Transposing is a special case of permute:
#+BEGIN_SRC lisp
  (ao:permute '(0 1) *a*) ; => #2A((1 2 3) (4 5 6))
#+END_SRC

=each= applies a function to its (array) arguments elementwise:
#+BEGIN_SRC lisp
  (ao:each #'+ #(0 1 2) #(2 3 5)) ; => #(2 4 7)
#+END_SRC

The semantics of =margin= are more difficult to explain, so perhaps an example will be more useful.  Suppose that you want to calculate column sums in a matrix.  You could =permute= (transpose) the matrix, =split= its subarrays at rank one (so you get a vector for each row), and apply the function that calculates the sum.  =margin= automates that for you:
#+BEGIN_SRC lisp
  (ao:margin (lambda (column)
               (reduce #'+ column))
             #2A((0 1)
                 (2 3)
                 (5 7)) 0) ; => #(7 11)
#+END_SRC
But the function is much more general than this: the arguments =inner= and =outer= allow arbitrary permutations before splitting.

Finally, =recycle= allows you to recycle arrays along inner and outer dimensions:
#+BEGIN_SRC lisp
  (ao:recycle #(2 3) :inner 2 :outer 4)
  ; => #3A(((2 2) (3 3)) ((2 2) (3 3)) ((2 2) (3 3)) ((2 2) (3 3)))
#+END_SRC

** Scalars as 0-dimensional arrays

Library functions treat non-array objects as if they were equivalent to 0-dimensional arrays: for example, =(ao:split array (rank array))= returns an array that effectively equivalent (=eq=) to array.  Another example is =recycle=:
#+BEGIN_SRC lisp
  (ao:recycle 4 :inner '(2 2)) ; => #2A((4 4) (4 4))
#+END_SRC

** Stacking

You can also stack compatible arrays along any axis:
#+BEGIN_SRC lisp
  (defparameter *a1* #(0 1 2))
  (defparameter *a2* #(3 5 7))
  (ao:stack 0 *a1* *a2*) ; => #(0 1 2 3 5 7)
  (ao:stack 1
            (ao:reshape-col *a1*)
            (ao:reshape-col *a2*)) ; => #2A((0 3) (1 5) (2 7))
  
#+END_SRC

** Shared structure

*Rules for that aren't finalized yet, see the source.*  Suggestions are welcome.

* To-do list
** benchmark and optimize walk-subscripts and walk-subscripts-list
- instead of allocating a new list each time, could map into a preallocated one


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 array-operations

Author

Tamas K. Papp <tkpapp@gmail.com>

License

MIT

Description

Simple array operations library for Common Lisp.

Dependencies
Source

array-operations.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 array-operations.asd

Location

/home/quickbuilder/quicklisp/dists/quicklisp/software/array-operations-20171130-git/array-operations.asd

Systems

array-operations (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 array-operations/package.lisp

Parent

array-operations (system)

Location

package.lisp

Packages

array-operations


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 array-operations/utilities.lisp

Dependency

package.lisp (file)

Parent

array-operations (system)

Location

utilities.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 array-operations/general.lisp

Dependency

utilities.lisp (file)

Parent

array-operations (system)

Location

general.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 array-operations/displacement.lisp

Dependency

general.lisp (file)

Parent

array-operations (system)

Location

displacement.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.6 array-operations/transformations.lisp

Dependency

displacement.lisp (file)

Parent

array-operations (system)

Location

transformations.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.7 array-operations/stack.lisp

Dependency

transformations.lisp (file)

Parent

array-operations (system)

Location

stack.lisp

Exported Definitions
Internal Definitions

stack*0 (function)


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 array-operations

Source

package.lisp (file)

Nickname

aops

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: &dims &rest DIMENSIONS

Dimensions of array-like object.

Package

array-operations

Source

general.lisp (file)

Macro: walk-subscripts (DIMENSIONS SUBSCRIPTS &optional POSITION) &body BODY

Iterate over the subscripts of an array with given DIMENSIONS. SUBSCRIPTS contains the current subscripts as a vector of fixnums, POSITION has the row-major index. Consequences are undefined if either POSITION or SUBSCRIPTS is modified.

Package

array-operations

Source

utilities.lisp (file)

Macro: walk-subscripts-list (DIMENSIONS SUBSCRIPTS &optional POSITION) &body BODY

Like WALK-SUBSCRIPTS, but SUBSCRIPTS is a newly created list for each position that does not share structure and can be freely used/modified/kept etc.

Package

array-operations

Source

utilities.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: coercing ELEMENT-TYPE &optional FUNCTION

Return a function composed of a univariate function that coerces to ELEMENT-TYPE and function. When FUNCTION is not given, return a closure that coerces to ELEMENT-TYPE.

Package

array-operations

Source

transformations.lisp (file)

Function: combine ARRAY &optional ELEMENT-TYPE

The opposite of SUBARRAYS. If ELEMENT-TYPE is not given, it is inferred from the first element of array, which also determines the dimensions. If that element is not an array, the original ARRAY is returned as it is.

Package

array-operations

Source

displacement.lisp (file)

Function: complement-permutation PERMUTATION RANK

Return a list of increasing indices that complement PERMUTATION, ie form a permutation when appended. Atoms are accepted and treated as lists of a single element.

Package

array-operations

Source

transformations.lisp (file)

Function: complete-permutation PERMUTATION RANK

Return a completed version of permutation, appending it to its complement.

Package

array-operations

Source

transformations.lisp (file)

Function: copy-into TARGET SOURCE

Copy SOURCE into TARGET, for array arguments of compatible dimensions (checked). Return TARGET, making the implementation of the semantics of SETF easy.

Package

array-operations

Source

displacement.lisp (file)

Function: copy-row-major-block SOURCE-ARRAY DESTINATION-ARRAY ELEMENT-TYPE &key SOURCE-START SOURCE-END DESTINATION-START

Copy elements with row major indexes between the given start and end from SOURCE to DESTINATION, respectively. Elements are coerced to ELEMENT-TYPE when necessary. Return no values.

This function should be used to implement copying of contiguous row-major blocks of elements, most optimizations should happen here.

Package

array-operations

Source

stack.lisp (file)

Function: displace ARRAY DIMENSIONS &optional OFFSET

Shorthand function for displacing an array.

Package

array-operations

Source

displacement.lisp (file)

Function: each FUNCTION ARRAY &rest OTHER-ARRAYS

Like EACH*, with ELEMENT-TYPE T.

Package

array-operations

Source

transformations.lisp (file)

Function: each* ELEMENT-TYPE FUNCTION ARRAY &rest OTHER-ARRAYS

Apply function to the array arguments elementwise, and return the result as an array with the given ELEMENT-TYPE. Arguments are checked for dimension compatibility.

Package

array-operations

Source

transformations.lisp (file)

Function: flatten ARRAY

Return ARRAY flattened to a vector. Will share structure.

Package

array-operations

Source

displacement.lisp (file)

Function: generate FUNCTION DIMENSIONS &optional ARGUMENTS

Like GENERATE*, with ELEMENT-TYPE T.

Package

array-operations

Source

transformations.lisp (file)

Function: generate* ELEMENT-TYPE FUNCTION DIMENSIONS &optional ARGUMENTS

Return an array with given DIMENSIONS and ELEMENT-TYPE, with elements generated by calling FUNCTION with

- no arguments, when ARGUMENTS is nil
- the position (= row major index), when ARGUMENTS is :POSITION - a list of subscripts, when ARGUMENTS is :SUBSCRIPTS
- both when ARGUMENTS is :POSITION-AND-SUBSCRIPTS

The traversal order is unspecified and may be nonlinear.

Package

array-operations

Source

transformations.lisp (file)

Function: identity-permutation? PERMUTATION &optional RANK

Test if PERMUTATION is the identity permutation, ie a sequence of consecutive integers starting at 0. Note that permutation is otherwise not checked, ie it may not be a permutation.

Package

array-operations

Source

transformations.lisp (file)

Function: invert-permutation PERMUTATION

Invert a permutation.

Package

array-operations

Source

transformations.lisp (file)

Function: make-array-like ARRAY &key DIMENSIONS ELEMENT-TYPE INITIAL-ELEMENT

Create an array with the same dimensions and element-type as ARRAY (which can be an array-like object that has the appropriate methods defined). Each attribute can be overriden. When INITIAL-ELEMENT is given, it is coerced to ELEMENT-TYPE and used as the initial element.

The array returned is always a simple-array and shares no structure with anything else.

Package

array-operations

Source

general.lisp (file)

Function: margin FUNCTION ARRAY INNER &optional OUTER

Like MARGIN*, with ELEMENT-TYPE T.

Package

array-operations

Source

transformations.lisp (file)

Function: margin* ELEMENT-TYPE FUNCTION ARRAY INNER &optional OUTER

PERMUTE ARRAY with ‘(,@OUTER ,@INNER), split the inner subarrays, apply FUNCTION to each, return the results in an array of dimensions OUTER, with the given ELEMENT-TYPE.

Package

array-operations

Source

transformations.lisp (file)

Function: matrix? MATRIX

Test if MATRIX has rank 2.

Package

array-operations

Source

general.lisp (file)

Function: outer FUNCTION &rest ARRAYS

Like OUTER, with ELEMENT-TYPE t.

Package

array-operations

Source

transformations.lisp (file)

Function: outer* ELEMENT-TYPE FUNCTION &rest ARRAYS

Generalized outer product of ARRAYS with FUNCTION. The resulting array has the concatenated dimensions of ARRAYS, and the given ELEMENT-TYPE.

Package

array-operations

Source

transformations.lisp (file)

Function: partition ARRAY START &optional END

Return a subset of the array, on the first indexes between START and END.

Package

array-operations

Source

displacement.lisp (file)

Writer

(setf partition) (function)

Function: (setf partition) VALUE ARRAY START &optional END
Package

array-operations

Source

displacement.lisp (file)

Reader

partition (function)

Function: permute PERMUTATION ARRAY

Return ARRAY with the axes permuted by PERMUTATION, which is a sequence of indexes. Specifically, an array A is transformed to B, where

B[b_1,...,b_n] = A[a_1,...,a_n] with b_i=a_{P[i]}

P is the permutation.

Array element type is preserved.

Package

array-operations

Source

transformations.lisp (file)

Function: recycle OBJECT &key INNER OUTER ELEMENT-TYPE

Recycle elements of object, extending the dimensions by outer (repeating OBJECT) and inner (repeating each element of OBJECT). When both INNER and OUTER are nil, the OBJECT is returned as is. Non-array objects are intepreted as rank 0 arrays, following the usual semantics.

Package

array-operations

Source

transformations.lisp (file)

Function: reshape ARRAY DIMENSIONS &optional OFFSET

Reshape ARRAY using DIMENSIONS (which can also be dimension specifications). If DIMENSIONS is a list, it may contain a single element T which will be calculated to match the total size of the resulting array.

Package

array-operations

Source

displacement.lisp (file)

Function: reshape-col ARRAY

Array reshaped as an Nx1 matrix.

Package

array-operations

Source

displacement.lisp (file)

Function: reshape-row ARRAY

Array reshaped as an 1xN matrix.

Package

array-operations

Source

displacement.lisp (file)

Function: split ARRAY RANK

Return an array of subarrays, split off at RANK. All subarrays are displaced and share structure.

Package

array-operations

Source

displacement.lisp (file)

Function: square-matrix? MATRIX

Test if MATRIX has two dimensions and that they are equal.

Package

array-operations

Source

general.lisp (file)

Function: stack AXIS ARRAY &rest ARRAYS

Like STACK*, with element-type T.

Package

array-operations

Source

stack.lisp (file)

Function: stack* ELEMENT-TYPE AXIS ARRAY &rest ARRAYS

Stack array arguments along AXIS. ELEMENT-TYPE determines the element-type of the result.

Package

array-operations

Source

stack.lisp (file)

Function: stack-cols &rest OBJECTS

Like STACK-COLS*, with ELEMENT-TYPE T.

Package

array-operations

Source

stack.lisp (file)

Function: stack-cols* ELEMENT-TYPE &rest OBJECTS

Stack OBJECTS column-wise into an array of the given ELEMENT-TYPE, coercing if necessary. Always return a simple array of rank 2.

How objects are used depends on their dimensions, queried by DIMS:

- when the object has 0 dimensions, fill a column with the element.

- when the object has 1 dimension, use it as a column.

- when the object has 2 dimensions, use it as a matrix.

When applicable, compatibility of dimensions is checked, and the result is used to determine the number of rows. When all objects have 0 dimensions, the result has one row.

Package

array-operations

Source

stack.lisp (file)

Function: stack-rows &rest OBJECTS

Like STACK-ROWS*, with ELEMENT-TYPE T.

Package

array-operations

Source

stack.lisp (file)

Function: stack-rows* ELEMENT-TYPE &rest OBJECTS

Stack OBJECTS row-wise into an array of the given ELEMENT-TYPE, coercing if necessary. Always return a simple array of rank 2.

How objects are used depends on their dimensions, queried by DIMS:

- when the object has 0 dimensions, fill a row with the element.

- when the object has 1 dimension, use it as a row.

- when the object has 2 dimensions, use it as a matrix.

When applicable, compatibility of dimensions is checked, and the result is used to determine the number of columns. When all objects have 0 dimensions, the result has one column.

Package

array-operations

Source

stack.lisp (file)

Function: sub ARRAY &rest SUBSCRIPTS

Given a partial list of subscripts, return the subarray that starts there, with all the other subscripts set to 0, dimensions inferred from the original. If no subscripts are given, the original array is returned. Implemented by displacing, may share structure.

Package

array-operations

Source

displacement.lisp (file)

Writer

(setf sub) (function)

Function: (setf sub) VALUE ARRAY &rest SUBSCRIPTS
Package

array-operations

Source

displacement.lisp (file)

Reader

sub (function)

Function: subvec VECTOR START &optional END

Displaced vector between START and END.

Package

array-operations

Source

displacement.lisp (file)

Writer

(setf subvec) (function)

Function: (setf subvec) VALUE VECTOR START &optional END
Package

array-operations

Source

displacement.lisp (file)

Reader

subvec (function)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: as-array OBJECT

Return the contents of OBJECT as an array. Exact semantics depends on OBJECT, but generally objects which contain elements in a rectilinear coordinate system should have a natural mapping to arrays.

When the second value is T, the array itself does not share structure with OBJECT, but its elements may. Otherwise, it is indeterminate whether the two objects share structure, and consequences of modifying the result are not defined. Methods are encouraged but not required to return a second value.

Package

array-operations

Source

general.lisp (file)

Methods
Method: as-array (ARRAY array)
Method: as-array OBJECT
Generic Function: dim ARRAY AXIS

Return specificed dimension of ARRAY.

Package

array-operations

Source

general.lisp (file)

Methods
Method: dim (ARRAY array) AXIS
Method: dim ARRAY AXIS
Generic Function: dims ARRAY

Return a list of dimensions.

For non-array objects, SIZE, DIM, NROW and NCOL use this method by default, so it is enough to define it (unless efficiency is a concern).

When DIMS is not defined for an object, it falls back to as-array, which may be very inefficient for objects which need to be consed. It is always advisable to define DIMS.

Package

array-operations

Source

general.lisp (file)

Methods
Method: dims (ARRAY array)
Method: dims ARRAY
Generic Function: element-type ARRAY

Return TYPE such that

1. all elements of ARRAY are guaranteed to be a subtype of TYPE,

2. if applicable, elements of ARRAY can be set to values which are of a type that is a subtype of TYPE.

Package

array-operations

Source

general.lisp (file)

Methods
Method: element-type (ARRAY array)
Method: element-type ARRAY
Generic Function: ncol ARRAY

Number of columns. Will signal an error if ARRAY is not a matrix.

Package

array-operations

Source

general.lisp (file)

Methods
Method: ncol (ARRAY array)
Method: ncol ARRAY
Generic Function: nrow ARRAY

Number of rows. Will signal an error if ARRAY is not a matrix.

Package

array-operations

Source

general.lisp (file)

Methods
Method: nrow (ARRAY array)
Method: nrow ARRAY
Generic Function: rank ARRAY

Return the rank of ARRAY.

Package

array-operations

Source

general.lisp (file)

Methods
Method: rank (ARRAY array)
Method: rank ARRAY
Generic Function: size ARRAY

Return the total number of elements in array.

Package

array-operations

Source

general.lisp (file)

Methods
Method: size (ARRAY array)
Method: size ARRAY
Generic Function: stack-cols-copy SOURCE DESTINATION ELEMENT-TYPE START-COL

Method used to implement the copying of objects in STACK-COL*, by copying the elements of SOURCE to DESTINATION, starting with the column index START-COL in the latter. Elements are coerced to ELEMENT-TYPE.

This method is only called when (DIMS SOURCE) was non-nil. It is assumed that it only changes elements in DESTINATION which are supposed to be copies of SOURCE. DESTINATION is always a matrix with element-type upgraded from ELEMENT-TYPE, and its NROW should match the relevant dimension of SOURCE.

All objects have a fallback method, defined using AS-ARRAY. The only reason for definining a method is efficiency.

Package

array-operations

Source

stack.lisp (file)

Methods
Method: stack-cols-copy SOURCE DESTINATION ELEMENT-TYPE START-COL
Method: stack-cols-copy (SOURCE array) DESTINATION ELEMENT-TYPE START-COL
Generic Function: stack-rows-copy SOURCE DESTINATION ELEMENT-TYPE START-ROW

Method used to implement the copying of objects in STACK-ROW*, by copying the elements of SOURCE to DESTINATION, starting with the row index START-ROW in the latter. Elements are coerced to ELEMENT-TYPE.

This method is only called when (DIMS SOURCE) was non-nil. It is assumed that it onlychanges elements in DESTINATION which are supposed to be copies of SOURCE. DESTINATION is always a matrix with element-type upgraded from ELEMENT-TYPE, and its NCOL should match the relevant dimension of SOURCE.

All objects have a fallback method, defined using AS-ARRAY. The only reason for definining a method is efficiency.

Package

array-operations

Source

stack.lisp (file)

Methods
Method: stack-rows-copy SOURCE DESTINATION ELEMENT-TYPE START-ROW
Method: stack-rows-copy (SOURCE array) DESTINATION ELEMENT-TYPE START-ROW

Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Conditions

Condition: permutation-incompatible-rank ()
Package

array-operations

Source

transformations.lisp (file)

Direct superclasses

error (condition)

Condition: permutation-invalid-index ()
Package

array-operations

Source

transformations.lisp (file)

Direct superclasses

error (condition)

Direct slots
Slot: index
Initargs

:index

Condition: permutation-repeated-index ()
Package

array-operations

Source

transformations.lisp (file)

Direct superclasses

error (condition)

Direct slots
Slot: index
Initargs

:index


Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Types

Type: array-matrix ()

A rank-2 array.

Package

array-operations

Source

general.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Macros

Macro: multf PLACE &rest VALUES

Multiply by the arguments

Package

array-operations

Source

utilities.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: check-permutation PERMUTATION &optional RANK

Check if PERMUTATION is a valid permutation (of the given RANK), and signal an error if necessary.

Package

array-operations

Source

transformations.lisp (file)

Function: ensure-dimensions OBJECT

Return a list of dimensions corresponding to OBJECT. Positive integers are treated as dimensions of rank 1, lists are returned as they are, and arrays are queried for their dimensions.

OBJECTS accepted by this function as valid dimensions are called ‘dimension specifications’ in this library.

Package

array-operations

Source

utilities.lisp (file)

Function: fill-in-dimensions DIMENSIONS SIZE

If one of the dimensions is missing (indicated with T), replace it with a dimension so that the total product equals SIZE. If that’s not possible, signal an error. If there are no missing dimensions, just check that the product equals size. Also accepts other dimension specifications (integer, array).

Package

array-operations

Source

displacement.lisp (file)

Function: permutation-flags PERMUTATION &optional RANK

Make a bit vector of flags with indexes from PERMUTATION, signalling errors for invalid and repeated indices. NOT EXPORTED.

Package

array-operations

Source

transformations.lisp (file)

Function: product DIMENSIONS

Product of elements in the argument. NOT EXPORTED.

Package

array-operations

Source

utilities.lisp (file)

Function: same-dimensions? ARRAY &rest ARRAYS

Test if arguments have the same dimensions. NOT EXPORTED.

Package

array-operations

Source

utilities.lisp (file)

Function: stack*0 ELEMENT-TYPE ARRAYS

Stack arrays along the 0 axis, returning an array with given ELEMENT-TYPE.

Package

array-operations

Source

stack.lisp (file)

Function: sub-location% DIMENSIONS SUBSCRIPTS

Return (values OFFSET REMAINING-DIMENSIONS) that can be used to displace a row-major subarray starting at SUBSCRIPTS in an array with the given DIMENSIONS. NOT EXPORTED.

Package

array-operations

Source

displacement.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   A   F   L  
Index Entry  Section

A
array-operations.asd: The array-operations<dot>asd file
array-operations/displacement.lisp: The array-operations/displacement<dot>lisp file
array-operations/general.lisp: The array-operations/general<dot>lisp file
array-operations/package.lisp: The array-operations/package<dot>lisp file
array-operations/stack.lisp: The array-operations/stack<dot>lisp file
array-operations/transformations.lisp: The array-operations/transformations<dot>lisp file
array-operations/utilities.lisp: The array-operations/utilities<dot>lisp file

F
File, Lisp, array-operations.asd: The array-operations<dot>asd file
File, Lisp, array-operations/displacement.lisp: The array-operations/displacement<dot>lisp file
File, Lisp, array-operations/general.lisp: The array-operations/general<dot>lisp file
File, Lisp, array-operations/package.lisp: The array-operations/package<dot>lisp file
File, Lisp, array-operations/stack.lisp: The array-operations/stack<dot>lisp file
File, Lisp, array-operations/transformations.lisp: The array-operations/transformations<dot>lisp file
File, Lisp, array-operations/utilities.lisp: The array-operations/utilities<dot>lisp file

L
Lisp File, array-operations.asd: The array-operations<dot>asd file
Lisp File, array-operations/displacement.lisp: The array-operations/displacement<dot>lisp file
Lisp File, array-operations/general.lisp: The array-operations/general<dot>lisp file
Lisp File, array-operations/package.lisp: The array-operations/package<dot>lisp file
Lisp File, array-operations/stack.lisp: The array-operations/stack<dot>lisp file
Lisp File, array-operations/transformations.lisp: The array-operations/transformations<dot>lisp file
Lisp File, array-operations/utilities.lisp: The array-operations/utilities<dot>lisp file

Jump to:   A   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   &   (  
A   C   D   E   F   G   I   M   N   O   P   R   S   W  
Index Entry  Section

&
&dims: Exported macros

(
(setf partition): Exported functions
(setf sub): Exported functions
(setf subvec): Exported functions

A
as-array: Exported generic functions
as-array: Exported generic functions
as-array: Exported generic functions

C
check-permutation: Internal functions
coercing: Exported functions
combine: Exported functions
complement-permutation: Exported functions
complete-permutation: Exported functions
copy-into: Exported functions
copy-row-major-block: Exported functions

D
dim: Exported generic functions
dim: Exported generic functions
dim: Exported generic functions
dims: Exported generic functions
dims: Exported generic functions
dims: Exported generic functions
displace: Exported functions

E
each: Exported functions
each*: Exported functions
element-type: Exported generic functions
element-type: Exported generic functions
element-type: Exported generic functions
ensure-dimensions: Internal functions

F
fill-in-dimensions: Internal functions
flatten: Exported functions
Function, (setf partition): Exported functions
Function, (setf sub): Exported functions
Function, (setf subvec): Exported functions
Function, check-permutation: Internal functions
Function, coercing: Exported functions
Function, combine: Exported functions
Function, complement-permutation: Exported functions
Function, complete-permutation: Exported functions
Function, copy-into: Exported functions
Function, copy-row-major-block: Exported functions
Function, displace: Exported functions
Function, each: Exported functions
Function, each*: Exported functions
Function, ensure-dimensions: Internal functions
Function, fill-in-dimensions: Internal functions
Function, flatten: Exported functions
Function, generate: Exported functions
Function, generate*: Exported functions
Function, identity-permutation?: Exported functions
Function, invert-permutation: Exported functions
Function, make-array-like: Exported functions
Function, margin: Exported functions
Function, margin*: Exported functions
Function, matrix?: Exported functions
Function, outer: Exported functions
Function, outer*: Exported functions
Function, partition: Exported functions
Function, permutation-flags: Internal functions
Function, permute: Exported functions
Function, product: Internal functions
Function, recycle: Exported functions
Function, reshape: Exported functions
Function, reshape-col: Exported functions
Function, reshape-row: Exported functions
Function, same-dimensions?: Internal functions
Function, split: Exported functions
Function, square-matrix?: Exported functions
Function, stack: Exported functions
Function, stack*: Exported functions
Function, stack*0: Internal functions
Function, stack-cols: Exported functions
Function, stack-cols*: Exported functions
Function, stack-rows: Exported functions
Function, stack-rows*: Exported functions
Function, sub: Exported functions
Function, sub-location%: Internal functions
Function, subvec: Exported functions

G
generate: Exported functions
generate*: Exported functions
Generic Function, as-array: Exported generic functions
Generic Function, dim: Exported generic functions
Generic Function, dims: Exported generic functions
Generic Function, element-type: Exported generic functions
Generic Function, ncol: Exported generic functions
Generic Function, nrow: Exported generic functions
Generic Function, rank: Exported generic functions
Generic Function, size: Exported generic functions
Generic Function, stack-cols-copy: Exported generic functions
Generic Function, stack-rows-copy: Exported generic functions

I
identity-permutation?: Exported functions
invert-permutation: Exported functions

M
Macro, &dims: Exported macros
Macro, multf: Internal macros
Macro, walk-subscripts: Exported macros
Macro, walk-subscripts-list: Exported macros
make-array-like: Exported functions
margin: Exported functions
margin*: Exported functions
matrix?: Exported functions
Method, as-array: Exported generic functions
Method, as-array: Exported generic functions
Method, dim: Exported generic functions
Method, dim: Exported generic functions
Method, dims: Exported generic functions
Method, dims: Exported generic functions
Method, element-type: Exported generic functions
Method, element-type: Exported generic functions
Method, ncol: Exported generic functions
Method, ncol: Exported generic functions
Method, nrow: Exported generic functions
Method, nrow: Exported generic functions
Method, rank: Exported generic functions
Method, rank: Exported generic functions
Method, size: Exported generic functions
Method, size: Exported generic functions
Method, stack-cols-copy: Exported generic functions
Method, stack-cols-copy: Exported generic functions
Method, stack-rows-copy: Exported generic functions
Method, stack-rows-copy: Exported generic functions
multf: Internal macros

N
ncol: Exported generic functions
ncol: Exported generic functions
ncol: Exported generic functions
nrow: Exported generic functions
nrow: Exported generic functions
nrow: Exported generic functions

O
outer: Exported functions
outer*: Exported functions

P
partition: Exported functions
permutation-flags: Internal functions
permute: Exported functions
product: Internal functions

R
rank: Exported generic functions
rank: Exported generic functions
rank: Exported generic functions
recycle: Exported functions
reshape: Exported functions
reshape-col: Exported functions
reshape-row: Exported functions

S
same-dimensions?: Internal functions
size: Exported generic functions
size: Exported generic functions
size: Exported generic functions
split: Exported functions
square-matrix?: Exported functions
stack: Exported functions
stack*: Exported functions
stack*0: Internal functions
stack-cols: Exported functions
stack-cols*: Exported functions
stack-cols-copy: Exported generic functions
stack-cols-copy: Exported generic functions
stack-cols-copy: Exported generic functions
stack-rows: Exported functions
stack-rows*: Exported functions
stack-rows-copy: Exported generic functions
stack-rows-copy: Exported generic functions
stack-rows-copy: Exported generic functions
sub: Exported functions
sub-location%: Internal functions
subvec: Exported functions

W
walk-subscripts: Exported macros
walk-subscripts-list: Exported macros

Jump to:   &   (  
A   C   D   E   F   G   I   M   N   O   P   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   I   S  
Index Entry  Section

I
index: Exported conditions
index: Exported conditions

S
Slot, index: Exported conditions
Slot, index: Exported conditions

Jump to:   I   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   P   S   T  
Index Entry  Section

A
array-matrix: Exported types
array-operations: The array-operations system
array-operations: The array-operations package

C
Condition, permutation-incompatible-rank: Exported conditions
Condition, permutation-invalid-index: Exported conditions
Condition, permutation-repeated-index: Exported conditions

P
Package, array-operations: The array-operations package
permutation-incompatible-rank: Exported conditions
permutation-invalid-index: Exported conditions
permutation-repeated-index: Exported conditions

S
System, array-operations: The array-operations system

T
Type, array-matrix: Exported types

Jump to:   A   C   P   S   T