Subversion Repositories wimsdev

Rev

Rev 20 | Rev 4158 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
!if $wims_read_parm!=slib_header
2
 !goto proc
3
!endif
4
slib_title=Generates a random invertible matrix
5
slib_parms=3\
6
2,matrix size\
7
2,coefficient range\
8
Z,coefficient ring: Z for the time being,Q,R,C,G (Gauss ring), n (n is an integer for Z/nZ)
9
slib_author=Gang Xiao
10
slib_out=the generated matrix
11
slib_example= 3,6
3265 bpr 12
slib_require=pari
20 reyssat 13
!exit
14
 
15
:proc
16
!distribute items $wims_read_parm into slib_size,slib_range,slib_ring
17
!default slib_ring=Z
18
!bound slib_size between integer 2 and 20 default 2
19
!bound slib_range between integer 1 and 1000000 default 2
20
 
21
!if $slib_ring=Z
22
 slib_sh1=!shuffle $slib_size
23
 slib_sh2=!shuffle $slib_size
24
 slib_ran1=(random(2*$slib_range)*(2*random(2)-1))
25
 slib_ran2=(random($slib_range)*(4*random(2)-2))
26
 slib_ran3=(random($slib_range)*(4*random(2)-2)+2*random(2)-1)
27
 slib_coef=if(x==y,$slib_ran3,if(x>y,$slib_ran2,$slib_ran1))
28
 slib_M1=vecextract(matrix($slib_size,$slib_size,x,y,$slib_coef),[$slib_sh1],[$slib_sh2])
29
 slib_M2=matrix($slib_size,$slib_size,x,y,$slib_ran1)
30
 slib_out=!exec pari M2=$slib_M2;if(matdet(M2)<>0,print(M2),print($slib_M1))
31
 !exit
32
!endif
33