init and converts are indeed supposed to be morphisms from/to any other domain, satisfying some
composition condition: init(convert(x))=x.
Any field has to define at least one morphism from Integers, but I strongly disagree with the idea
that it should be the only one: we do not want to pay the price of a cast to Integer or even to
double in order to convert an int16_t to an int64_t.
One should allow fields to define any pair of such morphisms and let the prorammer of such fields be
in charge of avoiding ambiguity.
Le 29/05/2015 02:57, B Saunders a écrit :
> Incidentally, this is the behavior I want for init/convert on finite rings and polynomial rings over
> finite rings.
> For Field::Element e, f, and integer i,j or (double i,j and F.cardinality() < 2^52)
> F.areEqual(e, init(f, convert(i, e))) // init composed with convert is identity on F.
>
> Init is a bijection of 0..F.cardinality() - 1 to F (for finite ring)
Ok with that
>
> Init is also a bijection of 0.. F.characteristic()-1 to the prime subfield of F, with
> init(e, i) having the property that e = F.one added i times.
This is a too strong requirement. For example, this is not compatible with the use of Kronecker
substitutions (i.e. evaluate a polynomial in an element) to convert a field extension to integers.
More generally, we always hit the same design issue: we implicitely assume that the type of the
second arg to an init defines the semantic of how elements are represented over this type.
Maybe init/convert still have a too wide usage and we should
1/ restrict it to what Dave proposed: a canonical integer representation of elements, with
init/converts from/to Integer only.
2/ create morphisms outside the definition of a field, templated by the InField and OutField
Example:
Morphism < Givaro::GFqDom<int>, ZRing<double> > (const int src, double& dest);
What do you think?
Clément
>
> When the ring is finite and i >= 0,
> convert(j, init(e, i)) == i % F.cardinality()
>
> I don't specify a generic meaning for init from a negative integer. In particular, I don't require
> F.areEqual(F.mOne, init(e, -1)). I note that this is tested for in Givaro/tests/test-ffarith.
> I propose that individual fields/rings can choose their own behavior on negative integers.
>
>
> Best,
> -dave
>
> --
> Prof. B. David Saunders,
302-831-6238, CIS Department, University of Delaware
>
> On Tue, May 26, 2015 at 10:38 AM, Alexis Breust <
alexis...@gmail.com
> <mailto:
alexis...@gmail.com>> wrote:
>
> Hello dave,
>
> So, using just the double/integer interface will implicitly convert long long to double?
> Should I then cast it myself to an integer before calling init: init(a, integer(k)); to be sure
> I loose no precision?
>
> Anyhow, I like the idea, of having a clean init interface.
>
> Best,
> Alexis.
>
> --
> You received this message because you are subscribed to the Google Groups "linbox-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
>
linbox-devel...@googlegroups.com <mailto:
linbox-devel...@googlegroups.com>.
> <mailto:
linbox...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google Groups "linbox-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
>
linbox-devel...@googlegroups.com <mailto:
linbox-devel...@googlegroups.com>.
> <mailto:
linbox...@googlegroups.com>.