incr-set prlevel 1
if #0>2 START
incr-set prlevel -1
;;; Usage:
;;; 	<scroll a1 .. an i m
;;;
;;;     Makes i the ideal of the rational normal
;;; scroll of type a1 a2 ... an,
;;; a variety of
;;; dimension n and degree d = \sum_i ai in
;;; P^r, where r = d+n-1.  
;;;     Makes m the usual matrix whose 2x2 minors generate i.
;;;
;;;     Uses the first d+n variables from the current ring.
;;;
incr-set prlevel 1
jump END
;;; Parameters:
;;;	    a1 .. an = non-negative integers
;;; Output values:
;;;	    i the ideal of minors of the matrix m which is
;;;
;;; 	x[0] .. x[a1-1] y[0] .. y[a2-1] .. 
;;;     x[1] .. x[a1]   y[1] .. y[a2]   ..
;;;
;;; where the variables in the current ring are
;;; x[0] .. x[a1] y[0] .. y[a2] .. . This is the ideal of
;;; the variety 
;;; S(a1,..,an)
;;; which is the image of the projectivization
;;; of the bundle O(a1) + .. + O(an) on P1, embedded by
;;; O(1).
;;; 
;;; m is a presentation matrix for
;;; the line bundle O_{scroll} (F), where F
;;; is the ruling, as a module over the homogeneous
;;; coordinate ring of Pr.
;;;
;;; Caveats:  This should be modularized, with a script
;;; making m and another making i from it; but there is
;;; currently no way of passing lists of integers of
;;; indefinite length.

; created July 16, 1989
START:

;CHECK to make sure the ring has enough variables:
;initialize:
int @i 0
int @vars_used 0
int @varstot 0

checkloop:
int @i @i+1
int @varstot @varstot+1+#@i
if @i<(#0)-2 checkloop

poly @curring 0
nvars @curring @nvars
if @varstot<=@nvars ENDCHECK
shout echo NOT ENOUGH VARIABLES FOR SCROLL: NEEDED
shout type @varstot
shout echo HAVE
shout type @nvars
jump END1
ENDCHECK:

;THE MAIN CONSTRUCTION STARTS HERE
;initialize:
int @i 0
int @vars_used 0
mat @m
2
0

;make the desired matrix:
loop:

int @i @i+1
int @length (#@i)-1
cat @vars_used @mtemp
0 1
0..@length
concat @m @mtemp
int @vars_used @vars_used+1+#@i
if @i<(#0)-2 loop

;output the results:
wedge @m 2 @i
int @nparams #0
copy @m #@nparams
copy @i #(@nparams-1)

kill @m @length @mtemp @nparams

END1:
kill @i @vars_used @varstot @nvars @curring
END:
incr-set prlevel -1

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

;The scrolls in P5:
<ring 6 a-z r
set prlevel -1

<scroll 5 i m ;the rational normal curve
type m
type i

;cone on the twisted quartic with vertex b=c=d=e=f=0
<scroll 0 4 i m  
type m
type i

<scroll 1 3 i m ;S(1,3) = F_2
type m
type i

<scroll 2 2 i m ;S(2,2) = v_2(P1 x P1) 
type m
type i

<scroll 1 1 1 i m ;S(1,1,1) = P1 x P1 x P1
type m
type i

;check the error checking mechanism:
<ring 5 a-z r
<scroll 5 i m ;the rational normal curve

listvars
