|
From: Akshay S. <ak...@us...> - 2013-02-11 06:59:38
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "matlisp".
The branch, tensor has been updated
via f01e8cb0e33110ab72e6e828f052e7c534c84ebc (commit)
via 18563e60200ee394dc974dd81ec63a48e2b96ea5 (commit)
from 2bf1a9674740ca3829a86c45f0dc14a2ee3157c4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f01e8cb0e33110ab72e6e828f052e7c534c84ebc
Merge: 18563e6 2bf1a96
Author: Akshay Srinivasan <aks...@gm...>
Date: Sun Feb 10 22:58:47 2013 -0800
Merge branch 'tensor' of ssh://matlisp.git.sourceforge.net/gitroot/matlisp/matlisp into tensor
commit 18563e60200ee394dc974dd81ec63a48e2b96ea5
Author: Akshay Srinivasan <aks...@gm...>
Date: Sun Feb 10 22:58:21 2013 -0800
Brought the &rest argument back to tensor-ref. Changed function names for static methods for tensor classes.
diff --git a/src/base/standard-tensor.lisp b/src/base/standard-tensor.lisp
index 4e8e80a..8ef5435 100644
--- a/src/base/standard-tensor.lisp
+++ b/src/base/standard-tensor.lisp
@@ -294,7 +294,7 @@
(setf (number-of-elements tensor) sz)))))))))
;;
-(defgeneric tensor-ref (tensor subscripts)
+(defgeneric tensor-ref (tensor &rest subscripts)
(:documentation "
Syntax
======
@@ -312,7 +312,7 @@
of the store."))
-(defgeneric (setf tensor-ref) (value tensor subscripts))
+(defgeneric (setf tensor-ref) (value tensor &rest subscripts))
;;
(defgeneric tensor-store-ref (tensor store-idx)
@@ -362,12 +362,12 @@
(defclass ,vector (standard-vector ,tensor-class)
())
;;Store refs
- (defmethod tensor-ref ((tensor ,tensor-class) subs)
- (let-typed ((lidx (store-indexing subs tensor) :type index-type)
+ (defmethod tensor-ref ((tensor ,tensor-class) &rest subs)
+ (let-typed ((lidx (store-indexing (if (typep (car subs) '(or cons vector)) (car subs) subs) tensor) :type index-type)
(sto-x (store tensor) :type ,(linear-array-type store-element-type)))
(,reader sto-x lidx)))
- (defmethod (setf tensor-ref) (value (tensor ,tensor-class) subs)
- (let-typed ((lidx (store-indexing subs tensor) :type index-type)
+ (defmethod (setf tensor-ref) (value (tensor ,tensor-class) &rest subs)
+ (let-typed ((lidx (store-indexing (if (typep (car subs) '(or cons vector)) (car subs) subs) tensor) :type index-type)
(sto-x (store tensor) :type ,(linear-array-type store-element-type)))
(,value-writer (,coercer-unforgiving value) sto-x lidx)))
(defmethod tensor-store-ref ((tensor ,tensor-class) lidx)
diff --git a/src/classes/complex-tensor.lisp b/src/classes/complex-tensor.lisp
index 382641a..df2c0a2 100644
--- a/src/classes/complex-tensor.lisp
+++ b/src/classes/complex-tensor.lisp
@@ -14,41 +14,41 @@
'(cl:complex complex-base-type))
;;Field operations
-(definline complex-type.f+ (a b)
+(definline complex-typed.f+ (a b)
(declare (type complex-type a b))
(+ a b))
-(definline complex-type.f- (a b)
+(definline complex-typed.f- (a b)
(declare (type complex-type a b))
(- a b))
-(definline complex-type.finv+ (a)
+(definline complex-typed.finv+ (a)
(declare (type complex-type a))
(- a))
-(definline complex-type.fid+ ()
+(definline complex-typed.fid+ ()
#c(0.0d0 0.0d0))
-(definline complex-type.f* (a b)
+(definline complex-typed.f* (a b)
(declare (type complex-type a b))
(* a b))
-(definline complex-type.f/ (a b)
+(definline complex-typed.f/ (a b)
(declare (type complex-type a b))
(/ a b))
-(definline complex-type.finv* (a)
+(definline complex-typed.finv* (a)
(declare (type complex-type a))
(/ a))
-(definline complex-type.fid* ()
+(definline complex-typed.fid* ()
#c(1.0d0 0.0d0))
-(definline complex-type.fconj (a)
+(definline complex-typed.fconj (a)
(declare (type complex-type a))
(conjugate a))
-(definline complex-type.f= (a b)
+(definline complex-typed.f= (a b)
(declare (type complex-type a b))
(= a b))
@@ -76,33 +76,33 @@
(restart-case (coerce-complex-base-unforgiving x)
(use-value (value) (coerce-complex-base value))))
;;
-(definline complex-type.reader (tstore idx)
+(definline complex-typed.reader (tstore idx)
(declare (type complex-store-vector tstore)
(type index-type idx))
(complex (aref tstore (* 2 idx))
(aref tstore (1+ (* 2 idx)))))
-(definline complex-type.value-writer (value store idx)
+(definline complex-typed.value-writer (value store idx)
(declare (type complex-store-vector store)
(type index-type idx)
(type complex-type value))
(setf (aref store (* 2 idx)) (realpart value)
(aref store (1+ (* 2 idx))) (imagpart value)))
-(definline complex-type.value-incfer (value store idx)
+(definline complex-typed.value-incfer (value store idx)
(declare (type complex-store-vector store)
(type index-type idx)
(type complex-type value))
(incf (aref store (* 2 idx)) (realpart value))
(incf (aref store (1+ (* 2 idx))) (imagpart value)))
-(definline complex-type.reader-writer (fstore fidx tstore tidx)
+(definline complex-typed.reader-writer (fstore fidx tstore tidx)
(declare (type complex-store-vector fstore tstore)
(type index-type fidx tidx))
(setf (aref tstore (* 2 tidx)) (aref fstore (* 2 fidx))
(aref tstore (1+ (* 2 tidx))) (aref fstore (1+ (* 2 fidx)))))
-(definline complex-type.swapper (fstore fidx tstore tidx)
+(definline complex-typed.swapper (fstore fidx tstore tidx)
(declare (type complex-store-vector fstore tstore)
(type index-type fidx tidx))
(rotatef (aref tstore (* 2 tidx)) (aref fstore (* 2 fidx)))
@@ -113,16 +113,16 @@
(:documentation "Tensor class with complex elements."))
:matrix complex-matrix :vector complex-vector
;;
- :f+ complex-type.f+
- :f- complex-type.f-
- :finv+ complex-type.finv+
- :fid+ complex-type.fid+
- :f* complex-type.f*
- :f/ complex-type.f/
- :finv* complex-type.finv*
- :fid* complex-type.fid*
- :f= complex-type.f=
- :fconj complex-type.fconj
+ :f+ complex-typed.f+
+ :f- complex-typed.f-
+ :finv+ complex-typed.finv+
+ :fid+ complex-typed.fid+
+ :f* complex-typed.f*
+ :f/ complex-typed.f/
+ :finv* complex-typed.finv*
+ :fid* complex-typed.fid*
+ :f= complex-typed.f=
+ :fconj complex-typed.fconj
;;
:store-allocator allocate-complex-store
:coercer coerce-complex
@@ -130,11 +130,11 @@
;;
:matrix complex-matrix :vector complex-vector
;;
- :reader complex-type.reader
- :value-writer complex-type.value-writer
- :value-incfer complex-type.value-incfer
- :reader-writer complex-type.reader-writer
- :swapper complex-type.swapper)
+ :reader complex-typed.reader
+ :value-writer complex-typed.value-writer
+ :value-incfer complex-typed.value-incfer
+ :reader-writer complex-typed.reader-writer
+ :swapper complex-typed.swapper)
;;
#+nil
diff --git a/src/classes/real-tensor.lisp b/src/classes/real-tensor.lisp
index ac5d144..9224e61 100644
--- a/src/classes/real-tensor.lisp
+++ b/src/classes/real-tensor.lisp
@@ -9,64 +9,64 @@
`(simple-array real-type (,size)))
;;Field definitions
-(definline real-type.f+ (a b)
+(definline real-typed.f+ (a b)
(declare (type real-type a b))
(+ a b))
-(definline real-type.f- (a b)
+(definline real-typed.f- (a b)
(declare (type real-type a b))
(- a b))
-(definline real-type.finv+ (a)
+(definline real-typed.finv+ (a)
(declare (type real-type a))
(- a))
-(definline real-type.fid+ ()
+(definline real-typed.fid+ ()
0.0d0)
-(definline real-type.f* (a b)
+(definline real-typed.f* (a b)
(declare (type real-type a b))
(* a b))
-(definline real-type.f/ (a b)
+(definline real-typed.f/ (a b)
(declare (type real-type a b))
(/ a b))
-(definline real-type.finv* (a)
+(definline real-typed.finv* (a)
(declare (type real-type a))
(/ a))
-(definline real-type.fid* ()
+(definline real-typed.fid* ()
1.0d0)
-(definline real-type.fid= (a b)
+(definline real-typed.fid= (a b)
(declare (type real-type a b))
(= a b))
;;Store definitions
-(definline real-type.reader (tstore idx)
+(definline real-typed.reader (tstore idx)
(declare (type index-type idx)
(type real-store-vector tstore))
(aref tstore idx))
-(definline real-type.value-writer (value store idx)
+(definline real-typed.value-writer (value store idx)
(declare (type index-type idx)
(type real-store-vector store)
(type real-type value))
(setf (aref store idx) value))
-(definline real-type.value-incfer (value store idx)
+(definline real-typed.value-incfer (value store idx)
(declare (type index-type idx)
(type real-store-vector store)
(type real-type value))
(incf (aref store idx) value))
-(definline real-type.reader-writer (fstore fidx tstore tidx)
+(definline real-typed.reader-writer (fstore fidx tstore tidx)
(declare (type index-type fidx tidx)
(type real-store-vector fstore tstore))
(setf (aref tstore tidx) (aref fstore fidx)))
-(definline real-type.swapper (fstore fidx tstore tidx)
+(definline real-typed.swapper (fstore fidx tstore tidx)
(declare (type index-type fidx tidx)
(type real-store-vector fstore tstore))
(rotatef (aref tstore tidx) (aref fstore fidx)))
@@ -88,26 +88,26 @@ Allocates real storage. Default initial-element = 0d0.")
(:documentation "Tensor class with real double elements."))
:matrix real-matrix :vector real-vector
;;
- :f+ real-type.f+
- :f- real-type.f-
- :finv+ real-type.finv+
- :fid+ real-type.fid+
- :f* real-type.f*
- :f/ real-type.f/
- :finv* real-type.finv*
- :fid* real-type.fid*
- :f= real-type.fid=
+ :f+ real-typed.f+
+ :f- real-typed.f-
+ :finv+ real-typed.finv+
+ :fid+ real-typed.fid+
+ :f* real-typed.f*
+ :f/ real-typed.f/
+ :finv* real-typed.finv*
+ :fid* real-typed.fid*
+ :f= real-typed.fid=
:fconj nil
;;
:store-allocator allocate-real-store
:coercer coerce-real
:coercer-unforgiving coerce-real-unforgiving
;;
- :reader real-type.reader
- :value-writer real-type.value-writer
- :value-incfer real-type.value-incfer
- :reader-writer real-type.reader-writer
- :swapper real-type.swapper)
+ :reader real-typed.reader
+ :value-writer real-typed.value-writer
+ :value-incfer real-typed.value-incfer
+ :reader-writer real-typed.reader-writer
+ :swapper real-typed.swapper)
(defmethod print-element ((tensor real-tensor)
element stream)
diff --git a/src/classes/symbolic-tensor.lisp b/src/classes/symbolic-tensor.lisp
index 0365929..4e2c7e2 100644
--- a/src/classes/symbolic-tensor.lisp
+++ b/src/classes/symbolic-tensor.lisp
@@ -9,44 +9,44 @@
`(simple-array symbolic-type (,size)))
;;Field definitions
-(definline symbolic-type.f+ (a b)
+(definline symbolic-typed.f+ (a b)
(declare (type symbolic-type a b))
(maxima::add a b))
-(definline symbolic-type.f- (a b)
+(definline symbolic-typed.f- (a b)
(declare (type symbolic-type a b))
(maxima::sub a b))
-(definline symbolic-type.finv+ (a)
+(definline symbolic-typed.finv+ (a)
(declare (type symbolic-type a))
(maxima::mul -1 a))
-(definline symbolic-type.fid+ ()
+(definline symbolic-typed.fid+ ()
0)
-(definline symbolic-type.f* (a b)
+(definline symbolic-typed.f* (a b)
(declare (type symbolic-type a b))
(maxima::mul a b))
-(definline symbolic-type.f/ (a b)
+(definline symbolic-typed.f/ (a b)
(declare (type symbolic-type a b))
(maxima::div a b))
-(definline symbolic-type.finv* (a)
+(definline symbolic-typed.finv* (a)
(declare (type symbolic-type a))
(maxima::div 1 a))
-(definline symbolic-type.fid* ()
+(definline symbolic-typed.fid* ()
1)
-(definline symbolic-type.f= (a b)
+(definline symbolic-typed.f= (a b)
(declare (type symbolic-type a b))
(maxima::equal a b))
-(definline symbolic-type.fconj (a)
+(definline symbolic-typed.fconj (a)
(maxima::meval `((maxima::$conjugate maxima::simp) ,a)))
-(definline symbolic-type.diff (a x)
+(definline symbolic-typed.diff (a x)
(etypecase a
(symbolic-type
(maxima::$diff a x))
@@ -56,29 +56,29 @@
:store (map 'symbolic-store-vector #'(lambda (f) (maxima::$diff f x)) (store a))))))
;;
;;Store definitions
-(definline symbolic-type.reader (tstore idx)
+(definline symbolic-typed.reader (tstore idx)
(declare (type index-type idx)
(type symbolic-store-vector tstore))
(aref tstore idx))
-(definline symbolic-type.value-writer (value store idx)
+(definline symbolic-typed.value-writer (value store idx)
(declare (type index-type idx)
(type symbolic-store-vector store)
(type symbolic-type value))
(setf (aref store idx) value))
-(definline symbolic-type.value-incfer (value store idx)
+(definline symbolic-typed.value-incfer (value store idx)
(declare (type index-type idx)
(type symbolic-store-vector store)
(type symbolic-type value))
- (setf (aref store idx) (symbolic-type.f+ (aref store idx) value)))
+ (setf (aref store idx) (symbolic-typed.f+ (aref store idx) value)))
-(definline symbolic-type.reader-writer (fstore fidx tstore tidx)
+(definline symbolic-typed.reader-writer (fstore fidx tstore tidx)
(declare (type index-type fidx tidx)
(type symbolic-store-vector fstore tstore))
(setf (aref tstore tidx) (aref fstore fidx)))
-(definline symbolic-type.swapper (fstore fidx tstore tidx)
+(definline symbolic-typed.swapper (fstore fidx tstore tidx)
(declare (type index-type fidx tidx)
(type symbolic-store-vector fstore tstore))
(rotatef (aref tstore tidx) (aref fstore fidx)))
@@ -99,26 +99,26 @@ Allocates symbolic storage. Default initial-element = 0.")
(:documentation "Tensor class with symbolic double elements."))
:matrix symbolic-matrix :vector symbolic-vector
;;
- :f+ symbolic-type.f+
- :f- symbolic-type.f-
- :finv+ symbolic-type.finv+
- :fid+ symbolic-type.fid+
- :f* symbolic-type.f*
- :f/ symbolic-type.f/
- :finv* symbolic-type.finv*
- :fid* symbolic-type.fid*
- :f= symbolic-type.f=
- :fconj symbolic-type.fconj
+ :f+ symbolic-typed.f+
+ :f- symbolic-typed.f-
+ :finv+ symbolic-typed.finv+
+ :fid+ symbolic-typed.fid+
+ :f* symbolic-typed.f*
+ :f/ symbolic-typed.f/
+ :finv* symbolic-typed.finv*
+ :fid* symbolic-typed.fid*
+ :f= symbolic-typed.f=
+ :fconj symbolic-typed.fconj
;;
:store-allocator allocate-symbolic-store
:coercer coerce-symbolic
:coercer-unforgiving coerce-symbolic-unforgiving
;;
- :reader symbolic-type.reader
- :value-writer symbolic-type.value-writer
- :value-incfer symbolic-type.value-incfer
- :reader-writer symbolic-type.reader-writer
- :swapper symbolic-type.swapper)
+ :reader symbolic-typed.reader
+ :value-writer symbolic-typed.value-writer
+ :value-incfer symbolic-typed.value-incfer
+ :reader-writer symbolic-typed.reader-writer
+ :swapper symbolic-typed.swapper)
(defmethod initialize-instance ((tensor symbolic-tensor) &rest initargs)
(if (getf initargs :store)
diff --git a/src/ffi/foreign-vector.lisp b/src/ffi/foreign-vector.lisp
index f70c459..1521986 100644
--- a/src/ffi/foreign-vector.lisp
+++ b/src/ffi/foreign-vector.lisp
@@ -18,24 +18,14 @@
(defun fv-ref (x n)
(declare (type foreign-vector x)
(type fixnum n))
- (let ((sap (fv-pointer x))
- (ss (fv-size x))
- (sty (fv-type x)))
- (unless (< -1 n ss)
- (error 'out-of-bounds-error :requested n :bound ss
- :message "From inside fv-ref."))
- (cffi:mem-aref sap sty n)))
+ (assert (< -1 n (fv-size x)) nil 'out-of-bounds-error :requested n :bound (fv-size x) :message "From inside fv-ref.")
+ (cffi:mem-aref (fv-pointer x) (fv-type x) n))
(defun (setf fv-ref) (value x n)
(declare (type foreign-vector x)
(type fixnum n))
- (let ((sap (fv-pointer x))
- (ss (fv-size x))
- (sty (fv-type x)))
- (unless (< -1 n ss)
- (error 'out-of-bounds-error :requested n :bound ss
- :message "From inside (setf fv-ref)."))
- (setf (cffi:mem-aref sap sty n) value)))
+ (assert (< -1 n (fv-size x)) nil 'out-of-bounds-error :requested n :bound (fv-size x) :message "From inside fv-ref.")
+ (setf (cffi:mem-aref (fv-pointer x) (fv-type x) n) value))
;;; Rudimentary support for making it a bit easier to deal with Fortran
;;; arrays in callbacks.
-----------------------------------------------------------------------
Summary of changes:
src/base/standard-tensor.lisp | 12 +++---
src/classes/complex-tensor.lisp | 60 ++++++++++++++++++------------------
src/classes/real-tensor.lisp | 56 ++++++++++++++++----------------
src/classes/symbolic-tensor.lisp | 64 +++++++++++++++++++-------------------
src/ffi/foreign-vector.lisp | 18 ++--------
5 files changed, 100 insertions(+), 110 deletions(-)
hooks/post-receive
--
matlisp
|