hermann on Mon, 15 Jul 2024 23:00:49 +0200


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

Re: vector of t_FRAC questions


On 2024-07-15 22:35, Loïc Grenié wrote:
D) how to convert d to [10, 112, -5] in GP simpler?

        d/2*2, and maybe d*2/2, would probably have the expected
  effect. d*1 not...

Thanks, that helps:

? d
[81920/1, 917504/1, -40960/1]
? d*2/2
[81920, 917504, -40960]
?


Despite doc ...

? ?gcd
gcd(x,{y}): greatest common divisor of x and y.

?

... gcd works also if only x is passed and is a t_VEC:

? gcd(d)
8192/1
?

"d/gcd(d)" is what I searched for:

? d/gcd(d)
[10, 112, -5]
?


And "[d/gcd(d) | d<-dir]" for all build directions!

? get_all_build_directions(dir)
? dir
[[81920/1, 917504/1, -40960/1], [204800/1, 2293760/1, -102400/1], [122880/1, 1376256/1, -61440/1], [81920/1, 917504/1, -40960/1], [-122880/1, -1376256/1, 61440/1], [-40960/1, -458752/1, 20480/1], [-163840/1, -1835008/1, 81920/1], [-163840/1, -1835008/1, 81920/1]]
? [d/gcd(d) | d<-dir]
[[10, 112, -5], [10, 112, -5], [10, 112, -5], [10, 112, -5], [-10, -112, 5], [-10, -112, 5], [-10, -112, 5], [-10, -112, 5]]
?


Regards,

Hermann.