incr-set prlevel 1
if #0=5 START
incr-set prlevel -1
;;; Usage:
;;; 	<from_bigraded r s m n segre
;;;
;;;     If m is a bigraded module over Pr x Ps then n is set to
;;; the singly graded module over P^{rs+r+s} which
;;; represents the same sheaf as m, via the segre embedding.
;;;	    It is assumed that the current ring has at least
;;; rs+r+s+1 variables, and the first rs+r+s+1 of these are
;;; used.
incr-set prlevel 1
jump END
;;; Parameters:
;;;		r,s = positive integers 
;;;		m = bigraded module over a polynomial ring in
;;;         two sets of variables: the first r+1 and the next
;;;	        s+1.  m must be generated by forms of bidgree d,d
;;;	        for various d (that is, m must be a diagonal module.
;;; Output values:
;;;	    n = module over the current ring.
;;;	    segre = the segre map used
;;;
;;; If R = k[zij] is the current ring, and 
;;; S = k[ xi , yj ] is the bihomogeneous 
;;; base ring of m, then the desired module is the R-submodule
;;; of m generated by the given S-generators, via the segre
;;; map sending  zij  to   xi yj.
;;;
;;; If m is not generated by "diagonal" 
;;; elements (bidegrees equal),
;;; but, say by elements of bidegree d,e, then the result
;;; will correspond to the module m, regraded -- that is, twisted
;;; by a line bundel 0(d,e).
; created 5/15/89
START:
;get a handle to the current ring:
<getvars @curring

;Form the segre map
setring #3
<getvars @vars
submat @vars @vars1
	1
	1..#1+1
submat @vars @vars2
	1
	#1+2..#1+#2+2
transpose @vars2 @vars2
mult @vars2 @vars1 @segre
flatten @segre #5

setring @curring
<push_forward1 #5 #3 #4

kill @curring @vars @vars1 @vars2 @segre
END:
incr-set prlevel -1

$;;;;;;;; EXAMPLE SECTION ;;;;;;;;;;;;;;;;;;;;;;;;;
;Sheaves on P1 x P1:

;The bihomogeneous coordinate ring of P1xP1:
ring r
;
4
x[1]-x[2]
y[1]-y[2];
;
;

;The bihomogeneous ideal of a point:
ideal i
2
x[1]
y[1]

;A bihomogeneous ideal of the empty set:
ideal j
2
x[1]
x[2]

;The twisted cubic:
ideal k
1
x[1]y[1]2+x[2]y[2]2

;Note that the generator 1 in r is of degree 0,0

;The homogeneous coordinate ring of P3:
<ring 4 z[1,1]-z[2,2] s

<from_bigraded
<from_bigraded 1 1 i N segre
type segre
nres N N
betti N ;the ideal of a point
; total:      1     3     3     1 
; --------------------------------
;     0:      1     3     3     1 

<from_bigraded 1 1 j N segre
nres N N
betti N ;the ideal of the empty set
; total:      1     4     6     4     1 
; --------------------------------------
;     0:      1     4     6     4     1 

<from_bigraded 1 1 k N segre
std N N ;the ideal of the twisted cubic
hilb N
; codimension = 2
; degree      = 3
; genus       = 0
