incr_set prlevel 1
if #0>4 START
incr_set prlevel -1
;;; Usage:
;;;     <2byn n s1 s2 .. sn m t1 .. tm k u1 e1 u2 e2 .. uk ek M I
;;; Produces a 2 x ? matrix in Kronecker
;;; Weierstrass normal form, along with
;;; the ideal of 2 x 2 minors, with a
;;; standard basis computed.
;;;
incr_set prlevel 1
jump END
;;; Parameters: n m k - the number of scroll, nilpotent, and
;;;			jordan blocks in M, respectively
;;;		s1 .. sn - the lengths of the scroll blocks
;;;		t1 .. tm - the lengths of the nilpotent blocks
;;;		u1 .. uk - the lengths of the jordan blocks
;;;		e1 .. ek - the eigenvalues of the jordan blocks
;;;
;;; Output values: M - the 2 x (whatever) matrix
;;;		   I - the ideal of 2x2 minors of M, with a
;;;		       standard basis computed
;;;
; created ... 2/25/92 by M. Johnson
START:

int @numvars 0

int @i 1

int @scrollpart #1
if @scrollpart=0 ENDpreloop
preloop:
	int @i @i+1
	int @numvars @numvars+#(@i)+1
	if @i<@scrollpart+1 preloop
ENDpreloop:

int @i @i+1

int @nilpotentpart #(@i)
if @nilpotentpart=0 ENDpreloop2
preloop2:
	int @i @i+1
	int @numvars @numvars+#(@i)-1
	if @i<@scrollpart+@nilpotentpart+2 preloop2
ENDpreloop2:

int @i @i+1

int @jordanpart #(@i)
if @jordanpart=0 ENDpreloop3
preloop3:
	int @i @i+1
	int @numvars @numvars+#(@i)
	int @i @i+1
	if @i<@scrollpart+@nilpotentpart+(2*@jordanpart)+3 preloop3
ENDpreloop3:

<ring @numvars a-z R

int @curvar 1
int @i 1

; @scrollpart is the number of succeeding
; arguments which are to be devoted to
; the scroll part of the 2xn matrix.

mat @m
2
0

if @scrollpart=0 ENDscroll

loop:
	int @i @i+1
	int @length #(@i)-1
	cat @curvar-1 @mtemp
		0 1
		0..@length
	concat @m @mtemp
	int @curvar @curvar+1+#@i
	if @i<@scrollpart+1 loop

ENDscroll:

int @i @i+1

if @nilpotentpart=0 ENDnilpotent

loop2:
	int @i @i+1
	int @length #(@i)
	<nilpotent0 @curvar @length @mtemp
	concat @m @mtemp
	int @curvar @curvar-1+@length
	if @i<@scrollpart+@nilpotentpart+2 loop2

ENDnilpotent:

int @i @i+1

int @eigenvalue 0
if @jordanpart=0 ENDjordan

loop3:
	int @i @i+1
	type @i
	int @length #(@i)
	int @i @i+1
	int @eigenvalue #(@i)
	<jordan0 @curvar @length @eigenvalue @mtemp
	concat @m @mtemp
	int @curvar @curvar+@length
	if @i<@scrollpart+@nilpotentpart+(2*@jordanpart)+3 loop3

ENDjordan:

int @i @i+1

setdegs @m
;
;

copy @m #(@i)
wedge @m 2 @I
std @I @I
copy @I #(@i+1)

kill @scrollpart @nilpotentpart @jordanpart @numvars
kill @i @length @m @mtemp @curvar @eigenvalue @I

END:
incr_set prlevel -1

$;;;;;;;; EXAMPLE SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;

% <2byn 1 13 2 3 3 1 3 4 M I
 
% type M

; a b c d e f g h i j k l m o p 0 q r 0 s    t    u  
; b c d e f g h i j k l m n 0 o p 0 q r 4s+t 4t+u 4u 


