oldk1331 wrote:
>
> This is a preliminary patch. I think there is no need to call
> "normalize" in hashUpdate! ?
>
> diff --git a/src/algebra/float.spad b/src/algebra/float.spad
> index 3996e67..0f06e64 100644
> --- a/src/algebra/float.spad
> +++ b/src/algebra/float.spad
> @@ -977,6 +977,9 @@
> (q0, q1) := (q1, q2)
> (s, t) := (t, r)
>
> + hashUpdate!(s : HashState, x : %) : HashState ==
> + t : RN := x.mantissa * 2::RN^x.exponent
> + hashUpdate!(s, t)
This may be pretty bad performancewise: in FriCAS exponents
are unlimited, so you may attempt to create number too big
to fit into available memory. Or spent a lot of time
handling huge numbers.
Calling 'normalize' would be wrong: 'normalize' may change
value.
> --% Float: arbitrary precision floating point arithmetic domain
>
> diff --git a/src/algebra/fraction.spad b/src/algebra/fraction.spad
> index b4c564c..2e26261 100644
> --- a/src/algebra/fraction.spad
> +++ b/src/algebra/fraction.spad
> @@ -280,6 +280,10 @@
> coerce(d : S) : % == [d, 1]
> zero?(x : %) == zero? x.num
>
> + hashUpdate!(s : HashState, x : %) ==
> + s := hashUpdate!(s, x.num)
> + s := hashUpdate!(s, x.den)
> + s
>
> if S has GcdDomain and S has canonicalUnitNormal then
> retract(x : %) : S ==
This definition is valid only if domain has canonical representation.
Several interesting domains have, but some do not. Notably, field
of fractions of algebraic extentions do not have canonical
representation. So this definition should be conditional.
In general, domain without canonical representation are pain
to hash. For sets there is resonable solution using symmetric
functions like sum. But in other cases what I was able
imagine essentially boils down to forcing canonical representation
first and then hashing.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.