
!bound prtype within points,explicit,implicit,parametric default points
!bound eqtype within points,explicit,implicit,parametric,pointint,parametricint default explicit
!bound objdim between integer 1 and 4 default 1
!bound spacedim between integer $objdim+1 and 6 default $[$objdim+1]
codim=$[$spacedim-$objdim]
range=13
integer=0
!if $eqtype=pointint
 eqtype=points
 integer=1
!endif
!if $eqtype=parametricint
 eqtype=parametric
 integer=1
!endif

!if $prtype=$eqtype
 !if $prtype!=points
  eqtype=points
 !else
  eqtype=implicit
 !endif
!endif

varnames=!item 1 to $spacedim of x,y,z,u,v,w
parmnames=!line $objdim of t\
	s,t\
	r,s,t\
	p,r,s,t\
	p,q,r,s,t
var1=!items $objdim+1 to $spacedim of $varnames
var2=!item 1 to $objdim of $varnames

random=(random(2*$range+1)-$range)
!if $eqtype=explicit or $prtype=explicit
 ranktest=vecextract(mat,"1..$objdim")
!else
 ranktest=mat
!endif

ker=kernel=matker(mat)~;
!if $prtype=explicit
  ker=k=matker(mat)~; D=vecextract(k,"$[$objdim+1]..$spacedim");\
  k=D^-1*k; const=k*orig~;\
  kernel=concat(-vecextract(k,"1..$objdim"),const); 
!endif
!if $prtype=implicit
  ker=k=matker(mat)~; r=0;\
  while(r<$codim,\
    perm=matrix($codim,$codim,m,n,random(5)-2); r=matrank(perm);\
  );\
  k=perm*k; D=denominator(k); kernel=D*k;\
  for(n=1,$codim,kernel[n,]=kernel[n,]/content(kernel[n,]));\
  kernel=concat(kernel,kernel*orig~);
!endif

pari_header={\
	rk=0;\
	while(rk<$objdim,\
		mat=matrix($objdim,$spacedim,x,y,$random);\
		rk=matrank($ranktest);\
	);\
	orig=vector($spacedim,x,$random);\
	aff=matrix($objdim+1,$spacedim,x,y,0);\
	for(i=1,$objdim,aff[i,]=mat[i,]+orig);\
	aff[$objdim+1,]=orig;\
	$ker\
}
pari_out=!exec pari print(aff)\
	print(mat~)\
	print(orig)\
	print(kernel)
!distribute lines $pari_out into points,mat1,origin,kernel
points=!translate ; to $\
$ in $points
mat1=!translate ; to $\
$ in $mat1
kernel=!translate ; to $\
$ in $kernel

status=waiting
penalty=0
wims_module_log=$cmd $prtype->$eqtype $objdim/$spacedim

