Subversion Repositories wimsdev

Rev

Rev 13594 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13594 Rev 14851
Line 51... Line 51...
51
!default slib_constz=(z-$(slib_dataz[3]))*($(slib_dataz[4])-z)
51
!default slib_constz=(z-$(slib_dataz[3]))*($(slib_dataz[4])-z)
52
 
52
 
53
!! ==== list of given x : at least one given, and one unknown. ====
53
!! ==== list of given x : at least one given, and one unknown. ====
54
slib_givenx=1,0
54
slib_givenx=1,0
55
 
55
 
56
!! ==== compute a random x1 with significant digits matching the given precision  ====
56
!! ==== compute a random x1 with significant digits matching the given precision ====
57
slib_x1=!random $slib_randx
57
slib_x1=!random $slib_randx
58
slib_mul=$[10^($slib_prec-1-floor(lg($slib_x1)))]
58
slib_mul=$[10^($slib_prec-1-floor(lg($slib_x1)))]
59
slib_x1=$[rint($slib_mul*$slib_x1)/$slib_mul]
59
slib_x1=$[rint($slib_mul*$slib_x1)/$slib_mul]
60
 
60
 
61
!for slib_i from 3 to $slib_nc
61
!for slib_i from 3 to $slib_nc
62
  slib_r=!randint 0,1
62
  slib_r=!randint 0,1
63
  slib_givenx=$slib_givenx, $slib_r
63
  slib_givenx=$slib_givenx, $slib_r
64
  !if $slib_r=1
64
  !if $slib_r=1
65
    !!==== compute a random xi with significant digits matching the given precision  ====
65
    !!==== compute a random xi with significant digits matching the given precision ====
66
    slib_x$slib_i=!random $slib_randx
66
    slib_x$slib_i=!random $slib_randx
67
    slib_mul=$[10^($slib_prec-1-floor(lg($(slib_x$slib_i))))]
67
    slib_mul=$[10^($slib_prec-1-floor(lg($(slib_x$slib_i))))]
68
    slib_x$slib_i=$[rint($slib_mul*$(slib_x$slib_i))/$slib_mul]
68
    slib_x$slib_i=$[rint($slib_mul*$(slib_x$slib_i))/$slib_mul]
69
  !endif
69
  !endif
70
!next slib_i
70
!next slib_i
71
!!==== assert: every given x is an random number between xmin and xmax,  ====
71
!!==== assert: every given x is an random number between xmin and xmax, ====
72
!!==== with no more than prec significant digits. ======================
72
!!==== with no more than prec significant digits. ======================
73
 
73
 
74
!! ==== list of given y: at least one given, and one unknown. ====
74
!! ==== list of given y: at least one given, and one unknown. ====
75
slib_giveny=1,0
75
slib_giveny=1,0
76
 
76
 
77
 
77
 
78
!! ==== compute a random y1 with significant digits matching the given precision  ====
78
!! ==== compute a random y1 with significant digits matching the given precision ====
79
slib_y1=!random $slib_randy
79
slib_y1=!random $slib_randy
80
slib_mul=$[10^($slib_prec-1-floor(lg($slib_y1)))]
80
slib_mul=$[10^($slib_prec-1-floor(lg($slib_y1)))]
81
slib_y1=$[rint($slib_mul*$slib_y1)/$slib_mul]
81
slib_y1=$[rint($slib_mul*$slib_y1)/$slib_mul]
82
 
82
 
83
!for slib_i from 3 to $slib_nl
83
!for slib_i from 3 to $slib_nl
84
  slib_r=!randint 0,1
84
  slib_r=!randint 0,1
85
  slib_giveny=$slib_giveny, $slib_r
85
  slib_giveny=$slib_giveny, $slib_r
86
  !if $slib_r=1
86
  !if $slib_r=1
87
    !!==== compute a random yi with significant digits matching the given precision  ====
87
    !!==== compute a random yi with significant digits matching the given precision ====
88
    slib_y$slib_i=!random $slib_randy
88
    slib_y$slib_i=!random $slib_randy
89
    slib_mul=$[10^($slib_prec-1-floor(lg($(slib_y$slib_i))))]
89
    slib_mul=$[10^($slib_prec-1-floor(lg($(slib_y$slib_i))))]
90
    slib_y$slib_i=$[rint($slib_mul*$(slib_y$slib_i))/$slib_mul]
90
    slib_y$slib_i=$[rint($slib_mul*$(slib_y$slib_i))/$slib_mul]
91
  !endif
91
  !endif
92
!next slib_i
92
!next slib_i
93
!!==== assert: every given y is an random number between ymin and ymax,  ====
93
!!==== assert: every given y is an random number between ymin and ymax, ====
94
!!==== with no more than prec significant digits. ======================
94
!!==== with no more than prec significant digits. ======================
95
 
95
 
96
!!==== getting rid of any previous values of z_i_j ====
96
!!==== getting rid of any previous values of z_i_j ====
97
!for slib_i from 1 to $slib_nc
97
!for slib_i from 1 to $slib_nc
98
  !for slib_j from 1 to $slib_nl
98
  !for slib_j from 1 to $slib_nl
Line 117... Line 117...
117
      slib_range_noncomputablex=$slib_range_noncomputablex, $slib_i
117
      slib_range_noncomputablex=$slib_range_noncomputablex, $slib_i
118
    !endif
118
    !endif
119
  !endif
119
  !endif
120
!next slib_i
120
!next slib_i
121
!!=== assert : range_noncomputablex is the list of indexes for noncomputable x
121
!!=== assert : range_noncomputablex is the list of indexes for noncomputable x
122
!for  slib_r in $slib_range_noncomputablex
122
!for slib_r in $slib_range_noncomputablex
123
  !!==== gather the computable indexes for y ====
123
  !!==== gather the computable indexes for y ====
124
  slib_first=1
124
  slib_first=1
125
  !for slib_i=1 to $slib_nl
125
  !for slib_i=1 to $slib_nl
126
    !if $(slib_computabley[$slib_i]) = 1
126
    !if $(slib_computabley[$slib_i]) = 1
127
      !if $slib_first=1
127
      !if $slib_first=1
Line 130... Line 130...
130
      !else
130
      !else
131
        slib_range_computabley=$slib_range_computabley, $slib_i
131
        slib_range_computabley=$slib_range_computabley, $slib_i
132
      !endif
132
      !endif
133
    !endif
133
    !endif
134
  !next slib_i
134
  !next slib_i
135
  !!=== assert : range_computabley is the list of indexes for computable y  ====
135
  !!=== assert : range_computabley is the list of indexes for computable y ====
136
  slib_s=!randitem $slib_range_computabley
136
  slib_s=!randitem $slib_range_computabley
137
  !!==== assert: x is unknown and y is known for column r and row s ====
137
  !!==== assert: x is unknown and y is known for column r and row s ====
138
  constraint=-1
138
  constraint=-1
139
  maxwhile=20
139
  maxwhile=20
140
  currentwhile=0
140
  currentwhile=0
Line 152... Line 152...
152
    constraint=!mathsubst x=$(slib_x$(slib_r)) in $slib_constx
152
    constraint=!mathsubst x=$(slib_x$(slib_r)) in $slib_constx
153
  !endwhile
153
  !endwhile
154
  !!==== assert: the value of xr is strictly inside the range xmin .. xmax ====
154
  !!==== assert: the value of xr is strictly inside the range xmin .. xmax ====
155
  !!==== updating slib_givenz ====
155
  !!==== updating slib_givenz ====
156
  slib_givenz=!exec pari A=Mat([$slib_givenz]);\
156
  slib_givenz=!exec pari A=Mat([$slib_givenz]);\
157
                         B=matrix($slib_nl,$slib_nc,row,col,(row==$slib_s)*(col==$slib_r));\
157
    B=matrix($slib_nl,$slib_nc,row,col,(row==$slib_s)*(col==$slib_r));\
158
                         print(A+B);
158
    print(A+B);
159
  slib_givenz=!nospace $slib_givenz
159
  slib_givenz=!nospace $slib_givenz
160
  !! updating slib_computablex
160
  !! updating slib_computablex
161
  slib_computablex=!exec pari A=Vec([$slib_computablex]);\
161
  slib_computablex=!exec pari A=Vec([$slib_computablex]);\
162
                                B=vector($slib_nc,x,(x==$slib_r));\
162
    B=vector($slib_nc,x,(x==$slib_r));\
163
                                A+B
163
    A+B
164
  slib_computablex=!nospace $slib_computablex
164
  slib_computablex=!nospace $slib_computablex
165
!next slib_r
165
!next slib_r
166
!!==== assert: every x is computable ====
166
!!==== assert: every x is computable ====
167
 
167
 
168
!!==== gathering the non-computable indexes for y ====
168
!!==== gathering the non-computable indexes for y ====
Line 176... Line 176...
176
      slib_range_noncomputabley=$slib_range_noncomputabley, $slib_i
176
      slib_range_noncomputabley=$slib_range_noncomputabley, $slib_i
177
    !endif
177
    !endif
178
  !endif
178
  !endif
179
!next slib_i
179
!next slib_i
180
!!=== assert : range_noncomputabley is the list of indexes for noncomputable y
180
!!=== assert : range_noncomputabley is the list of indexes for noncomputable y
181
!for  slib_s in $slib_range_noncomputabley
181
!for slib_s in $slib_range_noncomputabley
182
  !!==== gather the computable indexes for x ====
182
  !!==== gather the computable indexes for x ====
183
  slib_first=1
183
  slib_first=1
184
  !for slib_i=1 to $slib_nc
184
  !for slib_i=1 to $slib_nc
185
    !if $(slib_computablex[$slib_i]) = 1
185
    !if $(slib_computablex[$slib_i]) = 1
186
      !if $slib_first=1
186
      !if $slib_first=1
Line 189... Line 189...
189
      !else
189
      !else
190
        slib_range_computablex=$slib_range_computablex, $slib_i
190
        slib_range_computablex=$slib_range_computablex, $slib_i
191
      !endif
191
      !endif
192
    !endif
192
    !endif
193
  !next slib_i
193
  !next slib_i
194
  !!=== assert : range_computablex is the list of indexes for computable x  ====
194
  !!=== assert : range_computablex is the list of indexes for computable x ====
195
  slib_r=!randitem $slib_range_computablex
195
  slib_r=!randitem $slib_range_computablex
196
  !!==== assert: x is known and y is unknown for column r and row s ====
196
  !!==== assert: x is known and y is unknown for column r and row s ====
197
  constraint=-1
197
  constraint=-1
198
  !while $constraint <= 0
198
  !while $constraint <= 0
199
    slib_z_$(slib_s)_$(slib_r)=!random $slib_randz
199
    slib_z_$(slib_s)_$(slib_r)=!random $slib_randz
Line 205... Line 205...
205
    constraint=!mathsubst y=$(slib_y$(slib_s)) in $slib_consty
205
    constraint=!mathsubst y=$(slib_y$(slib_s)) in $slib_consty
206
  !endwhile
206
  !endwhile
207
  !!==== assert: the value of ys is strictly inside the range ymin .. ymax ====
207
  !!==== assert: the value of ys is strictly inside the range ymin .. ymax ====
208
  !!==== updating slib_givenz ====
208
  !!==== updating slib_givenz ====
209
  slib_givenz=!exec pari A=Mat([$slib_givenz]);\
209
  slib_givenz=!exec pari A=Mat([$slib_givenz]);\
210
                         B=matrix($slib_nl,$slib_nc,row,col,(row==$slib_s)*(col==$slib_r));\
210
    B=matrix($slib_nl,$slib_nc,row,col,(row==$slib_s)*(col==$slib_r));\
211
                         print(A+B);
211
    print(A+B);
212
  slib_givenz=!nospace $slib_givenz
212
  slib_givenz=!nospace $slib_givenz
213
  !! updating slib_computabley
213
  !! updating slib_computabley
214
  slib_computabley=!exec pari A=Vec([$slib_computabley]);\
214
  slib_computabley=!exec pari A=Vec([$slib_computabley]);\
215
                              B=vector($slib_nl,y,(y==$slib_s));\
215
    B=vector($slib_nl,y,(y==$slib_s)); A+B
216
                              A+B
-
 
217
  slib_computabley=!nospace $slib_computabley
216
  slib_computabley=!nospace $slib_computabley
218
!next slib_s
217
!next slib_s
219
!!==== assert: every y is computable ====
218
!!==== assert: every y is computable ====
220
 
219
 
221
!!computing the non-given z_s_r
220
!!computing the non-given z_s_r
Line 237... Line 236...
237
slib_reply=1
236
slib_reply=1
238
slib_replies=
237
slib_replies=
239
!! slib_t will be a list of chunks of code to make a table when interleaved
238
!! slib_t will be a list of chunks of code to make a table when interleaved
240
!! with slib_replies
239
!! with slib_replies
241
slib_t=
240
slib_t=
242
slib_t=<table border=3><tr><th bgcolor='#AAFFAA' colspan="2" rowspan="2">$slib_namez ($slib_unitz)</th><th bgcolor='yellow' align='center' colspan="$slib_nc">$slib_namex ($slib_unitx)</th></tr><tr>
241
slib_t=<table class="wimsborder"><tr><th style='background-color:#AAFFAA' colspan="2" rowspan="2">$slib_namez ($slib_unitz)</th><th style='background-color:yellow;text-align:center' colspan="$slib_nc">$slib_namex ($slib_unitx)</th></tr><tr>
243
!for slib_i=1 to $slib_nc
242
!for slib_i=1 to $slib_nc
244
slib_c=$(slib_shx[$slib_i])
243
slib_c=$(slib_shx[$slib_i])
245
!if $(slib_givenx[$slib_c])=1
244
!if $(slib_givenx[$slib_c])=1
246
  slib_t=$slib_t <td bgcolor='yellow'>$(slib_x$slib_c) $slib_unitx</td>
245
  slib_t=$slib_t <td bgcolor='yellow'>$(slib_x$slib_c) $slib_unitx</td>
247
!else
246
!else
248
  slib_t=$slib_t <td bgcolor='yellow' style='padding:8'>,
247
  slib_t=$slib_t <td style='background-color:yellow;padding:8'>,
249
  slib_replies=$slib_replies $(slib_x$slib_c) $slib_unitx,
248
  slib_replies=$slib_replies $(slib_x$slib_c) $slib_unitx,
250
  slib_reply=$[$slib_reply+1]
249
  slib_reply=$[$slib_reply+1]
251
  slib_t=$slib_t </td>
250
  slib_t=$slib_t </td>
252
!endif
251
!endif
253
!next slib_i
252
!next slib_i
Line 255... Line 254...
255
!!<tr><td>
254
!!<tr><td>
256
!for slib_j=1 to $slib_nl
255
!for slib_j=1 to $slib_nl
257
  slib_l=$(slib_shy[$slib_j])
256
  slib_l=$(slib_shy[$slib_j])
258
  slib_t=$slib_t </tr><tr>
257
  slib_t=$slib_t </tr><tr>
259
  !if $slib_j=1
258
  !if $slib_j=1
260
    slib_t=$slib_t <th bgcolor='lightblue' valign='medium' rowspan="$slib_nl">$slib_namey<br/>($slib_unity)</th>
259
    slib_t=$slib_t <th style='background-color:lightblue;vertical-align:medium' rowspan='$slib_nl'>$slib_namey<br />($slib_unity)</th>
261
  !endif
260
  !endif
262
  !if $(slib_giveny[$slib_l])=1
261
  !if $(slib_giveny[$slib_l])=1
263
    slib_t=$slib_t <td bgcolor='lightblue'>$(slib_y$slib_l) $slib_unity</td>
262
    slib_t=$slib_t <td bgcolor='lightblue'>$(slib_y$slib_l) $slib_unity</td>
264
  !else
263
  !else
265
    slib_t=$slib_t <td bgcolor='lightblue' style='padding:8'>,
264
    slib_t=$slib_t <td style='background-color:lightblue;padding:8'>,
266
    slib_replies=$slib_replies $(slib_y$slib_l) $slib_unity,
265
    slib_replies=$slib_replies $(slib_y$slib_l) $slib_unity,
267
    slib_reply=$[$slib_reply+1]
266
    slib_reply=$[$slib_reply+1]
268
    slib_t=$slib_t </td>
267
    slib_t=$slib_t </td>
269
  !endif
268
  !endif
270
 !for slib_i=1 to $slib_nc
269
 !for slib_i=1 to $slib_nc
271
    slib_c=$(slib_shx[$slib_i])
270
    slib_c=$(slib_shx[$slib_i])
272
    !if $(slib_givenz[$slib_l;$slib_c])=1
271
    !if $(slib_givenz[$slib_l;$slib_c])=1
273
      slib_t=$slib_t <td bgcolor='#AAFFAA'>$(slib_z_$(slib_l)_$(slib_c)) $slib_unitz</td>
272
      slib_t=$slib_t <td style='background-color:#AAFFAA>'>$(slib_z_$(slib_l)_$(slib_c)) $slib_unitz</td>
274
    !else
273
    !else
275
      slib_t=$slib_t <td bgcolor='#AAFFAA' style='padding:8'>,
274
      slib_t=$slib_t <td style='background-color:#AAFFAA;padding:8'>,
276
      slib_replies=$slib_replies $(slib_z_$(slib_l)_$(slib_c)) $slib_unitz,
275
      slib_replies=$slib_replies $(slib_z_$(slib_l)_$(slib_c)) $slib_unitz,
277
      slib_reply=$[$slib_reply+1]
276
      slib_reply=$[$slib_reply+1]
278
      slib_t=$slib_t </td>
277
      slib_t=$slib_t </td>
279
    !endif
278
    !endif
280
  !next slib_i
279
  !next slib_i
Line 285... Line 284...
285
slib_replies=$(slib_replies[1 to $slib_reply])
284
slib_replies=$(slib_replies[1 to $slib_reply])
286
 
285
 
287
slib_table=$(slib_t[1])
286
slib_table=$(slib_t[1])
288
!for slib_i=1 to $slib_reply
287
!for slib_i=1 to $slib_reply
289
  !if $slib_dbg=1
288
  !if $slib_dbg=1
290
    slib_table=$slib_table <input type='text' name='reply$slib_i' value='$(slib_replies[$slib_i])'/> $(slib_t[$[$slib_i+1]])
289
    slib_table=$slib_table <input type='text' name='reply$slib_i' value='$(slib_replies[$slib_i])' /> $(slib_t[$[$slib_i+1]])
291
  !else
290
  !else
292
    slib_table=$slib_table <input type='text' name='reply$slib_i'/> $(slib_t[$[$slib_i+1]])
291
    slib_table=$slib_table <input type='text' name='reply$slib_i' /> $(slib_t[$[$slib_i+1]])
293
  !endif
292
  !endif
294
!next slib_i
293
!next slib_i
295
 
294
 
296
slib_out= $slib_table, $slib_reply, $slib_replies, $slib_t
295
slib_out= $slib_table, $slib_reply, $slib_replies, $slib_t
297
!goto end
296
!goto end