login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

spad
)abbrev domain MYPLEX MyComplex
++ Description:
++ Based on \spadtype{Complex(R)},
++ \spadtype{MyComplex(R)} creates the domain of elements of the form
++ \spad{a + b * i} where \spad{a} and b come from the ring R,
++ and i is a new element such that \spad{i^2 = -1}.
MyComplex(R:CommutativeRing): ComplexCategory(R) with
     if R has OpenMath then OpenMath
   == add
       Rep := Record(real:R, imag:R)
if R has OpenMath then writeOMComplex(dev: OpenMathDevice, x: %): Void == OMputApp(dev) OMputSymbol(dev, "complex1", "complex__cartesian") OMwrite(dev, real x) OMwrite(dev, imag x) OMputEndApp(dev)
OMwrite(x: %): String == s: String := "" sp := OM_-STRINGTOSTRINGPTR(s)$Lisp dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML) OMputObject(dev) writeOMComplex(dev, x) OMputEndObject(dev) OMclose(dev) s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String s
OMwrite(x: %, wholeObj: Boolean): String == s: String := "" sp := OM_-STRINGTOSTRINGPTR(s)$Lisp dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML) if wholeObj then OMputObject(dev) writeOMComplex(dev, x) if wholeObj then OMputEndObject(dev) OMclose(dev) s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String s
OMwrite(dev: OpenMathDevice, x: %): Void == OMputObject(dev) writeOMComplex(dev, x) OMputEndObject(dev)
OMwrite(dev: OpenMathDevice, x: %, wholeObj: Boolean): Void == if wholeObj then OMputObject(dev) writeOMComplex(dev, x) if wholeObj then OMputEndObject(dev)
0 == [0, 0] 1 == [1, 0] zero? x == zero?(x.real) and zero?(x.imag) -- one? x == one?(x.real) and zero?(x.imag) one? x == ((x.real) = 1) and zero?(x.imag) coerce(r:R):% == [r, 0] complex(r, i) == [r, i] real x == x.real imag x == x.imag x + y == [x.real + y.real, x.imag + y.imag] -- by re-defining this here, we save 5 fn calls x:% * y:% == [x.real * y.real - x.imag * y.imag, x.imag * y.real + y.imag * x.real] -- here we save nine!
if R has IntegralDomain then _exquo(x:%, y:%) == -- to correct bad defaulting problem zero? y.imag => x exquo y.real x * conjugate(y) exquo norm(y)
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4777213760436474437-25px001.spad
      using old system compiler.
   MYPLEX abbreviates domain MyComplex 
------------------------------------------------------------------------
   initializing NRLIB MYPLEX for MyComplex 
   compiling into NRLIB MYPLEX 
****** Domain: R already in scope
augmenting R: (OpenMath)
   compiling local writeOMComplex : (OpenMathDevice,$) -> Void
Time: 0.05 SEC.
compiling exported OMwrite : $ -> String Time: 0 SEC.
compiling exported OMwrite : ($,Boolean) -> String Time: 0 SEC.
compiling exported OMwrite : (OpenMathDevice,$) -> Void Time: 0 SEC.
compiling exported OMwrite : (OpenMathDevice,$,Boolean) -> Void Time: 0 SEC.
compiling exported Zero : () -> $ Time: 0 SEC.
compiling exported One : () -> $ Time: 0 SEC.
compiling exported zero? : $ -> Boolean Time: 0 SEC.
compiling exported one? : $ -> Boolean Time: 0 SEC.
compiling exported coerce : R -> $ Time: 0 SEC.
compiling exported complex : (R,R) -> $ MYPLEX;complex;2R$;11 is replaced by CONS Time: 0 SEC.
compiling exported real : $ -> R MYPLEX;real;$R;12 is replaced by QCAR Time: 0 SEC.
compiling exported imag : $ -> R MYPLEX;imag;$R;13 is replaced by QCDR Time: 0 SEC.
compiling exported + : ($,$) -> $ Time: 0 SEC.
compiling exported * : ($,$) -> $ Time: 0 SEC.
****** Domain: R already in scope augmenting R: (IntegralDomain) compiling exported exquo : ($,$) -> Union($,failed) Time: 0 SEC.
****** Domain: R already in scope augmenting R: (EuclideanDomain) ****** Domain: R already in scope augmenting R: (PolynomialFactorizationExplicit) ****** Domain: R already in scope augmenting R: (RadicalCategory) ****** Domain: R already in scope augmenting R: (TranscendentalFunctionCategory) ****** Domain: R already in scope augmenting R: (RealNumberSystem) ****** Domain: R already in scope augmenting R: (TranscendentalFunctionCategory) ****** Domain: R already in scope augmenting R: (Comparable) ****** Domain: R already in scope augmenting R: (ConvertibleTo (InputForm)) ****** Domain: R already in scope augmenting R: (ConvertibleTo (Pattern (Float))) ****** Domain: R already in scope augmenting R: (ConvertibleTo (Pattern (Integer))) ****** Domain: R already in scope augmenting R: (DifferentialRing) ****** Domain: R already in scope augmenting R: (Eltable R R) ****** Domain: R already in scope augmenting R: (EuclideanDomain) ****** Domain: R already in scope augmenting R: (Evalable R) ****** Domain: R already in scope augmenting R: (Field) ****** Domain: R already in scope augmenting R: (Finite) ****** Domain: R already in scope augmenting R: (FiniteFieldCategory) ****** Domain: R already in scope augmenting R: (InnerEvalable (Symbol) R) ****** Domain: R already in scope augmenting R: (IntegerNumberSystem) ****** Domain: R already in scope augmenting R: (IntegralDomain) ****** Domain: R already in scope augmenting R: (LinearlyExplicitRingOver (Integer)) ****** Domain: R already in scope augmenting R: (OpenMath) ****** Domain: R already in scope augmenting R: (PartialDifferentialRing (Symbol)) ****** Domain: R already in scope augmenting R: (PatternMatchable (Float)) ****** Domain: R already in scope augmenting R: (PatternMatchable (Integer)) ****** Domain: R already in scope augmenting R: (RealConstant) ****** Domain: R already in scope augmenting R: (RealNumberSystem) ****** Domain: R already in scope augmenting R: (RetractableTo (Fraction (Integer))) ****** Domain: R already in scope augmenting R: (RetractableTo (Integer)) ****** Domain: R already in scope augmenting R: (TranscendentalFunctionCategory) (time taken in buildFunctor: 260)
;;; *** |MyComplex| REDEFINED
;;; *** |MyComplex| REDEFINED Time: 0.30 SEC.
Warnings: [1] OMwrite: pretend(String) -- should replace by @
Cumulative Statistics for Constructor MyComplex Time: 0.35 seconds
finalizing NRLIB MYPLEX Processing MyComplex for Browser database: --------constructor--------- --->-->MyComplex(constructor): Wrong number of arguments: MyComplex(R) ; compiling file "/var/aw/var/LatexWiki/MYPLEX.NRLIB/MYPLEX.lsp" (written 14 JUL 2013 10:10:12 AM):
; /var/aw/var/LatexWiki/MYPLEX.NRLIB/MYPLEX.fasl written ; compilation finished in 0:00:00.087 ------------------------------------------------------------------------ MyComplex is now explicitly exposed in frame initial MyComplex will be automatically loaded when needed from /var/aw/var/LatexWiki/MYPLEX.NRLIB/MYPLEX

fricas
myType := MyComplex MyComplex Integer

\label{eq1}\hbox{\axiomType{MyComplex}\ } (\hbox{\axiomType{MyComplex}\ } (\hbox{\axiomType{Integer}\ }))(1)
Type: Type
fricas
m := complex(complex(1,2)$MyComplex(Integer),complex(3,4)$MyComplex(Integer))$myType

\label{eq2}1 +{2 \  i}+{{\left(3 +{4 \  i}\right)}\  i}(2)
Type: MyComplex(MyComplex(Integer))
fricas
mr := real(m*m)

\label{eq3}4 -{{20}\  i}(3)
Type: MyComplex(Integer)
fricas
imag(mr)

\label{eq4}-{20}(4)
Type: Integer




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: