|
22 | 22 | (make-instance 'vader-enclose :base (funcall function (vader-base (first base))))))))
|
23 | 23 | ((= 2 (length base))
|
24 | 24 | (let ((iota-first (and (typep (first base) 'integer)
|
25 |
| - (typep (second base) 'vapri-integer-progression))) |
26 |
| - (iota-second (and (typep (first base) 'vapri-integer-progression) |
| 25 | + (typep (second base) 'vapri-arith-provec))) |
| 26 | + (iota-second (and (typep (first base) 'vapri-arith-provec) |
27 | 27 | (typep (second base) 'integer)))
|
28 | 28 | (lex-ref (getf params :lexical-reference)))
|
29 | 29 | (cond ((and lex-ref (or (numberp (first base))
|
|
41 | 41 | lex-ref (member lex-ref arith-functions :test #'char=)
|
42 | 42 | (not (and iota-second (char= #\÷ lex-ref))))
|
43 | 43 | (destructuring-bind (iota number) (if iota-second base (reverse base))
|
44 |
| - (make-instance 'vapri-integer-progression |
| 44 | + (make-instance 'vapri-arith-provec |
45 | 45 | :number (vapip-number iota) :origin (vapip-origin iota)
|
46 | 46 | :offset (if (not (member lex-ref add-sub-functions :test #'char=))
|
47 | 47 | (vapip-offset iota)
|
|
60 | 60 | (funcall function number (vapip-factor iota)))))
|
61 | 61 | :repeat (vapip-repeat iota))))))))))))
|
62 | 62 |
|
| 63 | +(defun extend-allocator-vader-inverse-where (&key base argument index-origin) |
| 64 | + "Extend allocation behavior of inverse-where class; allows the use of ⍸⍣¯1 to create one-hot vectors." |
| 65 | + (declare (ignore argument)) |
| 66 | + (let ((base-shape (shape-of base))) |
| 67 | + (when (and (not (second base-shape)) |
| 68 | + (first base-shape) (= 1 (first base-shape))) |
| 69 | + (let ((base-val (funcall (generator-of base) 0))) |
| 70 | + (when (and (integerp base-val) (plusp base-val)) |
| 71 | + (make-instance 'vapri-onehot-vector :shape (list base-val) :index (- base-val index-origin))))))) |
| 72 | + |
| 73 | +(defun extend-allocator-vader-section (&key base argument inverse axis index-origin) |
| 74 | + "Extend allocation behavior of section class; allows resizing of one-hot vectors." |
| 75 | + (declare (ignore axis index-origin)) |
| 76 | + (typecase base |
| 77 | + (vapri-onehot-vector (when (or (not (listp argument)) |
| 78 | + (= 1 (length argument)))) |
| 79 | + (make-instance 'vapri-onehot-vector :shape (list argument) |
| 80 | + :index (vaohv-index base))))) |
| 81 | + |
63 | 82 | (defun extend-allocator-vader-permute (&key base argument index-origin)
|
64 | 83 | "Extend allocation behavior of permute class; allows simple inversion of permutation without an argument."
|
65 | 84 | (declare (ignore axis index-origin))
|
|
72 | 91 | "Extend allocation behavior of expand class; allows for 3/⍳3 to produce a repeating integer progression vector instead of a vader-expand instance."
|
73 | 92 | (declare (ignore axis index-origin inverse))
|
74 | 93 | (typecase base
|
75 |
| - (vapri-integer-progression |
| 94 | + (vapri-arith-provec |
76 | 95 | (let ((rendered-argument (unless (shape-of argument) (render argument))))
|
77 | 96 | (when (integerp rendered-argument)
|
78 |
| - (make-instance 'vapri-integer-progression |
| 97 | + (make-instance 'vapri-arith-provec |
79 | 98 | :number (vapip-number base) :origin (vapip-origin base)
|
80 | 99 | :offset (vapip-offset base) :factor (vapip-factor base)
|
81 | 100 | :repeat (* rendered-argument (vapip-repeat base))))))))
|
0 commit comments