summaryrefslogtreecommitdiff
path: root/lib/Numeric/Container.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r--lib/Numeric/Container.hs91
1 files changed, 90 insertions, 1 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index 0fecf86..8cf3e07 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -20,11 +20,14 @@
20----------------------------------------------------------------------------- 20-----------------------------------------------------------------------------
21 21
22module Numeric.Container ( 22module Numeric.Container (
23 -- * Generic operations
23 Container(..), 24 Container(..),
25 -- * Matrix product and related functions
24 Product(..), 26 Product(..),
25 mXm,mXv,vXm, 27 mXm,mXv,vXm,
26 outer, kronecker, 28 outer, kronecker,
27 29
30 -- * Element conversion
28 Convert(..), 31 Convert(..),
29 Complexable(), 32 Complexable(),
30 RealElement(), 33 RealElement(),
@@ -32,7 +35,11 @@ module Numeric.Container (
32 RealOf, ComplexOf, SingleOf, DoubleOf, 35 RealOf, ComplexOf, SingleOf, DoubleOf,
33 36
34 IndexOf, 37 IndexOf,
35 module Data.Complex 38 module Data.Complex,
39 -- * Deprecated
40 (.*),(*/),(<|>),(<->),
41 vectorMax,vectorMin,
42 vectorMaxIndex, vectorMinIndex
36) where 43) where
37 44
38import Data.Packed 45import Data.Packed
@@ -397,3 +404,85 @@ type family ElementOf c
397type instance ElementOf (Vector a) = a 404type instance ElementOf (Vector a) = a
398type instance ElementOf (Matrix a) = a 405type instance ElementOf (Matrix a) = a
399 406
407------------------------------------------------------------
408
409----------------------------------------------------
410
411{-# DEPRECATED (.*) "use scale a x or scalar a * x" #-}
412
413-- -- | @x .* a = scale x a@
414-- (.*) :: (Linear c a) => a -> c a -> c a
415infixl 7 .*
416a .* x = scale a x
417
418----------------------------------------------------
419
420{-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-}
421
422-- -- | @a *\/ x = scale (recip x) a@
423-- (*/) :: (Linear c a) => c a -> a -> c a
424infixl 7 */
425v */ x = scale (recip x) v
426
427
428------------------------------------------------
429
430{-# DEPRECATED (<|>) "define operator a & b = fromBlocks[[a,b]] and use asRow/asColumn to join vectors" #-}
431{-# DEPRECATED (<->) "define operator a // b = fromBlocks[[a],[b]] and use asRow/asColumn to join vectors" #-}
432
433class Joinable a b where
434 joinH :: Element t => a t -> b t -> Matrix t
435 joinV :: Element t => a t -> b t -> Matrix t
436
437instance Joinable Matrix Matrix where
438 joinH m1 m2 = fromBlocks [[m1,m2]]
439 joinV m1 m2 = fromBlocks [[m1],[m2]]
440
441instance Joinable Matrix Vector where
442 joinH m v = joinH m (asColumn v)
443 joinV m v = joinV m (asRow v)
444
445instance Joinable Vector Matrix where
446 joinH v m = joinH (asColumn v) m
447 joinV v m = joinV (asRow v) m
448
449infixl 4 <|>
450infixl 3 <->
451
452{-- - | Horizontal concatenation of matrices and vectors:
453
454@> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0]
455(6><4)
456 [ 1.0, 0.0, 0.0, 1.0
457 , 0.0, 1.0, 0.0, 2.0
458 , 0.0, 0.0, 1.0, 3.0
459 , 3.0, 0.0, 0.0, 4.0
460 , 0.0, 3.0, 0.0, 5.0
461 , 0.0, 0.0, 3.0, 6.0 ]@
462-}
463-- (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
464a <|> b = joinH a b
465
466-- -- | Vertical concatenation of matrices and vectors.
467-- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
468a <-> b = joinV a b
469
470-------------------------------------------------------------------
471
472{-# DEPRECATED vectorMin "use minElement" #-}
473vectorMin :: (Container Vector t, Element t) => Vector t -> t
474vectorMin = minElement
475
476{-# DEPRECATED vectorMax "use maxElement" #-}
477vectorMax :: (Container Vector t, Element t) => Vector t -> t
478vectorMax = maxElement
479
480
481{-# DEPRECATED vectorMaxIndex "use minIndex" #-}
482vectorMaxIndex :: Vector Double -> Int
483vectorMaxIndex = round . toScalarR MaxIdx
484
485{-# DEPRECATED vectorMinIndex "use maxIndex" #-}
486vectorMinIndex :: Vector Double -> Int
487vectorMinIndex = round . toScalarR MinIdx
488