Re: Can I decompose a domain ?
Martin Rubey <[email protected]>
| Newsgroups | gmane.comp.mathematics.axiom.general |
|---|---|
| Message-ID | <[email protected]> |
Dear Francois, Francois Maltey <[email protected]> writes: > Hello William, and thanks a lot > > > > resFloat : Expression Float := cos (4.0 * x) > > > resInteger : Expression Float := cos (4 * x) > > > resComplex : Expression Complex Integer := exp (3+4*%i) > > > > > > How can I get Float from resFloat ? Integer from resInteger, etc. > > > in a *.input file ? > > > Is the following what you want? > > No I don't try to get the sub-argument, but the type of the subargument. > But I'm not sure I can get it. In general, I don't think that it's possible. However, I think in your situation, it is unnecessary. > > (isTimes ((argument ((kernels resFloat).1)).1)).1::Float > > (isTimes ((argument ((kernels resInteger).1)).1)).1::Integer > > argument ((kernels resComplex).1).1::Complex Integer > > Imagine I know that a is an Expression... > My function don't know if a is an Expression Float, or an Expression > Integer... As far as I know, you are modifying TranscendentalManipulations(R, F) from manip.spad. The header reads )abbrev package TRMANIP TranscendentalManipulations TranscendentalManipulations(R, F): Exports == Implementation where R : Join(OrderedSet, GcdDomain) F : Join(FunctionSpace R, TranscendentalFunctionCategory) So, usually, TRMANIP will be called (secretly, by the interpreter) with the arguments INT, EXPR INT or Float, EXPR Float or FRAC INT, EXPR FRAC INT or something similar. So you can simply say Myfunction(a : F) : String == if R is Integer then ... else if R is Fraction Integer then ... and so on. However, I believe that it is better to test for properties: if R has CharacteristicZero then if F has ComplexCategory R then ... else and so on. In some cases you will also want to test whether a particular member of R is an integer. You then have to say if (r := retractIfCan(a)@Union("failed", Integer)) case Integer then ... Warning: look up the correct syntax, and as far as I remember, it makes a difference whether you ask for Union("failed", Integer) or Union(Integer, "failed"), unfortunately. In an .input file you can simulate this behaviour as follows: say, right at the beginning R => INT F => EXPR R to test your code for EXPR INT. If you have done this, modify it to say R => Float F => EXPR R to test your code for EXPR Float, and so on. Martin