diff options
author | dos-reis <gdr@axiomatics.org> | 2010-03-01 08:16:36 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-03-01 08:16:36 +0000 |
commit | 89122c246b751bba715be67884000a0ef236975d (patch) | |
tree | 6d008a27d0394538dd435e8968ae3735e887cf1e /src | |
parent | 6dc0a8a511253741245a48bd02d4f6861b1a938b (diff) | |
download | open-axiom-89122c246b751bba715be67884000a0ef236975d.tar.gz |
* algebra/vector.spad.pamphlet (maxIndex$Vector): Define.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/algebra/strap/VECTOR.lsp | 65 | ||||
-rw-r--r-- | src/algebra/vector.spad.pamphlet | 10 |
3 files changed, 49 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3b5cef38..e5f8d552 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-03-01 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * algebra/vector.spad.pamphlet (maxIndex$Vector): Define. + 2010-02-28 Gabriel Dos Reis <gdr@cs.tamu.edu> * algebra/boolean.spad.pamphlet diff --git a/src/algebra/strap/VECTOR.lsp b/src/algebra/strap/VECTOR.lsp index 6b8ecf36..e6ac08f8 100644 --- a/src/algebra/strap/VECTOR.lsp +++ b/src/algebra/strap/VECTOR.lsp @@ -4,23 +4,32 @@ (DECLAIM (FTYPE (FUNCTION (|%List| |%Shell|) |%Thing|) |VECTOR;vector;L$;1|)) +(DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Integer|) + |VECTOR;maxIndex;$I;2|)) + +(PUT '|VECTOR;maxIndex;$I;2| '|SPADreplace| '|sizeOfSimpleArray|) + (DECLAIM (FTYPE (FUNCTION (|%Thing| |%Shell|) |%Thing|) - |VECTOR;convert;$If;2|)) + |VECTOR;convert;$If;3|)) (DEFUN |VECTOR;vector;L$;1| (|l| $) (SPADCALL |l| (|getShellEntry| $ 10))) -(DEFUN |VECTOR;convert;$If;2| (|x| $) +(DEFUN |VECTOR;maxIndex;$I;2| (|x| $) + (DECLARE (IGNORE $)) + (|sizeOfSimpleArray| |x|)) + +(DEFUN |VECTOR;convert;$If;3| (|x| $) (SPADCALL - (LIST (SPADCALL '|vector| (|getShellEntry| $ 14)) - (SPADCALL (SPADCALL |x| (|getShellEntry| $ 15)) - (|getShellEntry| $ 16))) - (|getShellEntry| $ 18))) + (LIST (SPADCALL '|vector| (|getShellEntry| $ 15)) + (SPADCALL (SPADCALL |x| (|getShellEntry| $ 16)) + (|getShellEntry| $ 17))) + (|getShellEntry| $ 19))) -(DEFUN |Vector| (#0=#:G1406) +(DEFUN |Vector| (#0=#:G1407) (PROG () (RETURN - (PROG (#1=#:G1407) + (PROG (#1=#:G1408) (RETURN (COND ((LETT #1# @@ -40,7 +49,7 @@ (PROGN (LETT |dv$1| (|devaluate| |#1|) . #0=(|Vector|)) (LETT |dv$| (LIST '|Vector| |dv$1|) . #0#) - (LETT $ (|newShell| 35) . #0#) + (LETT $ (|newShell| 36) . #0#) (|setShellEntry| $ 0 |dv$|) (|setShellEntry| $ 3 (LETT |pv$| @@ -89,22 +98,24 @@ (|setShellEntry| $ 6 |#1|) (COND ((|testBitVector| |pv$| 3) - (|setShellEntry| $ 19 - (CONS (|dispatchFunction| |VECTOR;convert;$If;2|) $)))) + (|setShellEntry| $ 20 + (CONS (|dispatchFunction| |VECTOR;convert;$If;3|) $)))) $)))) (MAKEPROP '|Vector| '|infovec| (LIST '#(NIL NIL NIL NIL NIL (|IndexedVector| 6 (NRTEVAL 1)) (|local| |#1|) (|Integer|) (0 . |One|) (|List| 6) - (4 . |construct|) |VECTOR;vector;L$;1| (|OutputForm|) - (|InputForm|) (9 . |convert|) (14 . |parts|) - (19 . |convert|) (|List| $) (24 . |convert|) - (29 . |convert|) (|Mapping| 6 6 6) (|Boolean|) - (|NonNegativeInteger|) (|Equation| 6) (|List| 23) - (|Mapping| 21 6) (|Mapping| 21 6 6) (|UniversalSegment| 7) - (|Void|) (|Mapping| 6 6) (|Matrix| 6) (|SingleInteger|) - (|String|) (|Union| 6 '"failed") (|List| 7)) - '#(|vector| 34 |parts| 39 |convert| 44 |construct| 49) + (4 . |construct|) |VECTOR;vector;L$;1| + |VECTOR;maxIndex;$I;2| (|OutputForm|) (|InputForm|) + (9 . |convert|) (14 . |parts|) (19 . |convert|) (|List| $) + (24 . |convert|) (29 . |convert|) (|Mapping| 6 6 6) + (|Boolean|) (|NonNegativeInteger|) (|Equation| 6) + (|List| 24) (|Mapping| 22 6) (|Mapping| 22 6 6) + (|UniversalSegment| 7) (|Void|) (|Mapping| 6 6) + (|Matrix| 6) (|SingleInteger|) (|String|) + (|Union| 6 '"failed") (|List| 7)) + '#(|vector| 34 |parts| 39 |maxIndex| 44 |convert| 49 + |construct| 54) '((|shallowlyMutable| . 0) (|finiteAggregate| . 0)) (CONS (|makeByteWordVec2| 5 '(0 0 0 0 0 0 0 5 0 0 1 4 0 0 1 2 3 4)) @@ -126,11 +137,11 @@ (|OrderedSet|) (|Aggregate|) (|EltableAggregate| 7 6) (|Evalable| 6) (|SetCategory|) (|Type|) (|Eltable| 7 6) - (|InnerEvalable| 6 6) (|CoercibleTo| 12) - (|ConvertibleTo| 13) (|BasicType|)) - (|makeByteWordVec2| 19 - '(0 7 0 8 1 0 0 9 10 1 13 0 12 14 1 0 9 - 0 15 1 9 13 0 16 1 13 0 17 18 1 0 13 - 0 19 1 0 0 9 11 1 0 9 0 15 1 3 13 0 - 19 1 0 0 9 10))))) + (|InnerEvalable| 6 6) (|CoercibleTo| 13) + (|ConvertibleTo| 14) (|BasicType|)) + (|makeByteWordVec2| 20 + '(0 7 0 8 1 0 0 9 10 1 14 0 13 15 1 0 9 + 0 16 1 9 14 0 17 1 14 0 18 19 1 0 14 + 0 20 1 0 0 9 11 1 0 9 0 16 1 6 7 0 12 + 1 3 14 0 20 1 0 0 9 10))))) '|lookupIncomplete|)) diff --git a/src/algebra/vector.spad.pamphlet b/src/algebra/vector.spad.pamphlet index 292a8a01..e11e41e9 100644 --- a/src/algebra/vector.spad.pamphlet +++ b/src/algebra/vector.spad.pamphlet @@ -140,14 +140,18 @@ IndexedVector(R:Type, mn:Integer): ++ and indexed by a finite segment of integers starting at 1. Vector(R:Type): Exports == Implementation where - VECTORMININDEX ==> 1 -- if you want to change this, be my guest - Exports ==> VectorCategory R with vector: List R -> % ++ vector(l) converts the list l to a vector. Implementation ==> - IndexedVector(R, VECTORMININDEX) add + IndexedVector(R, 1) add vector l == construct l + -- We want maxIndex to be inlined. Ideally, the definition should + -- read + -- maxIndex x == # rep x + -- However, there is currently an infelicity in the compiler that + -- prevents good uses of dependent domains. So, we fall back to + maxIndex x == sizeOfSimpleArray(x)$Foreign(Builtin) if R has ConvertibleTo InputForm then convert(x:%):InputForm == convert [convert('vector)@InputForm, |