~ubuntu-branches/ubuntu/vivid/haskell-hmatrix/vivid

« back to all changes in this revision

Viewing changes to lib/Numeric/Vector.hs

  • Committer: Package Import Robot
  • Author(s): Denis Laxalde
  • Date: 2013-07-06 15:37:50 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130706153750-wxxplc788jedqvv5
Tags: 0.15.0.0-1
* New upstream release.
* Make it clear in copyright that the license is GPL-3 (as stated by the
  author in <https://github.com/albertoruiz/hmatrix/issues/45>) although
  there is no proper license file yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
-------------------------------------------------------------------
27
27
 
28
 
#ifndef VECTOR
29
 
import Foreign(Storable)
30
 
#endif
31
 
 
32
 
------------------------------------------------------------------
33
 
 
34
 
#ifndef VECTOR
35
 
 
36
 
instance (Show a, Storable a) => (Show (Vector a)) where
37
 
    show v = (show (dim v))++" |> " ++ show (toList v)
38
 
 
39
 
instance Container Vector a => Eq (Vector a) where
40
 
    (==) = equal
41
 
 
42
 
instance (Element a, Read a) => Read (Vector a) where
43
 
    readsPrec _ s = [((d |>) . read $ listnums, rest)]
44
 
        where (thing,rest) = breakAt ']' s
45
 
              (dims,listnums) = breakAt '>' thing
46
 
              d = read . init . fst . breakAt '|' $ dims
47
 
              breakAt c l = (a++[c],tail b) where
48
 
                  (a,b) = break (==c) l
49
 
 
50
 
#endif
51
 
 
52
 
 
53
 
------------------------------------------------------------------
54
 
 
55
28
adaptScalar f1 f2 f3 x y
56
29
    | dim x == 1 = f1   (x@>0) y
57
30
    | dim y == 1 = f3 x (y@>0)