I wrote
> Example: for determinant of a SquareMatrix over rR, DoCon has
>
> (1) det for CommutativeRing rR => SquareMatrix rR,
>
> (2) det_euc for Euclidean rR => SquareMatrix rR,
>
> (3) det_upol_finField ::
> Field k => [ResidueE (UPol k)] -> [[UPol k]] -> UPol k
> -- ext mM
> -- A degree cost method to compute det M over k[x] for a finite
> -- field k.
>
> On average, (2) is faster than (1), (3) is faster than (2).
> DoCon provides three different functions, for some reasons.
> If it introduced class WithDet, may be, it could have a unique
> operation `det', whose instances are efficienly resolved for these
> three functions (I am not sure, needs recollection, trying).
I need to correct this. With DoCon and Haskell, this all is not so nice.
Suppose one defines
class CommutativeRing rR => WithDet rR -- I
where
det :: SquareMatrix rR -> rR
-- default implementation
det mt = if rR has EuclideanRing then
gaussEliminationForEuclidean mt
else genericMethod mt
class CommutativeRing rR => WithDet rR -- II
where
det :: SquareMatrix rR -> rR
det = genericAlgorithm -- this is the default implementation
-- for any commutative ring
instance EuclideanRing rR => WithDet rR -- II-1
where
det mt = gaussEliminationForEuclidean mt
instance FiniteField k => WithDet (UPol k) -- II-2
where
det mt = mostSpecialMethod mt
Currently
(I) is not possible in Haskell +glasgow-ext,
II-2 must work,
II-1 is not possible in Haskell +glasgow-ext.
This is why DoCon introduces more than one function for Det.
But this is done for temporary and technical (in my mind) reasons.
Putting more effort in Haskell+ext implementation will fix this,
(though, developing such things in practice needs years and years).
As the Spad language is more expressive, it is likely to have an
easier resolution.
Thus, can Spad handle (I) ? Something like this:
Category(R : CommutativeRing) : WithDet ==
...
with
det : SquareMatrix R -> R
Default Implementation ==
det mt = if rR has EuclideanRing then
gaussEliminationForEuclidean mt
else genericMethod mt -- expand by row
-- correct the syntax if needed.
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.