hi,
I think I am happe now with the API for binary operators,
To see where I am heading, consider the bitvector implementation. Here is e.g. how logxor is implemented
s1 logior s2 -> s2
(define (supervector-logxor! s1 s2)
(supervector-binary
;; The general case
logxor
;; The s1 part is a constant bin
(lambda (x)
(if (= x 0)
(values invert 0) ;; will invert the s2 part in case it is a full bin - fast
(values nothing 0) ;; will leace the s2 part non changes - fast
;; the s2 part is constant
(lambda (x)
(if (= x 0)
(values invert 0) ;; if s1 is ro? refere to it with negation if referable (fast)
(values nothing 0))) ;; replace s2 with s1 if referable (fast)
;; Both s1 and s2 are constant and s2 is a complete bin
logxor
s1
s2))
We have the following controls
(values add val) : will add the same val to all elements in the bin e.g. maybe stored in the bin
(values scale val) : will scale the same vale to all elements in the bin
(values nothing _) : will do nothing with the bin
(values replace val) : set the whole bin to val
(values invert _) : take lognot to the whole bin
(values negate _) : take not to the whole bin
With a good alignement of the bins and ability to reference bins if s2 is the constant part,
the code will successfully produce a fast application of the binary operators. This means that
clustered sparse bitvectors are well modeled in this system and for those vectors. especially
for advanced matching constructs with very large numbers of clauses it is possible to make the
matching fast and also the amount of memory needed to store the matcher is small.
We have a similar system for algebraic manipulation and for logical operations.
logxor is not in the current setup not applicated as a fast op however, but it is sent as a function into the
construct in higher order manner. This means that busy loops for fat vectors are a bit slow. When things
are debugged I will move over to macro versions which allow the busy loop to essentially be as fast as if we
did a logxor in a single loop of a bytevector which you can get at 100-200Mops per second. This can go much
faster like 1-2G ops per second if we push it to C.