On Fri, Mar 02, 2012 at 12:35:14PM +0100, Ralf Hemmecke wrote:
>> )abbrev domain SUP SparseUnivariatePolynomial
>> SparseUnivariatePolynomial(R : CommutativeRing):
>>     with ...
>>       Join(CommutativeRing,
>>            R has IntegerLike  or  R has FiniteField  or
>>              R has SuchAndSuchCategory  =>  UniqueFactorizationDomain
>>           )
>>    == add
>>     Rep == ?
>>     factor(f : UP R) : Factored (UP R) ==
>>              R has IntegerLike =>  factorUPOverInteger f
>>              R has FiniteField =>  factorUPByExtendedBerlekemp(R, f)
>>              R has SuchAndSuchCategory =>  factorUPByGeneric(R, f)
>
> Of course that can be done. But I have the impression you haven't that  
> you haven't got the point in me writing
>
>     if R has Field then
>       foo(r: R): % == (1/r) pretend %
>     else
>       foo(r: R): % == r pretend %
>
> instead of
>
>    foo(r: R): % ==  if R has Field then
>                        (1/r) pretend %
>                     else
>                        r pretend %
>
> In the second case (as in your case above), calling factor will *always*  
> perform the test "R has Field". In my version that test is only at  
> instantiation time of the domain.
>

factorUPOverInteger f  is an expensive loop, and the relative cost of
preliminary  (R has IntegerLike)  is usually small.
Still your solution looks indeed considerably better.

>> I am trying to find out whether the language allows, in principle, a clear
>> and efficient dispatching for such operations which have a complex set of
>> implementation cases overlapping non-trivially and having different
>> generality levels.
>
> I think my previous mail should have shown you how dispatching can be  
> done on a domain level. The exports would simply list the function  
> unconditionally.

Then, the next question is 
      why the `factor' instances are not so nicely 
      dispatched in the current FriCAS, Axiom ?

For I am a bit confused. 
1. Waldek wrote about the category of  Explicit..., 
   and of some performance problems related to dispatching `factor'.
2. I write in my  testParse.spad :   
                            factor(f) $UnivariateFactorize(UP(x,INT))
   -- and this is by the advice read from e-mail.
   Could I happen to call `factor' in this case from other place, where 
   its impementation is less efficient?
3. Waldek wrote, that it is not nicely dispatched -- if I understand 
   correct.
   Is this by occasion or there are some fundamental reasons for this?

Regards,

------
Sergei
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to