version 1.28, 2004/05/13 05:33:10 |
version 1.34, 2004/09/01 05:06:09 |
|
|
% $OpenXM: OpenXM/src/kan96xx/Kan/dr.sm1,v 1.27 2004/04/29 11:20:37 takayama Exp $ |
% $OpenXM: OpenXM/src/kan96xx/Kan/dr.sm1,v 1.33 2004/08/31 05:30:20 takayama Exp $ |
%% dr.sm1 (Define Ring) 1994/9/25, 26 |
%% dr.sm1 (Define Ring) 1994/9/25, 26 |
%% This file is error clean. |
%% This file is error clean. |
|
|
|
|
[ |
[ |
/mat arg1 def |
/mat arg1 def |
/m mat length def |
/m mat length def |
|
{ |
|
m 0 eq { /ans [ ] def exit } { } ifelse |
mat 0 get isArray |
mat 0 get isArray |
{ } |
{ } |
{ (transpose: Argument must be an array of arrays.) error } |
{ (transpose: Argument must be an array of arrays.) error } |
|
|
ans [ j i ] << mat i get j get >> put |
ans [ j i ] << mat i get j get >> put |
} for |
} for |
} for |
} for |
|
exit |
|
} loop |
/arg1 ans def |
/arg1 ans def |
] pop |
] pop |
popVariables |
popVariables |
|
|
/univ vars 0 get reverse |
/univ vars 0 get reverse |
vars 1 get reverse join |
vars 1 get reverse join |
def |
def |
|
w-vectors to_int32 /w-vectors set |
[ |
[ |
0 1 << w-vectors length 1 sub >> |
0 1 << w-vectors length 1 sub >> |
{ |
{ |
|
|
/arg2 set /arg1 set |
/arg2 set /arg1 set |
[/univ /www /k /vname /vweight /ans] pushVariables |
[/univ /www /k /vname /vweight /ans] pushVariables |
/univ arg1 def /www arg2 def |
/univ arg1 def /www arg2 def |
[ |
[ |
|
www to_int32 /www set |
/ans << univ length >> -1 0 evecw def |
/ans << univ length >> -1 0 evecw def |
0 2 << www length 2 sub >> |
0 2 << www length 2 sub >> |
{ |
{ |
|
|
[ |
[ |
/fff arg1 def |
/fff arg1 def |
/www arg2 def |
/www arg2 def |
|
www to_int32 /www set |
fff (0). eq { /ddd -intInfinity def /ord_w.LLL goto} { } ifelse |
fff (0). eq { /ddd -intInfinity def /ord_w.LLL goto} { } ifelse |
fff (ring) dc /rrr set |
fff (ring) dc /rrr set |
fff init /fff set |
fff init /fff set |
|
|
[ |
[ |
/fff arg1 def |
/fff arg1 def |
/www arg2 def |
/www arg2 def |
|
www to_int32 /www set |
fff (0). eq { /ddd -intInfinity def /ord_w_all.LLL goto} { } ifelse |
fff (0). eq { /ddd -intInfinity def /ord_w_all.LLL goto} { } ifelse |
/ddd -intInfinity def |
/ddd -intInfinity def |
fff (ring) dc /rrr set |
fff (ring) dc /rrr set |
|
|
[/in-ngcd /nlist /g.ngcd /ans] pushVariables |
[/in-ngcd /nlist /g.ngcd /ans] pushVariables |
[ |
[ |
/nlist arg1 def |
/nlist arg1 def |
|
nlist to_univNum /nlist set |
nlist length 2 lt |
nlist length 2 lt |
{ /ans nlist 0 get def /L.ngcd goto } |
{ /ans nlist 0 get def /L.ngcd goto } |
{ |
{ |
Line 3656 $ [ff ff] fromVectors :: $ |
|
Line 3665 $ [ff ff] fromVectors :: $ |
|
( ff to_int { tag } map :: ) |
( ff to_int { tag } map :: ) |
]] putUsages |
]] putUsages |
|
|
|
/to_int32 { |
|
/arg1 set |
|
[/to-int32 /ob /ans] pushVariables |
|
[ |
|
/ob arg1 def |
|
/ans ob def |
|
ob isArray { |
|
ob {to_int32} map /ans set |
|
/LLL.to_int32 goto |
|
} { } ifelse |
|
ob isUniversalNumber { |
|
ob (integer) dc /ans set |
|
/LLL.to_int32 goto |
|
} { } ifelse |
|
/LLL.to_int32 |
|
/arg1 ans def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(to_int32) |
|
[(obj to_int32 obj2) |
|
$All universalNumber in obj are changed to integer (int32).$ |
|
(Example: /ff [1 (2).. [(hello) (0).]] def ff { tag } map ::) |
|
( ff to_int32 { tag } map :: ) |
|
(cf. to_int, to_univNum ) |
|
]] putUsages |
|
|
/define_ring_variables { |
/define_ring_variables { |
[/in-define_ring_variables /drv._v /drv._p /drv._v0] pushVariables |
[/in-define_ring_variables /drv._v /drv._p /drv._v0] pushVariables |
%% You cannot use these names for names for polynomials. |
%% You cannot use these names for names for polynomials. |
Line 3854 $ [ff ff] fromVectors :: $ |
|
Line 3891 $ [ff ff] fromVectors :: $ |
|
popVariables |
popVariables |
arg1 |
arg1 |
} def |
} def |
|
|
|
/to_univNum { |
|
/arg1 set |
|
[/rr ] pushVariables |
|
[ |
|
/rr arg1 def |
|
rr isArray { |
|
rr { to_univNum } map /rr set |
|
} { |
|
} ifelse |
|
rr isInteger { |
|
rr (universalNumber) dc /rr set |
|
} { |
|
} ifelse |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(to_univNum) |
|
[(obj to_univNum obj2) |
|
(Example. [ 2 (3).. ] to_univNum) |
|
$cf. to_int32. (to_int)$ |
|
]] putUsages |
|
|
|
[(lcm) |
|
[ ([a b c ...] lcm r) |
|
(cf. polylcm, mpzext) |
|
] |
|
] putUsages |
|
/lcm { |
|
/arg1 set |
|
[/aa /bb /rr /pp /i] pushVariables |
|
[ |
|
/aa arg1 def |
|
/rr (1).. def |
|
/pp 0 def % isPolynomial array? |
|
0 1 aa length 1 sub { |
|
/i set |
|
aa i get isPolynomial { |
|
/pp 1 def |
|
exit |
|
} { } ifelse |
|
} for |
|
|
|
0 1 aa length 1 sub { |
|
/i set |
|
pp { |
|
[rr aa i get] polylcm /rr set |
|
} { |
|
[(lcm) rr aa i get ] mpzext /rr set |
|
} ifelse |
|
} for |
|
|
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(gcd) |
|
[ ([a b c ...] gcd r) |
|
(cf. polygcd, mpzext) |
|
] |
|
] putUsages |
|
/gcd { |
|
/arg1 set |
|
[/aa /bb /rr /pp /i] pushVariables |
|
[ |
|
/aa arg1 def |
|
/rr (1).. def |
|
/pp 0 def % isPolynomial array? |
|
0 1 aa length 1 sub { |
|
/i set |
|
aa i get isPolynomial { |
|
/pp 1 def |
|
/rr aa i get def |
|
exit |
|
} { } ifelse |
|
} for |
|
|
|
pp { |
|
0 1 aa length 1 sub { |
|
/i set |
|
[rr aa i get] polygcd /rr set |
|
} for |
|
} { |
|
aa ngcd /rr set |
|
} ifelse |
|
|
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
[(denominator) |
|
[ ([a b c ...] denominator r) |
|
( a denominator r ) |
|
(cf. dc, numerator) |
|
(Output is Z or a polynomial.) |
|
] |
|
] putUsages |
|
% test data. |
|
% [(1).. (2).. div (1).. (3).. div ] denominator |
|
% [(2).. (3).. (4).. ] denominator |
|
/denominator { |
|
/arg1 set |
|
[/pp /dd /ii /rr] pushVariables |
|
[ |
|
/pp arg1 def |
|
pp to_univNum /pp set |
|
{ |
|
pp isArray { |
|
pp { denominator } map /dd set |
|
/rr dd lcm def % rr = lcm(dd[0], dd[1], ... ) |
|
rr /dd set |
|
exit |
|
} { } ifelse |
|
|
|
pp (denominator) dc /dd set |
|
exit |
|
|
|
} loop |
|
/arg1 dd def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
[(numerator) |
|
[ ([a b c ...] numerator r) |
|
( a numerator r ) |
|
(cf. dc, denominator) |
|
(Output is a list of Z or polynomials.) |
|
] |
|
] putUsages |
|
% test data. |
|
/numerator { |
|
/arg1 set |
|
[/pp /dd /ii /rr] pushVariables |
|
[ |
|
/pp arg1 def |
|
pp to_univNum /pp set |
|
{ |
|
pp isArray { |
|
pp denominator /dd set |
|
pp dd mul /rr set |
|
rr cancel /rr set |
|
exit |
|
} { } ifelse |
|
|
|
pp (numerator) dc /rr set |
|
exit |
|
|
|
} loop |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
/cancel.Q { |
|
/arg1 set |
|
[/aa /rr /nn /dd /gg] pushVariables |
|
[ |
|
/aa arg1 def |
|
{ |
|
aa isRational { |
|
[(cancel) aa] mpzext /rr set |
|
rr (denominator) dc (1).. eq { |
|
/rr rr (numerator) dc def |
|
exit |
|
} { } ifelse |
|
rr (denominator) dc (-1).. eq { |
|
/rr rr (numerator) dc (-1).. mul def |
|
} { } ifelse |
|
exit |
|
} { } ifelse |
|
|
|
/rr aa def |
|
exit |
|
} loop |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
/cancel.one { |
|
/arg1 set |
|
[/aa /rr /nn /dd /gg] pushVariables |
|
[ |
|
/aa arg1 def |
|
{ |
|
aa isRational { |
|
aa (numerator) dc /nn set |
|
aa (denominator) dc /dd set |
|
nn isUniversalNumber dd isUniversalNumber and { |
|
/rr aa cancel.Q def |
|
exit |
|
} { (cancel: not implemented) error } ifelse |
|
} { } ifelse |
|
|
|
/rr aa def |
|
exit |
|
} loop |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
[(cancel) |
|
[ (obj cancel r) |
|
(Cancel numerators and denominators) |
|
(The implementation has not yet been completed. It works only for Q.) |
|
]] putUsages |
|
/cancel { |
|
/arg1 set |
|
[/aa /rr] pushVariables |
|
[ |
|
/aa arg1 def |
|
aa isArray { |
|
aa {cancel} map /rr set |
|
} { |
|
aa cancel.one /rr set |
|
} ifelse |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
|
|
/nnormalize_vec { |
|
/arg1 set |
|
[/pp /rr /dd ] pushVariables |
|
[ |
|
/pp arg1 def |
|
pp denominator /dd set |
|
dd (0).. lt { (nnormalize_vec: internal error) error } { } ifelse |
|
pp numerator dd mul cancel /pp set |
|
/@@@.nnormalize_vec_c dd def |
|
pp gcd /dd set |
|
dd (0).. lt { (nnormalize_vec: internal error) error } { } ifelse |
|
pp (1).. dd div mul cancel /rr set |
|
@@@.nnormalize_vec_c dd div cancel /@@@.nnormalize_vec_c set |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(nnormalize_vec) |
|
[(pp nnormalize_vec npp) |
|
(It normalizes a given vector of Q into a vector of Z with relatively prime) |
|
(entries by multiplying a postive number.) |
|
]] putUsages |
|
|
|
/getNode { |
|
/arg2 set |
|
/arg1 set |
|
[/in-getNode /ob /key /rr /rr /ii] pushVariables |
|
[ |
|
/ob arg1 def |
|
/key arg2 def |
|
/rr null def |
|
{ |
|
ob isClass { |
|
ob (array) dc /ob set |
|
} { exit } ifelse |
|
ob 0 get key eq { |
|
/rr ob def |
|
exit |
|
} { } ifelse |
|
ob 2 get /ob set |
|
0 1 ob length 1 sub { |
|
/ii set |
|
ob ii get key getNode /rr set |
|
rr tag 0 eq { } { exit } ifelse |
|
} for |
|
exit |
|
} loop |
|
/arg1 rr def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(getNode) |
|
[(ob key getNode) |
|
(ob is a class object.) |
|
(The operator getNode returns the node with the key in ob.) |
|
(The node is an array of the format [key attr-list node-list]) |
|
(Example:) |
|
( /dog [(dog) [[(legs) 4] ] [ ]] [(class) (tree)] dc def) |
|
( /man [(man) [[(legs) 2] ] [ ]] [(class) (tree)] dc def) |
|
( /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def) |
|
( ma (dog) getNode ) |
|
]] putUsages |
|
|
|
|
/usages { |
/usages { |
/arg1 set |
/arg1 set |