Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
18136 bpr 1
!! this file is an option for anstype litexp (or other)
2
!! it checks if wims_read_parm is a developped and reduced polynom of Z[x]
17282 guerimand 3
!! no bracket
18136 bpr 4
!! each term should have to be simplified using power of the variable (x*x not accepted for x^2)
5
!! each coefficient has to be calculated (3*5*x^2 not accepted)
6
!! only for polynom with one variable and coefficients in Z
7
!!
17282 guerimand 8
!! error checked :
9
!! - notreduced termealgsimp : x*x instead of x^2
18136 bpr 10
!! - notreduced termesamepower : several terms with same power of variable
11
!! - notreduced termenumsimp : numerical coefficient of a term is not calculated
17282 guerimand 12
!! - notreduced parenthesis : use of parenthesis
13
!! - usedivide : use of / symbol
18411 bpr 14
!set var =!varlist nofn $wims_read_parm
15
!set varcnt =!itemcnt $var
16
!if $varcnt>1
17
  !exit
18
!endif
17282 guerimand 19
nb_=!charcnt $wims_read_parm
20
nbt=0
18136 bpr 21
!reset terme ltermes wrong checkd_
17282 guerimand 22
k_=1
23
!while ($k_<=$nb_ and $wrong=$empty) or $terme!=$empty
17292 guerimand 24
  c_=!char $k_ of $wims_read_parm
25
  !if ($c_=+ or $c_=-) or $k_>$nb_
26
    !if $terme!=$empty
27
      !! analyse du terme
28
      t_=!replace internal * by , in $terme
29
      !distribute item 0,0 into flag_var,flag_num
17356 guerimand 30
      !distribute item 1,0 into kk_,p_
17292 guerimand 31
      nb2_=!itemcnt $t_
32
      !while $kk_<=$nb2_ and $wrong=$empty
33
        tt_=!item $kk_ of $t_
34
        ttt_=$[$tt_*1]
35
        !if $ttt_=NaN
36
          !if $flag_var=1
37
            !! check of produce of variable (not use of puissance)
38
            wrong=badform notreduced termealgsimp $terme
39
          !else
40
            flag_var=1
17356 guerimand 41
            !!puissance check
42
            ttt_=!replace internal ^ by , in $tt_
43
            ttt_=!item 2 of $ttt_
17360 guerimand 44
            !if $ttt_!=$empty and $ttt_<=1
17356 guerimand 45
              wrong=badform notreduced power0 $terme
17292 guerimand 46
            !endif
17356 guerimand 47
            !default ttt_=1
48
            p_=$[$p_+$ttt_]
17292 guerimand 49
          !endif
50
        !else
51
          !if $flag_num=1
52
            wrong=badform notreduced termenumsimp $terme
53
          !endif
17356 guerimand 54
          !if $flag_var=1
55
            wrong=badform notreduced constantbefore $terme
56
          !endif
17292 guerimand 57
          flag_num=1
58
        !endif
59
        !increase kk_
60
      !endwhile
17360 guerimand 61
      !increase nbt
62
      pp_=!positionof item $p_ in $checkd_
63
      !if $pp_!=$empty and $wrong=$empty
64
        wrong=badform notreduced termesamepower $(ltermes[$pp_]),$terme
17356 guerimand 65
      !else
17511 guerimand 66
        checkd_=!append item $p_ to $checkd_
17356 guerimand 67
      !endif
17292 guerimand 68
      ltermes=!append item $terme to $ltermes
69
      !if $k_>$nb_ or $c_=+
70
        !reset terme
71
      !else
72
        terme=-
73
      !endif
74
    !endif
75
  !else
76
    !if $c_ isin ()
77
      wrong=badform notreduced parenthesis
78
    !else
79
      !if $c_=/
18206 reyssat 80
        wrong=badform usebadchar /
17292 guerimand 81
      !else
82
        terme=$terme$c_
83
      !endif
84
    !endif
85
  !endif
18292 reyssat 86
  !if ($terme=$empty) and ($c_=-)
87
    terme=-
88
  !endif
17292 guerimand 89
  !increase k_
17282 guerimand 90
!endwhile