J E Cremona on Wed, 03 Oct 2018 17:48:11 +0200


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

vector version of gcdext?


The function gcd() allows 2 inputs as in gcd(2,3) or a vector of inputs as in gcd([6,10,15]),  but the extended version only allows the first form.  It would not be hard to write an extended vector version (and I can of course write my own) -- feature request?

One way to do this is using Smith Normal Form, i.e. matsnf.  But there is a problem when the input are polynomials:


 H = [6,10,15]
%3 = [6, 10, 15]
? matsnf(Mat(H),3)
%4 = [Mat(1), [-5, -30, -14; 3, 15, 7; 0, 2, 1], Mat([0, 0, 1])]
? H = [6,10,15]
%5 = [6, 10, 15]
? matsnf(Mat(H),1)
%6 = [Mat(1), [-5, -30, -14; 3, 15, 7; 0, 2, 1], Mat([0, 0, 1])]
? H = [x,x+1,x+2]
%7 = [x, x + 1, x + 2]
? matsnf(Mat(H),3)
  ***   at top-level: matsnf(Mat(H),3)
  ***                 ^----------------
  *** matsnf: inconsistent dimensions in gsmithall.
  ***   Break loop: type 'break' to go back to GP prompt

I used the flag value 3=1+2 to get the multiplier matrices and allow polynomials, but (as is documented) this is only implemented for square matrices in the polynomial case.  That means that I can pad the matrix using n-1 rows of zeros and extract the answer, but I would prefer not to have to do this.

John

--
Prof J E Cremona
Warwick Mathematics Institute
University of Warwick
http://www2.warwick.ac.uk/fac/sci/maths/people/staff/john_cremona/