[BACK]Return to r-fd.rr CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-port / cgi

Annotation of OpenXM/src/asir-port/cgi/r-fd.rr, Revision 1.4

1.4     ! takayama    1: /* $OpenXM: OpenXM/src/asir-port/cgi/r-fd.rr,v 1.3 2014/07/31 07:00:41 takayama Exp $ */
1.1       takayama    2: load("tk_fd.rr")$
1.2       takayama    3: import("tk_r.rr")$
1.3       takayama    4: import("oh_number.rr")$
                      5:
                      6: /* r_d2rat(0.3)  --> precision loss in truncation if not ctrl("bigfloat",1) */
                      7: ctrl("bigfloat",1)$
                      8: def r_d2rat(Y) {
                      9:   if ((type(Y) ==4)||(type(Y)==5)||(type(Y)==6)) return map(r_d2rat,Y);
                     10:   if ((type(Y)  == 1) && (ntype(Y) >= 1)) {
                     11:     S = rtostr(Y);  Y = "eval(("+S+")*exp(0));";
                     12:     /* print(Y); */
                     13:     Y = eval_str(Y);
1.4     ! takayama   14:     /* printf("Y=%a\n",Y); */
        !            15:     /* return oh_number.rats(Y); */
        !            16:     return rats2(Y);  /* temporary  */
1.3       takayama   17:   }else return Y;
                     18: }
1.1       takayama   19: def r_ahvec(A,B,C,Y) {
1.3       takayama   20:   Y = r_d2rat(Y);
1.1       takayama   21:   R=tk_fd.ygahvec(A,B,C,Y|all=1);
                     22:   Gamma=R[1];
                     23:   Der=R[0];
                     24:   Z=R[2]*Gamma;
                     25:   Der2 = newvect(length(Der));
                     26:   for (I=0; I<length(Der); I++) Der2[I] = Der[I]*Gamma;
                     27:   Der2 = vtol(Der2);
                     28:   Ans=cons(Z,Der2);
                     29:   /*  Fans=map(rtostr,map(tk_fd.tk_number_rattofloat,Ans)); */
                     30:   Fans=map(deval,Ans);
1.2       takayama   31:   Fans = tk_r.asir2r_c(Fans);
1.1       takayama   32:   return Fans;
                     33: }
1.4     ! takayama   34:
        !            35: /* temporary */
        !            36: def rats2(X) {
        !            37:   if (X == 0) return 0;
        !            38:   Sign=1;
        !            39:   if (X <0) {Sign=-1  ; X = -X;}
        !            40:   Digit = number_floor(eval(log(X)/log(10)));
        !            41:   Num = number_floor((X/(10^Digit))*10^20);
        !            42:   return Sign*(Num/(10^20))*(10^Digit);
        !            43: }
        !            44:
        !            45: def checkrats2() {
        !            46:   for (I=0; I<10; I++) {
        !            47:      Sign=(-1)^(random()%2);
        !            48:      X = eval(exp(0)*(random()/random())*10^(Sign*(random()%300))); /* 308 */
        !            49:      printf("X=%a\n",X);
        !            50:      Y = rats2(X);
        !            51:      printf("Y=%a\n",Y);
        !            52:      if (number_abs(eval(Y*exp(0))/X-1) > 0.0000001) {
        !            53:         printf("error: X = %a, Y=%a\n",X,Y);
        !            54:      }
        !            55:   }
        !            56: }
1.1       takayama   57: end$

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>