You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set uses hashing for quick (potentially false positive) equality check in inclusion (log(n)), followed by isequal check to avoid false positive. Thus set equalities have cost of n log(n) instead of n^2 without the use of a smart datastructure.
Initially there was a worry that Set uses ==, which would have broken its use with Symbolics (where == is used to create a symbolic equation), but that does not seem to be the case.
To avoid creating a new Set at every equality check, we should probably have it as part of the structure. E.g.
@withmetadata struct SAdd{T<:QObj} <: Symbolic{T}
dict
_set_precomputed
_arguments_precomputed
end
It will take a bit more memory (not much given that the objects are not copied, only referenced), but it should speed up a lot of other code.
pinging @apkille as we had been discussing this in #40
The text was updated successfully, but these errors were encountered:
I think a hash is not defined for these objects so it defaults to memory id as hash. Defining a hash function should take care of this (and they have a pretty simple standard definition in this case along the lines of hash(arguments(expr)) (but it should be the two-argument hash)).
we already have
Set uses hashing for quick (potentially false positive) equality check in inclusion (
log(n)
), followed byisequal
check to avoid false positive. Thus set equalities have cost ofn log(n)
instead ofn^2
without the use of a smart datastructure.Initially there was a worry that Set uses
==
, which would have broken its use with Symbolics (where==
is used to create a symbolic equation), but that does not seem to be the case.To avoid creating a new
Set
at every equality check, we should probably have it as part of the structure. E.g.It will take a bit more memory (not much given that the objects are not copied, only referenced), but it should speed up a lot of other code.
pinging @apkille as we had been discussing this in #40
The text was updated successfully, but these errors were encountered: