version 1.2, 2014/07/31 06:24:11 |
version 1.8, 2015/02/28 11:39:13 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/asir-port/cgi/r-fd.rr,v 1.7 2015/02/25 04:47:50 takayama Exp $ */ |
load("tk_fd.rr")$ |
load("tk_fd.rr")$ |
import("tk_r.rr")$ |
import("tk_r.rr")$ |
|
import("oh_number.rr")$ |
|
|
|
/* r_d2rat(0.3) --> precision loss in truncation if not ctrl("bigfloat",1) */ |
|
ctrl("bigfloat",1)$ |
|
def r_d2rat(Y) { |
|
if ((type(Y) ==4)||(type(Y)==5)||(type(Y)==6)) return map(r_d2rat,Y); |
|
if ((type(Y) == 1) && (ntype(Y) >= 1)) { |
|
S = rtostr(Y); Y = "eval(("+S+")*exp(0));"; |
|
/* print(Y); */ |
|
Y = eval_str(Y); |
|
/* printf("Y=%a\n",Y); */ |
|
/* return oh_number.rats(Y); */ |
|
return rats2(Y); /* temporary */ |
|
}else return Y; |
|
} |
def r_ahvec(A,B,C,Y) { |
def r_ahvec(A,B,C,Y) { |
R=tk_fd.ygahvec(A,B,C,Y|all=1); |
Y = r_d2rat(Y); |
|
Ans=a_ahvec(A,B,C,Y); |
|
/* Fans=map(rtostr,map(tk_fd.tk_number_rattofloat,Ans)); */ |
|
Fans=map(deval,Ans); |
|
Fans = tk_r.asir2r_c(Fans); |
|
return Fans; |
|
} |
|
|
|
def a_ahvec(A,B,C,Y) { |
|
R=tk_fd.ahvec_abc(A,B,C,Y|all=1); |
Gamma=R[1]; |
Gamma=R[1]; |
Der=R[0]; |
Der=R[0]; |
Z=R[2]*Gamma; |
Z=R[2]*Gamma; |
Line 10 def r_ahvec(A,B,C,Y) { |
|
Line 34 def r_ahvec(A,B,C,Y) { |
|
for (I=0; I<length(Der); I++) Der2[I] = Der[I]*Gamma; |
for (I=0; I<length(Der); I++) Der2[I] = Der[I]*Gamma; |
Der2 = vtol(Der2); |
Der2 = vtol(Der2); |
Ans=cons(Z,Der2); |
Ans=cons(Z,Der2); |
/* Fans=map(rtostr,map(tk_fd.tk_number_rattofloat,Ans)); */ |
return(Ans); |
Fans=map(deval,Ans); |
} |
|
|
|
/* temporary */ |
|
def rats2(X) { |
|
if (X == 0) return 0; |
|
Sign=1; |
|
if (X <0) {Sign=-1 ; X = -X;} |
|
Digit = number_floor(eval(log(X)/log(10))); |
|
Num = number_floor((X/(10^Digit))*10^20); |
|
return Sign*(Num/(10^20))*(10^Digit); |
|
} |
|
|
|
def checkrats2() { |
|
for (I=0; I<10; I++) { |
|
Sign=(-1)^(random()%2); |
|
X = eval(exp(0)*(random()/random())*10^(Sign*(random()%300))); /* 308 */ |
|
printf("X=%a\n",X); |
|
Y = rats2(X); |
|
printf("Y=%a\n",Y); |
|
if (number_abs(eval(Y*exp(0))/X-1) > 0.0000001) { |
|
printf("error: X = %a, Y=%a\n",X,Y); |
|
} |
|
} |
|
} |
|
|
|
def a_expect(A,B,C,Y) { |
|
E=tk_fd.expectation_abc(A,B,C,Y); |
|
return(E); |
|
} |
|
def r_expect(A,B,C,Y) { |
|
Y = r_d2rat(Y); |
|
E=a_expect(A,B,C,Y); |
|
Fans=map_deval(E); |
Fans = tk_r.asir2r_c(Fans); |
Fans = tk_r.asir2r_c(Fans); |
return Fans; |
return Fans; |
|
} |
|
|
|
def r_ahmat(A,B,C,Y) { |
|
Y = r_d2rat(Y); |
|
Ans=a_ahmat(A,B,C,Y); |
|
Fans=map_deval(Ans); |
|
Fans = tk_r.asir2r_c(Fans); |
|
return Fans; |
|
} |
|
|
|
def a_ahmat(A,B,C,Y) { |
|
return(tk_fd.ahmat_abc(A,B,C,Y)); |
|
} |
|
|
|
def r_log_ahmat(A,B,C,Y) { |
|
Y = r_d2rat(Y); |
|
Ans=a_log_ahmat(A,B,C,Y); |
|
Fans=map_deval(Ans); |
|
Fans = tk_r.asir2r_c(Fans); |
|
return Fans; |
|
} |
|
|
|
def a_log_ahmat(A,B,C,Y) { |
|
Ans=tk_fd.log_ahmat_abc(A,B,C,Y); |
|
return Ans; |
|
} |
|
|
|
def map_deval(L) { |
|
if (type(L) >=4) return(map(map_deval,L)); |
|
return(deval(L)); |
} |
} |
end$ |
end$ |