New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vector-set, slight tidying in structure (autodiff #3) #220
Conversation
Codecov Report
@@ Coverage Diff @@
## sritchie/diff_two #220 +/- ##
====================================================
Coverage ? 84.20%
====================================================
Files ? 79
Lines ? 8072
Branches ? 440
====================================================
Hits ? 6797
Misses ? 835
Partials ? 440 Continue to review full report at Codecov.
|
1355cf0
to
20e1d3f
Compare
@@ -0,0 +1,130 @@ | |||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for optimization of differential tags? I wonder if it is worth specializing it to numbers
This PR adds a "vector set" implementation that we'll use in #221 to implement
Differential
. A "vector set" is a vector of distinct, sorted elements, used to represent a set more cheaply than an actual set.Rather than make a
deftype
and make this a real thing that matches the set interface (and perhaps discover in the process that Clojure has already optimized small sets to work just as fast, gulp!), vector sets you make withmake
stay correct if you stay inside the supplied API.NOTE for @littleredcomputer - a
(sorted-set)
is actually very fast for conj, disj, set operations... but slower to return its greatest element.Also, from the CHANGELOG:
sicmutils.structure/opposite
returns an identicalstructure with flipped orientation (Add vector-set, slight tidying in structure (autodiff #3) #220). acts as
identity
fornon-structures.
NOTE: for reference, this idea is also called a "flat set" in boost. Technically a Clojure vector-based set is NOT flat, since vectors are implemented with a hash trie... whatever. Once we start benchmarking maybe we can replace this with a set.