# Variable initialisation file.
# This file is read by wims for new sessions.

level=$[$level]
!if $level!=NaN and $level>0 and $level<=8
# levels:		  1 2 3   4   5 6   7 8
 totdim  =!word $level of 2 3 3   4   5 6   7 8
 range1  =!word $level of 1 2 2   3   4 5   5 5
 range2  =!word $level of 2 2 3   3   5 5   6 6
 sup1    =!word $level of 1 1 1   1   2 2   3 4
 sup2    =!word $level of 1 1 2   2   2 2   3 4
 severity=!word $level of 1 1 1.2 1.5 2 2.5 3 4
!endif

!bound totdim between integer 2 and 8 default 3
mid=!randint floor($totdim/2),ceil($totdim/2)
!bound subdim between integer 1 and $totdim-1 default $mid
comdim=$[$totdim-$subdim]
!bound range1 between integer 1 and 5 default 3
!bound range2 between integer 2 and 6 default 4
range=2*$range1*$range2
!bound sup1   between integer 1 and 4 default 1
!bound sup2   between integer 1 and 4 default 2
!bound givtype within vec,sys default sys
!bound gettype within vec,sys default vec
!bound severity between 1 and 4 default 1

pariout=!exec pari r=0;while(r<$subdim,a=matrix($subdim,$totdim,x,y,random(2*$range1+1)-$range1);r=matrank(a)); print(a)\
	k=matker(a)~;print(denominator(k)*k)\
	t=matker(k)~;print(denominator(t)*t)\
	r=0;while(r<$subdim,b=matrix($subdim+$sup1,$subdim,x,y,random(2*$range2+1)-$range2);r=matrank(b)); print(b*a)\
	d=matrix($sup2,$totdim,x,y,random(2*$range+1)-$range);print(d)\
	print("OK");
!distribute lines $pariout into basesub,syssub,basesub2,vec1,vec2,OK
!if OK notwordof $OK
 error=init_fail
 !exit
!endif
syspari=$syssub
baspari=$basesub2

!for i in basesub,syssub,basesub2,vec1,vec2
 $i=!translate ; to $\
$ in $($i)
!next i
vecs=!append line $vec2 to $vec1
vecs=!trim $vecs
n=!linecnt $vecs
tt=!shuffle $n
vecs=!line $tt of $vecs

!if $gettype=sys
 sub=$basesub2
 basesub2=$syssub
 syssub=$sub
!endif
syssize=!linecnt $syssub

status=waiting
wims_module_log=$cmd: dim=$totdim, sup=$[$sup1+$sup2], severity $severity

