diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-08-31 16:52:26 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-08-31 16:52:26 +0000 |
commit | 4486e93da02c7ef9e1fdf785c88f78986048c332 (patch) | |
tree | c0d84fce23a39a307fd12041fdd570be93aca15d /lib/Data | |
parent | 0b48e6b34a1a4ec590f2d17833f713f42f5e0955 (diff) |
refactoring norms
Diffstat (limited to 'lib/Data')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 9059723..2855a90 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -21,7 +21,7 @@ | |||
21 | module Data.Packed.Matrix ( | 21 | module Data.Packed.Matrix ( |
22 | Element, RealElement, Container(..), | 22 | Element, RealElement, Container(..), |
23 | Convert(..), RealOf, ComplexOf, SingleOf, DoubleOf, ElementOf, | 23 | Convert(..), RealOf, ComplexOf, SingleOf, DoubleOf, ElementOf, |
24 | Precision(..), comp, real'', complex'', | 24 | Precision(..), comp, |
25 | AutoReal(..), | 25 | AutoReal(..), |
26 | Matrix,rows,cols, | 26 | Matrix,rows,cols, |
27 | (><), | 27 | (><), |
@@ -485,7 +485,10 @@ instance Precision (Complex Float) (Complex Double) where | |||
485 | float2DoubleG = asComplex . float2DoubleV . asReal | 485 | float2DoubleG = asComplex . float2DoubleV . asReal |
486 | 486 | ||
487 | -- | Supported real types | 487 | -- | Supported real types |
488 | class (Element t, Element (Complex t), RealFloat t) => RealElement t | 488 | class (Element t, Element (Complex t), RealFloat t |
489 | -- , RealOf t ~ t, RealOf (Complex t) ~ t | ||
490 | ) | ||
491 | => RealElement t | ||
489 | 492 | ||
490 | instance RealElement Double | 493 | instance RealElement Double |
491 | 494 | ||
@@ -501,6 +504,8 @@ class Container c where | |||
501 | single' :: Precision a b => c b -> c a | 504 | single' :: Precision a b => c b -> c a |
502 | double' :: Precision a b => c a -> c b | 505 | double' :: Precision a b => c a -> c b |
503 | 506 | ||
507 | comp x = complex' x | ||
508 | |||
504 | instance Container Vector where | 509 | instance Container Vector where |
505 | toComplex = toComplexV | 510 | toComplex = toComplexV |
506 | fromComplex = fromComplexV | 511 | fromComplex = fromComplexV |
@@ -592,34 +597,23 @@ instance Convert (Complex Float) where | |||
592 | 597 | ||
593 | ------------------------------------------------------------------- | 598 | ------------------------------------------------------------------- |
594 | 599 | ||
595 | |||
596 | -- | to be replaced by Convert | 600 | -- | to be replaced by Convert |
597 | class Convert t => AutoReal t where | 601 | class Convert t => AutoReal t where |
598 | real''' :: Container c => c Double -> c t | 602 | real'' :: Container c => c Double -> c t |
599 | complex''' :: Container c => c t -> c (Complex Double) | 603 | complex'' :: Container c => c t -> c (Complex Double) |
600 | 604 | ||
601 | instance AutoReal Double where | 605 | instance AutoReal Double where |
602 | real''' = real | 606 | real'' = real |
603 | complex''' = complex | 607 | complex'' = complex |
604 | 608 | ||
605 | instance AutoReal (Complex Double) where | 609 | instance AutoReal (Complex Double) where |
606 | real''' = real | 610 | real'' = real |
607 | complex''' = complex | 611 | complex'' = complex |
608 | 612 | ||
609 | instance AutoReal Float where | 613 | instance AutoReal Float where |
610 | real''' = real . single | 614 | real'' = real . single |
611 | complex''' = double . complex | 615 | complex'' = double . complex |
612 | 616 | ||
613 | instance AutoReal (Complex Float) where | 617 | instance AutoReal (Complex Float) where |
614 | real''' = real . single | 618 | real'' = real . single |
615 | complex''' = double . complex | 619 | complex'' = double . complex |
616 | |||
617 | |||
618 | comp x = complex' x | ||
619 | |||
620 | -- complex'' x = double (complex x) | ||
621 | -- real'' x = real (single x) | ||
622 | |||
623 | real'' x = real''' x | ||
624 | complex'' x = complex''' x | ||
625 | |||