Karim Belabas on Sun, 22 Jan 2017 23:04:08 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Question on printing a matrix... |
* wraithx@morpheus.net [2017-01-22 22:50]: > Is there a way to print a matrix that looks as nice as when you view it on > the gp command line? > > For example, if I do: > (15:43) gp > a=factor(12) > %13 = > [2 2] > > [3 1] > > (15:43) gp > a > %14 = > [2 2] > > [3 1] > > (15:43) gp > print(a) > [2, 2; 3, 1] > > I'd like to "print" that matrix and get the same output as just doing "a" on > the command line. Is there a way to do this? For more information, I'll be > doing this inside of a function. When I just put: > a; > on its own line, I do not get any output on the screen. When I do: > print(a); > I get the output shown last above. I'd like to get the %14 output to happen > inside that function. Is this possible? The corresponding libpari function is not exported to GP, you have to 'install' it: (22:54) gp > install("outmat","vG") (22:54) gp > a = factor(12) %2 = [2 2] [3 1] (22:54) gp > outmat(a) [2 2] [3 1] Another way which happens to work here but will not (in general) be equivalent to typing on the command line is (22:54) gp > printf("%d", a) [2 2] [3 1] Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `