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

File: [local] / OpenXM / src / k097 / object.kk (download)

Revision 1.3, Fri Jan 5 11:14:25 2001 UTC (23 years, 4 months ago) by takayama
Branch: MAIN
Changes since 1.2: +5 -5 lines

Bug fix of the new manual system of kan/k0.
Moved some functions with the name *Indexed* to debug/indexed.k

/* $OpenXM: OpenXM/src/k097/object.kk,v 1.3 2001/01/05 11:14:25 takayama Exp $ */
/* object.kk , 1997, 4/11. */
Protect("showln",0);

class Object extends PrimitiveObject {
  def new0() {
    return(Object);
  }
  def showln() {
    Println(this);
  }
  def getClass() {
    sm1(" this 0 get /FunctionValue set ");
  }
}

sm1(" /ectag { dup isClass not { pop -1 } { lc } ifelse } def ");
def k00ecTag(a) { sm1(a," ectag /FunctionValue set "); }
def IsObject(a) {
  if (!IsArray(a)) return(false);
  if (Length(a) < 1) return(false);
  if (k00ecTag(a[0]) == k00ecTag(Object[0])) return(true);
  else return(false);
}
HelpAdd(["IsObject",["IsObject(a) return true if a is an Object."]]);



/* class Gmp. Number theoretic functions.  
   1997, 4/17 
*/
class Gmp extends Object {
  def BitAnd(a,b) {
    sm1("[(and) ",a," ",b," ] mpzext /FunctionValue set ");
  }
  def BitOr(a,b) {
    sm1("[(ior) ",a," ",b," ] mpzext /FunctionValue set ");
  }
  def ModuloPower(base,ex,mmod) {
    sm1("[(powm) ",base," ",ex," ",mmod," ] mpzext /FunctionValue set ");
  }
  def ProbabilisticPrimeP(p,reps) {
    sm1("[(probab_prime_p) ",p," ",reps," ] mpzext /FunctionValue set ");
  }
  def Sqrt(a) {
    sm1("[(sqrt) ",a, " ] mpzext /FunctionValue set ");
  }
  def Gcd(a,b) {
    sm1("[(gcd) ",a," ",b," ] mpzext /FunctionValue set ");
  }
  def Div(a,b) {
    sm1("[(tdiv_qr) ",a," ",b," ] mpzext /FunctionValue set ");
  }
  def Mod(a,b) {
    sm1("[(tdiv_qr) ",a," ",b," ] mpzext 1 get /FunctionValue set ");
  }
}

HelpAdd(["Gmp.",
 ["Gmp is a class which supports the following methods:",
  "BitAnd, BitOr, ModuloPower, ProbabilisticPrimeP, Sqrt,",
  "Gcd, Div, Mod.",
  "These methods call functions of GNU MP package.",
  "Note that there is no method to create an instance.",
  "Ex.  r = Gmp.Gcd(5,8); "
  ]]);