hermann on Mon, 15 Jul 2024 22:01:52 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

vector of t_FRAC questions


I convert 3-dimensional vector or GMP mpq_t rational numbers from
CGAL function get_build_direction() to GP this way:

https://github.com/Hermann-SW/cgal4gp/blob/main/cgal4gp.cpp#L107-L123

extern "C"
GEN
get_build_direction() {
    assert(_simplex != NULL);
    _Vector_3 _dir = _simplex->get_build_direction();

    return mkvec3(
               mkfrac(
                   mpz2GEN(_dir[0].num.mpz()),
                   mpz2GEN(_dir[0].den.mpz())),
               mkfrac(
                   mpz2GEN(_dir[1].num.mpz()),
                   mpz2GEN(_dir[1].den.mpz())),
               mkfrac(
                   mpz2GEN(_dir[2].num.mpz()),
                   mpz2GEN(_dir[2].den.mpz())));
}

That works nicely, but I get denominators of 1:

$ gp -q tqf_width.gp
? G=[-67, -189, -200; 6, 17, 18; 1, 3, 3];
? Width([G*y~ | y<-SquaresRepresentations3(65)])
? d=get_build_direction()
[81920/1, 917504/1, -40960/1]
?


A) How to get conversion to t_INT in case of denominator 1?

B) Strange behavior of GP?

? simplify(d)
[81920/1, 917504/1, -40960/1]
? simplify([81920/1, 917504/1, -40960/1])
[81920, 917504, -40960]
?

C) Why does division by 1 not work, while division by gcd does?

? gcd(81920,gcd(917504,40960))
8192
? d/8192
[10, 112, -5]
? d/1
[81920/1, 917504/1, -40960/1]
?

D) how to convert d to [10, 112, -5] in GP simpler?


Computations above areb regarding 2nd example here:
https://github.com/Hermann-SW/cgal4gp/tree/main?tab=readme-ov-file#ternary-quadratic-form-width

Regards,

Hermann.