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

!bound size between integer 2 and 10 default 4
!bound type within matrix,system default system
!bound range between integer 4 and 999 default 9
!bound style within user,random default random
!bound field within Q,Z,C,G,F1,F2,F3,F4 default Q
!bound click within yes,no default yes

!if $field iswordof Z G
 click=no
!endif

character=0
!if F isin $field
 c=!char 2 of $field
 cl=!line $c of 3\
   5,7\
   13,17,19,23\
   41,43,47,53,59,61,67,71,73
 character=!randitem $cl
!endif

# contenu du fichier: initialisation du probleme.

ranco=(floor(random((2*$$range+1)*10^10)/10^10)-$$range)
ranz=random(3)-1
!if $field iswordof C G
 range=$[floor($range/2)]
 ranco=$ranco+$ranco*I
 ranz=$ranz+($ranz)*I
!endif

!if $field iswordof Q C
 mkmatrix=a=0;while(a==0,M=matrix($size,$size,x,y,$ranco);if(random(1000)<400,M[1,1]=0);a=matdet(M))
!endif

!if $field iswordof Z G
 mkmatrix=M=matid($size);b=M;for(i=1,5,c=b;d=b;for(row=1,$size-1,for(col=row+1,$size,c[row,col]=$ranz;d[col,row]=$ranz));M=M*c*d)
!endif

!if F isin $field
 ranco=Mod(random($character),$character)
 mkmatrix=a=0;while(a==0,M=matrix($size,$size,x,y,$ranco);if(random(1000)<400,M[1,1]=Mod(0,$character));M=lift(M);a=matdet(M)%$character)
!endif

!if $type=system
 const_origin=
 !if $field iswordof Q Z
  !for i=1 to $size
   c=!randint -$range,$range
   const_origin=!append item $c to $const_origin
  !next i
 !endif
 !if $field iswordof C G
  !for i=1 to $size
   c=!randint -$range,$range
   d=!randint -$range,$range
   !if $d<0
    sign=
   !else
    sign=+
   !endif
   const_origin=!append item $c$sign$d*i to $const_origin
  !next i
 !endif
 !if F isin $field
  !for i=1 to $size
   c=!randint 0,$character-1
   const_origin=!append item $c to $const_origin
  !next i
 !endif
!endif

mat=!exec pari $mkmatrix; print(M)\
	print(a);\
	print(matid($size));\
	print(mattranspose(M));\
	print([$const_origin]);
mat=!mathsubst I=i in $mat
det=!line 2 of $mat
reference_origin=!line 3 of $mat
transpose_origin=!line 4 of $mat
!if $field iswordof C G
 const_origin=!line 5 of $mat
!endif
matrix_origin=!line 1 of $mat
transpose_origin=!translate ; to $\
$ in $transpose_origin
laststep=0
!read proc.restart
status=waiting
wims_module_log=$cmd: $type $(size)x$size over $field

