Subversion Repositories wimsdev

Rev

Rev 4161 | Rev 7192 | 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
4161 bpr 4
 
20 reyssat 5
slib_parms=2\
6
 ,[x_1,...,x_n] \
7
 ,[a_1,...,a_m]
4330 bpr 8
slib_author=Adeline, Grelot; Bernadette, PERRIN-RIOU
4161 bpr 9
 
20 reyssat 10
slib_example=[1,1,1,3,4,5,6,2],[1,4,6]\
11
[1,1,1,3,4,5,6,2,7 ,4,7],[2,3,6]\
12
[1,1,1,3,4,5,6,2],[1,4]\
13
[1,1,1,3,4,5,6,2]
14
 
15
!exit
16
:proc
17
slib_out=
18
 
19
!readproc slib/stat/dataproc $wims_read_parm
20
 
21
slib_v=!declosing $slib_data
22
slib_w=!declosing $slib_weight
23
!if $slib_v$slib_w=$empty
24
	slib_out=0
25
	!exit
26
!else
27
	slib_v=!sort numeric item  of $slib_v
28
	slib_max=!item -1 of $slib_v
29
	slib_min=!item 1 of $slib_v
30
	slib_cnt= !itemcnt $slib_v
31
	slib_cntw=!itemcnt $slib_w
32
	!if $slib_cntw=2
33
		!distribute item $slib_w into slib_b,slib_p
34
		slib_c=$[ceil(($slib_max-$slib_b)/$slib_p)]
35
		slib_d=$[min(0,floor(($slib_min-($slib_b))/$slib_p))]
36
		slib_w=!values $slib_b+x*$slib_p for x=$slib_d to $slib_c
37
	!endif
38
	slib_w=!sort numeric item  of $slib_w
39
	!if $slib_w=$empty
40
		slib_N=$[ceil(4*($slib_cnt)^(1/4))]
41
		slib_w=!values $slib_min+x*$[(($slib_max-($slib_min))/$slib_N)] for x=0 to $slib_N
42
	!else
43
		slib_m=!item -1 of $slib_w
44
		slib_max=$[max($slib_max,$slib_m)]
45
		slib_m=!item 1 of $slib_w
46
		slib_min=$[min($slib_min,$slib_m)]
47
		slib_w=$slib_min,$slib_w,$slib_max
48
		slib_w= !listuniq $slib_w
49
	!endif
50
	slib_cpt=0
51
	slib_cntw=!itemcnt $slib_w
52
	slib_wpointer=2
53
# end est le point de separation
54
	slib_end=!item $slib_wpointer of $slib_w
55
	slib_result=
56
	!for slib_i=1 to $slib_cnt
57
 		slib_dat=!item $slib_i of $slib_v
58
		!if $slib_dat<$slib_end or ($slib_dat=$slib_max and $slib_wpointer=$slib_cntw)
59
  # On est toujours dans le meme intervalle
60
 			!advance slib_cpt
61
 		!else
62
  # Le point de separation franchi
63
  # creer un nouveau point de separation
64
:point
65
 			!advance slib_wpointer
66
 			 slib_end=!item $slib_wpointer of $slib_w
67
 			!if $slib_wpointer < $slib_cntw
68
 				slib_end1=!item $[$slib_wpointer+1] of $slib_w
69
			!else 
3129 bpr 70
				slib_end1=$[$slib_end+2]
20 reyssat 71
			!endif
72
		slib_result=!append item $[$slib_cpt] to $slib_result
3129 bpr 73
			!if $slib_dat>=$slib_end
20 reyssat 74
				slib_cpt=0
75
				!goto point
76
			!else
77
				slib_cpt=1
78
			!endif
79
		!endif
80
	!next slib_i
81
#Le dernier intervalle
82
	slib_result=!append item $[$slib_cpt] to $slib_result
83
	!if $[$slib_wpointer+1] <=$slib_cntw
84
		slib_zero=!values 0 for x=$[$slib_wpointer+1] to $slib_cntw
85
		slib_result=$slib_result,$slib_zero
86
	!endif
87
!endif
88
slib_out=!trim $slib_result
89
slib_out=!line -1 of $slib_out
90
slib_out=[$slib_out],[$slib_w]