Commit 1a2ebe96 authored by Liam Healy's avatar Liam Healy

Array input and output declarations

A somewhat comprhensive attempt to make sure :inputs, :outputs, and
:return arguments in defmfuns match what the function is expecting and
will return, so that non-native implementations will work correctly
for copying, and native ones will work correctly for pinning.  The
:return argument now defaults to :outputs in most circumstances.
parent bca08efd
;; Permutations ;; Permutations
;; Liam Healy, Sun Mar 26 2006 - 11:51 ;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2008-12-06 19:03:50EST permutation.lisp> ;; Time-stamp: <2008-12-07 18:17:57EST permutation.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
(((mpointer permutation) :pointer)) (((mpointer permutation) :pointer))
:definition :method :definition :method
:c-return :void :c-return :void
:inputs (permutation)
:outputs (permutation) :outputs (permutation)
:return (permutation) :return (permutation)
:documentation ; FDL :documentation ; FDL
...@@ -64,6 +63,7 @@ ...@@ -64,6 +63,7 @@
:definition :method :definition :method
:inputs (source) :inputs (source)
:outputs (destination) :outputs (destination)
:return (destination)
:documentation ; FDL :documentation ; FDL
"Copy the elements of the permutation source into the "Copy the elements of the permutation source into the
permutation destination. The two permutations must have the same size.") permutation destination. The two permutations must have the same size.")
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
:definition :method :definition :method
:inputs (p) :inputs (p)
:outputs (p) :outputs (p)
:return (p)
:documentation ; FDL :documentation ; FDL
"Exchanges the ith and jth elements of the permutation p.") "Exchanges the ith and jth elements of the permutation p.")
...@@ -85,6 +86,7 @@ ...@@ -85,6 +86,7 @@
"gsl_permutation_size" "gsl_permutation_size"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:c-return sizet :c-return sizet
:inputs (p)
:documentation ; FDL :documentation ; FDL
"The size of the permutation p.") "The size of the permutation p.")
...@@ -92,6 +94,7 @@ ...@@ -92,6 +94,7 @@
"gsl_permutation_data" "gsl_permutation_data"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:c-return :pointer :c-return :pointer
:inputs (p)
:documentation ; FDL :documentation ; FDL
"A pointer to the array of elements in the "A pointer to the array of elements in the
permutation p.") permutation p.")
...@@ -105,6 +108,7 @@ ...@@ -105,6 +108,7 @@
(((mpointer permutation) :pointer)) (((mpointer permutation) :pointer))
:definition :method :definition :method
:c-return :boolean :c-return :boolean
:inputs (permutation)
:documentation ; FDL :documentation ; FDL
"Check that the permutation p is valid. The n "Check that the permutation p is valid. The n
elements should contain each of the numbers 0 to n-1 once and only elements should contain each of the numbers 0 to n-1 once and only
...@@ -117,15 +121,19 @@ ...@@ -117,15 +121,19 @@
(defmfun permutation-reverse (p) (defmfun permutation-reverse (p)
"gsl_permutation_reverse" "gsl_permutation_reverse"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:outputs (p)
:c-return :void :c-return :void
:inputs (p)
:outputs (p)
:return (p)
:documentation ; FDL :documentation ; FDL
"Reverse the order of the elements of the permutation p.") "Reverse the order of the elements of the permutation p.")
(defmfun permutation-inverse (inv p) (defmfun permutation-inverse (inv p)
"gsl_permutation_inverse" "gsl_permutation_inverse"
(((mpointer inv) :pointer) ((mpointer p) :pointer)) (((mpointer inv) :pointer) ((mpointer p) :pointer))
:inputs (p)
:outputs (inv) :outputs (inv)
:return (inv)
:documentation ; FDL :documentation ; FDL
"Find the inverse of the permutation p.") "Find the inverse of the permutation p.")
...@@ -133,7 +141,9 @@ ...@@ -133,7 +141,9 @@
"gsl_permutation_next" "gsl_permutation_next"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:c-return :success-failure :c-return :success-failure
:inputs (p)
:outputs (p) :outputs (p)
:return (p :c-return)
:documentation ; FDL :documentation ; FDL
"Advance the permutation p to the next permutation "Advance the permutation p to the next permutation
in lexicographic order and return p and T. If no further in lexicographic order and return p and T. If no further
...@@ -146,7 +156,9 @@ ...@@ -146,7 +156,9 @@
"gsl_permutation_prev" "gsl_permutation_prev"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:c-return :success-failure :c-return :success-failure
:inputs (p)
:outputs (p) :outputs (p)
:return (p :c-return)
:documentation ; FDL :documentation ; FDL
"Step backwards from the permutation p to the "Step backwards from the permutation p to the
previous permutation in lexicographic order, returning p and T. previous permutation in lexicographic order, returning p and T.
...@@ -160,6 +172,9 @@ ...@@ -160,6 +172,9 @@
(defmfun permute (p data stride n) (defmfun permute (p data stride n)
"gsl_permute" "gsl_permute"
(((mpointer p) :pointer) (data :pointer) (stride sizet) (n sizet)) (((mpointer p) :pointer) (data :pointer) (stride sizet) (n sizet))
:inputs (p data)
:outputs (data)
:return (data)
:documentation ; FDL :documentation ; FDL
"Apply the permutation p to the array data of "Apply the permutation p to the array data of
size n with stride stride.") size n with stride stride.")
...@@ -167,6 +182,9 @@ ...@@ -167,6 +182,9 @@
(defmfun permute-inverse (p data stride n) (defmfun permute-inverse (p data stride n)
"gsl_permute_inverse" "gsl_permute_inverse"
(((mpointer p) :pointer) (data :pointer) (stride sizet) (n sizet)) (((mpointer p) :pointer) (data :pointer) (stride sizet) (n sizet))
:inputs (p data)
:outputs (data)
:return (data)
:documentation ; FDL :documentation ; FDL
"Apply the inverse of the permutation p to the array data of "Apply the inverse of the permutation p to the array data of
size n with stride.") size n with stride.")
...@@ -175,7 +193,9 @@ ...@@ -175,7 +193,9 @@
("gsl_permute_vector" :type) ("gsl_permute_vector" :type)
(((mpointer p) :pointer) ((mpointer v) :pointer)) (((mpointer p) :pointer) ((mpointer v) :pointer))
:definition :generic :definition :generic
:inputs (p v)
:outputs (v) :outputs (v)
:return (v)
:documentation ; FDL :documentation ; FDL
"Apply the permutation p to the elements of the "Apply the permutation p to the elements of the
vector v considered as a row-vector acted on by a permutation vector v considered as a row-vector acted on by a permutation
...@@ -188,7 +208,9 @@ ...@@ -188,7 +208,9 @@
("gsl_permute_vector" :type "_inverse") ("gsl_permute_vector" :type "_inverse")
(((mpointer p) :pointer) ((mpointer v) :pointer)) (((mpointer p) :pointer) ((mpointer v) :pointer))
:definition :generic :definition :generic
:inputs (p v)
:outputs (v) :outputs (v)
:return (v)
:documentation ; FDL :documentation ; FDL
"Apply the permutation p to the elements of the "Apply the permutation p to the elements of the
vector v considered as a row-vector acted on by a permutation vector v considered as a row-vector acted on by a permutation
...@@ -202,7 +224,9 @@ ...@@ -202,7 +224,9 @@
(((mpointer p) :pointer) (((mpointer p) :pointer)
((mpointer pa) :pointer) ((mpointer pa) :pointer)
((mpointer pb) :pointer)) ((mpointer pb) :pointer))
:inputs (pa pb)
:outputs (p) :outputs (p)
:return (p)
:documentation ; FDL :documentation ; FDL
"Combine the two permutations pa and pb into a "Combine the two permutations pa and pb into a
single permutation p where p = pa . pb. The permutation single permutation p where p = pa . pb. The permutation
...@@ -215,6 +239,7 @@ ...@@ -215,6 +239,7 @@
(defmfun linear-to-canonical (q p) (defmfun linear-to-canonical (q p)
"gsl_permutation_linear_to_canonical" "gsl_permutation_linear_to_canonical"
(((mpointer q) :pointer) ((mpointer p) :pointer)) (((mpointer q) :pointer) ((mpointer p) :pointer))
:inputs (p)
:outputs (q) :outputs (q)
:documentation ; FDL :documentation ; FDL
"Compute the canonical form of the permutation p and "Compute the canonical form of the permutation p and
...@@ -223,6 +248,7 @@ ...@@ -223,6 +248,7 @@
(defmfun canonical-to-linear (p q) (defmfun canonical-to-linear (p q)
"gsl_permutation_canonical_to_linear" "gsl_permutation_canonical_to_linear"
(((mpointer p) :pointer) ((mpointer q) :pointer)) (((mpointer p) :pointer) ((mpointer q) :pointer))
:inputs (q)
:outputs (p) :outputs (p)
:documentation ; FDL :documentation ; FDL
"Convert a permutation q in canonical form back into "Convert a permutation q in canonical form back into
...@@ -231,6 +257,7 @@ ...@@ -231,6 +257,7 @@
(defmfun inversions (p) (defmfun inversions (p)
"gsl_permutation_inversions" (((mpointer p) :pointer)) "gsl_permutation_inversions" (((mpointer p) :pointer))
:c-return sizet :c-return sizet
:inputs (p)
:documentation ; FDL :documentation ; FDL
"Count the number of inversions in the permutation "Count the number of inversions in the permutation
p. An inversion is any pair of elements that are not in order. p. An inversion is any pair of elements that are not in order.
...@@ -241,6 +268,7 @@ ...@@ -241,6 +268,7 @@
(defmfun linear-cycles (p) (defmfun linear-cycles (p)
"gsl_permutation_linear_cycles" (((mpointer p) :pointer)) "gsl_permutation_linear_cycles" (((mpointer p) :pointer))
:c-return sizet :c-return sizet
:inputs (p)
:documentation ; FDL :documentation ; FDL
"Count the number of cycles in the permutation p, given in linear form.") "Count the number of cycles in the permutation p, given in linear form.")
...@@ -248,6 +276,7 @@ ...@@ -248,6 +276,7 @@
"gsl_permutation_canonical_cycles" "gsl_permutation_canonical_cycles"
(((mpointer p) :pointer)) (((mpointer p) :pointer))
:c-return sizet :c-return sizet
:inputs (p)
:documentation ; FDL :documentation ; FDL
"Count the number of cycles in the permutation q, given in canonical form.") "Count the number of cycles in the permutation q, given in canonical form.")
......
;; Macro for defining GSL functions. ;; Macro for defining GSL functions.
;; Liam Healy 2008-04-16 20:49:50EDT defmfun.lisp ;; Liam Healy 2008-04-16 20:49:50EDT defmfun.lisp
;; Time-stamp: <2008-11-29 15:30:45EST defmfun.lisp> ;; Time-stamp: <2008-12-07 18:18:03EST defmfun.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -638,6 +638,7 @@ ...@@ -638,6 +638,7 @@
(t (unless (t (unless
(or (or
(and (eq c-return :error-code) (and (eq c-return :error-code)
(not outputs)
(not allocated) (not allocated)
(not return-supplied-p)) (not return-supplied-p))
(and (null return) return-supplied-p)) (and (null return) return-supplied-p))
......
;; BLAS level 1, Vector operations ;; BLAS level 1, Vector operations
;; Liam Healy, Wed Apr 26 2006 - 15:23 ;; Liam Healy, Wed Apr 26 2006 - 15:23
;; Time-stamp: <2008-11-09 17:11:25EST blas1.lisp> ;; Time-stamp: <2008-12-07 18:24:40EST blas1.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
(result :element-c-type)) (result :element-c-type))
:definition :generic :definition :generic
:element-types :float-complex :element-types :float-complex
:inputs (vec1 vec2)
:documentation ; FDL :documentation ; FDL
"Dot, or inner, product between vectors.") "Dot, or inner, product between vectors.")
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
"gsl_blas_sdsdot" "gsl_blas_sdsdot"
((alpha :float) ((mpointer vec1) :pointer) ((mpointer vec2) :pointer) ((alpha :float) ((mpointer vec1) :pointer) ((mpointer vec2) :pointer)
(result :pointer)) (result :pointer))
:inputs (vec1 vec2)
:outputs (result) :outputs (result)
:documentation ; FDL :documentation ; FDL
"Sum of a scalar and a dot product for single-floats.") "Sum of a scalar and a dot product for single-floats.")
...@@ -87,7 +89,6 @@ ...@@ -87,7 +89,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (x) :inputs (x)
:outputs (y) :outputs (y)
:return (y)
:documentation ; FDL :documentation ; FDL
"Copy the elements of the vector x into the vector y.") "Copy the elements of the vector x into the vector y.")
...@@ -100,7 +101,6 @@ ...@@ -100,7 +101,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (x y) :inputs (x y)
:outputs (y) :outputs (y)
:return (y)
:documentation ; FDL :documentation ; FDL
"Compute the sum y = \alpha x + y for the vectors x and y.") "Compute the sum y = \alpha x + y for the vectors x and y.")
...@@ -114,7 +114,6 @@ ...@@ -114,7 +114,6 @@
:c-return :void :c-return :void
:inputs (x) :inputs (x)
:outputs (x) :outputs (x)
:return (x)
:documentation ; FDL :documentation ; FDL
"Rescale the vector x by the multiplicative factor alpha.") "Rescale the vector x by the multiplicative factor alpha.")
...@@ -126,8 +125,7 @@ ...@@ -126,8 +125,7 @@
:element-types :complex :element-types :complex
:c-return :void :c-return :void
:inputs (x) :inputs (x)
:outputs (x) :outputs (x))
:return (x))
;;; The Givens rotations come in two forms, those that work on bare C ;;; The Givens rotations come in two forms, those that work on bare C
;;; arrays, and those that work on GSL vectors. Ports of both are ;;; arrays, and those that work on GSL vectors. Ports of both are
...@@ -141,7 +139,6 @@ ...@@ -141,7 +139,6 @@
:element-types :float :element-types :float
:inputs (x y c s) :inputs (x y c s)
:outputs (x y) :outputs (x y)
:return (x y)
:documentation ; FDL :documentation ; FDL
"These functions compute a Givens rotation (c,s) to the vector (x,y), "These functions compute a Givens rotation (c,s) to the vector (x,y),
[ c s ] [ x ] = [ r ] [ c s ] [ x ] = [ r ]
......
;; BLAS level 2, Matrix-vector operations ;; BLAS level 2, Matrix-vector operations
;; Liam Healy, Wed Apr 26 2006 - 21:08 ;; Liam Healy, Wed Apr 26 2006 - 21:08
;; Time-stamp: <2008-11-09 18:15:43EST blas2.lisp> ;; Time-stamp: <2008-12-07 18:25:57EST blas2.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (A x y) :inputs (A x y)
:outputs (y) :outputs (y)
:return (y)
:documentation ; FDL :documentation ; FDL
"If the second and third arguments are vectors, compute "If the second and third arguments are vectors, compute
the matrix-vector product and sum the matrix-vector product and sum
...@@ -59,7 +58,6 @@ ...@@ -59,7 +58,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (A x) :inputs (A x)
:outputs (x) :outputs (x)
:return (x)
:documentation ; FDL :documentation ; FDL
"If the second argument is a vector, compute "If the second argument is a vector, compute
the matrix-vector product x =alpha op(A) x the matrix-vector product x =alpha op(A) x
...@@ -92,7 +90,6 @@ ...@@ -92,7 +90,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (A x) :inputs (A x)
:outputs (x) :outputs (x)
:return (x)
:documentation ; FDL :documentation ; FDL
"If the second argument is a vector, compute "If the second argument is a vector, compute
inv(op(A)) x for x, where op(A) = A, A^T, A^H for inv(op(A)) x for x, where op(A) = A, A^T, A^H for
...@@ -123,7 +120,6 @@ ...@@ -123,7 +120,6 @@
:element-types :float :element-types :float
:inputs (A x y) :inputs (A x y)
:outputs (y) :outputs (y)
:return (y)
:documentation ; FDL :documentation ; FDL
"If the second and third arguments are vectors, compute "If the second and third arguments are vectors, compute
the matrix-vector product and sum y = alpha A the matrix-vector product and sum y = alpha A
...@@ -152,7 +148,6 @@ ...@@ -152,7 +148,6 @@
:element-types :complex :element-types :complex
:inputs (A x y) :inputs (A x y)
:outputs (y) :outputs (y)
:return (y)
:documentation ; FDL :documentation ; FDL
"If the second and third arguments are vectors, compute the "If the second and third arguments are vectors, compute the
matrix-vector product and sum y = alpha A x + beta y for the matrix-vector product and sum y = alpha A x + beta y for the
...@@ -178,7 +173,6 @@ ...@@ -178,7 +173,6 @@
:element-types :float-complex :element-types :float-complex
:inputs (x y A) :inputs (x y A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"The rank-1 update A = alpha x y^T + A of the matrix A.") "The rank-1 update A = alpha x y^T + A of the matrix A.")
...@@ -190,7 +184,6 @@ ...@@ -190,7 +184,6 @@
:element-types :complex :element-types :complex
:inputs (x y A) :inputs (x y A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"The conjugate rank-1 update A = alpha x y^H + A of the matrix A.") "The conjugate rank-1 update A = alpha x y^H + A of the matrix A.")
...@@ -204,7 +197,6 @@ ...@@ -204,7 +197,6 @@
:element-types :float :element-types :float
:inputs (x A) :inputs (x A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"If the first argument is a vector, "If the first argument is a vector,
the symmetric rank-1 update A = \alpha x x^T + A of the symmetric the symmetric rank-1 update A = \alpha x x^T + A of the symmetric
...@@ -230,7 +222,6 @@ ...@@ -230,7 +222,6 @@
:element-types :complex :element-types :complex
:inputs (x A) :inputs (x A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"If the first argument is a vector, "If the first argument is a vector,
compute the hermitian rank-1 update A = alpha x x^H + A of the compute the hermitian rank-1 update A = alpha x x^H + A of the
...@@ -259,7 +250,6 @@ ...@@ -259,7 +250,6 @@
:element-types :float :element-types :float
:inputs (x y A) :inputs (x y A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"If the first two arguments are vectors, compute "If the first two arguments are vectors, compute
the symmetric rank-2 update A = alpha x y^T + alpha y x^T + A of the the symmetric rank-2 update A = alpha x y^T + alpha y x^T + A of the
...@@ -285,7 +275,6 @@ ...@@ -285,7 +275,6 @@
:element-types :complex :element-types :complex
:inputs (x A) :inputs (x A)
:outputs (A) :outputs (A)
:return (A)
:documentation ; FDL :documentation ; FDL
"If the first two arguments are vectors, compute the "If the first two arguments are vectors, compute the
hermitian rank-2 update A = alpha x y^H + alpha^* y x^H A of hermitian rank-2 update A = alpha x y^H + alpha^* y x^H A of
......
;; BLAS level 3, Matrix-matrix operations ;; BLAS level 3, Matrix-matrix operations
;; Liam Healy, Wed Apr 26 2006 - 21:08 ;; Liam Healy, Wed Apr 26 2006 - 21:08
;; Time-stamp: <2008-11-09 18:12:05EST blas3.lisp> ;; Time-stamp: <2008-12-07 18:27:01EST blas3.lisp>
;; $Id$ ;; $Id$
(in-package :gsl) (in-package :gsl)
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
:definition :methods :definition :methods
:element-types :float-complex :element-types :float-complex
:inputs (A B C) :inputs (A B C)
:outputs (C) :outputs (C))
:return (C))
(defmfun matrix-product-symmetric (defmfun matrix-product-symmetric
((A matrix) (B matrix) (C matrix) ((A matrix) (B matrix) (C matrix)
...@@ -40,8 +39,7 @@ ...@@ -40,8 +39,7 @@
:definition :methods :definition :methods
:element-types :float-complex :element-types :float-complex
:inputs (A B C) :inputs (A B C)
:outputs (C) :outputs (C))
:return (C))
(defmfun matrix-product-hermitian (defmfun matrix-product-hermitian
((A matrix) (B matrix) (C matrix) ((A matrix) (B matrix) (C matrix)
...@@ -55,8 +53,7 @@ ...@@ -55,8 +53,7 @@
:definition :methods :definition :methods
:element-types :complex :element-types :complex
:inputs (A B C) :inputs (A B C)
:outputs (C) :outputs (C))
:return (C))
(defmfun matrix-product-triangular (defmfun matrix-product-triangular
((A matrix) (B matrix) ((A matrix) (B matrix)
...@@ -69,8 +66,7 @@ ...@@ -69,8 +66,7 @@
:definition :methods :definition :methods
:element-types :float-complex :element-types :float-complex
:inputs (A B) :inputs (A B)
:outputs (B) :outputs (B))
:return (B))
(defmfun inverse-matrix-product (defmfun inverse-matrix-product
((A matrix) (B matrix) ((A matrix) (B matrix)
...@@ -85,8 +81,7 @@ ...@@ -85,8 +81,7 @@
:definition :methods :definition :methods
:element-types :float-complex :element-types :float-complex
:inputs (A B) :inputs (A B)
:outputs (B) :outputs (B))
:return (B))
(defmfun symmetric-rank-1-update (defmfun symmetric-rank-1-update
((A matrix) (C matrix) ((A matrix) (C matrix)
...@@ -98,8 +93,7 @@ ...@@ -98,8 +93,7 @@
:definition :methods :definition :methods
:element-types :float-complex :element-types :float-complex
:inputs (A C) :inputs (A C)
:outputs (C) :outputs (C))
:return (C))
(defmfun hermitian-rank-1-update (defmfun hermitian-rank-1-update
((A matrix) (C matrix) ((A matrix) (C matrix)
...@@ -111,8 +105,7 @@ ...@@ -111,8 +105,7 @@
:definition :methods :definition :methods
:element-types :complex :element-types :complex