summaryrefslogtreecommitdiff
path: root/lib/Data
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-08-31 16:52:26 +0000
committerAlberto Ruiz <aruiz@um.es>2010-08-31 16:52:26 +0000
commit4486e93da02c7ef9e1fdf785c88f78986048c332 (patch)
treec0d84fce23a39a307fd12041fdd570be93aca15d /lib/Data
parent0b48e6b34a1a4ec590f2d17833f713f42f5e0955 (diff)
refactoring norms
Diffstat (limited to 'lib/Data')
-rw-r--r--lib/Data/Packed/Matrix.hs40
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 @@
21module Data.Packed.Matrix ( 21module 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
488class (Element t, Element (Complex t), RealFloat t) => RealElement t 488class (Element t, Element (Complex t), RealFloat t
489-- , RealOf t ~ t, RealOf (Complex t) ~ t
490 )
491 => RealElement t
489 492
490instance RealElement Double 493instance 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
507comp x = complex' x
508
504instance Container Vector where 509instance 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
597class Convert t => AutoReal t where 601class 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
601instance AutoReal Double where 605instance AutoReal Double where
602 real''' = real 606 real'' = real
603 complex''' = complex 607 complex'' = complex
604 608
605instance AutoReal (Complex Double) where 609instance AutoReal (Complex Double) where
606 real''' = real 610 real'' = real
607 complex''' = complex 611 complex'' = complex
608 612
609instance AutoReal Float where 613instance AutoReal Float where
610 real''' = real . single 614 real'' = real . single
611 complex''' = double . complex 615 complex'' = double . complex
612 616
613instance AutoReal (Complex Float) where 617instance AutoReal (Complex Float) where
614 real''' = real . single 618 real'' = real . single
615 complex''' = double . complex 619 complex'' = double . complex
616
617
618comp x = complex' x
619
620-- complex'' x = double (complex x)
621-- real'' x = real (single x)
622
623real'' x = real''' x
624complex'' x = complex''' x
625