[BACK]Return to object.kk CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097

Annotation of OpenXM/src/k097/object.kk, Revision 1.3

1.3     ! takayama    1: /* $OpenXM: OpenXM/src/k097/object.kk,v 1.2 2000/01/21 03:01:25 takayama Exp $ */
1.1       maekawa     2: /* object.kk , 1997, 4/11. */
                      3: Protect("showln",0);
                      4:
                      5: class Object extends PrimitiveObject {
                      6:   def new0() {
                      7:     return(Object);
                      8:   }
                      9:   def showln() {
                     10:     Println(this);
                     11:   }
                     12:   def getClass() {
                     13:     sm1(" this 0 get /FunctionValue set ");
                     14:   }
                     15: }
                     16:
                     17: sm1(" /ectag { dup isClass not { pop -1 } { lc } ifelse } def ");
                     18: def k00ecTag(a) { sm1(a," ectag /FunctionValue set "); }
                     19: def IsObject(a) {
                     20:   if (!IsArray(a)) return(false);
                     21:   if (Length(a) < 1) return(false);
                     22:   if (k00ecTag(a[0]) == k00ecTag(Object[0])) return(true);
                     23:   else return(false);
                     24: }
                     25: HelpAdd(["IsObject",["IsObject(a) return true if a is an Object."]]);
                     26:
                     27:
                     28:
                     29: /* class Gmp. Number theoretic functions.
                     30:    1997, 4/17
                     31: */
                     32: class Gmp extends Object {
                     33:   def BitAnd(a,b) {
                     34:     sm1("[(and) ",a," ",b," ] mpzext /FunctionValue set ");
                     35:   }
                     36:   def BitOr(a,b) {
                     37:     sm1("[(ior) ",a," ",b," ] mpzext /FunctionValue set ");
                     38:   }
                     39:   def ModuloPower(base,ex,mmod) {
                     40:     sm1("[(powm) ",base," ",ex," ",mmod," ] mpzext /FunctionValue set ");
                     41:   }
                     42:   def ProbabilisticPrimeP(p,reps) {
                     43:     sm1("[(probab_prime_p) ",p," ",reps," ] mpzext /FunctionValue set ");
                     44:   }
                     45:   def Sqrt(a) {
                     46:     sm1("[(sqrt) ",a, " ] mpzext /FunctionValue set ");
                     47:   }
                     48:   def Gcd(a,b) {
                     49:     sm1("[(gcd) ",a," ",b," ] mpzext /FunctionValue set ");
                     50:   }
                     51:   def Div(a,b) {
                     52:     sm1("[(tdiv_qr) ",a," ",b," ] mpzext /FunctionValue set ");
                     53:   }
                     54:   def Mod(a,b) {
                     55:     sm1("[(tdiv_qr) ",a," ",b," ] mpzext 1 get /FunctionValue set ");
                     56:   }
                     57: }
                     58:
                     59: HelpAdd(["Gmp.",
                     60:  ["Gmp is a class which supports the following methods:",
                     61:   "BitAnd, BitOr, ModuloPower, ProbabilisticPrimeP, Sqrt,",
                     62:   "Gcd, Div, Mod.",
1.3     ! takayama   63:   "These methods call functions of GNU MP package.",
        !            64:   "Note that there is no method to create an instance.",
        !            65:   "Ex.  r = Gmp.Gcd(5,8); "
        !            66:   ]]);
1.1       maekawa    67:

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