diff options
Diffstat (limited to 'packages/base/src/Internal')
-rw-r--r-- | packages/base/src/Internal/C/vector-aux.c | 2 | ||||
-rw-r--r-- | packages/base/src/Internal/Container.hs | 1 | ||||
-rw-r--r-- | packages/base/src/Internal/Conversion.hs | 5 | ||||
-rw-r--r-- | packages/base/src/Internal/LAPACK.hs | 9 | ||||
-rw-r--r-- | packages/base/src/Internal/Matrix.hs | 22 | ||||
-rw-r--r-- | packages/base/src/Internal/Numeric.hs | 49 | ||||
-rw-r--r-- | packages/base/src/Internal/Vectorized.hs | 44 |
7 files changed, 129 insertions, 3 deletions
diff --git a/packages/base/src/Internal/C/vector-aux.c b/packages/base/src/Internal/C/vector-aux.c index 0921c18..70e46bc 100644 --- a/packages/base/src/Internal/C/vector-aux.c +++ b/packages/base/src/Internal/C/vector-aux.c | |||
@@ -1365,7 +1365,7 @@ int int2double(KIVEC(x),DVEC(y)) CONVERT_IMP | |||
1365 | 1365 | ||
1366 | int int2long(KIVEC(x),LVEC(y)) CONVERT_IMP | 1366 | int int2long(KIVEC(x),LVEC(y)) CONVERT_IMP |
1367 | 1367 | ||
1368 | int lont2int(KLVEC(x),IVEC(y)) CONVERT_IMP | 1368 | int long2int(KLVEC(x),IVEC(y)) CONVERT_IMP |
1369 | 1369 | ||
1370 | int long2double(KLVEC(x),DVEC(y)) CONVERT_IMP | 1370 | int long2double(KLVEC(x),DVEC(y)) CONVERT_IMP |
1371 | 1371 | ||
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs index f6355b2..7fe5758 100644 --- a/packages/base/src/Internal/Container.hs +++ b/packages/base/src/Internal/Container.hs | |||
@@ -257,6 +257,7 @@ instance Numeric (Complex Double) | |||
257 | instance Numeric Float | 257 | instance Numeric Float |
258 | instance Numeric (Complex Float) | 258 | instance Numeric (Complex Float) |
259 | instance Numeric I | 259 | instance Numeric I |
260 | instance Numeric Z | ||
260 | 261 | ||
261 | -------------------------------------------------------------------------------- | 262 | -------------------------------------------------------------------------------- |
262 | 263 | ||
diff --git a/packages/base/src/Internal/Conversion.hs b/packages/base/src/Internal/Conversion.hs index 2f4a9c7..4541ec4 100644 --- a/packages/base/src/Internal/Conversion.hs +++ b/packages/base/src/Internal/Conversion.hs | |||
@@ -44,6 +44,11 @@ instance Precision (Complex Float) (Complex Double) where | |||
44 | double2FloatG = asComplex . double2FloatV . asReal | 44 | double2FloatG = asComplex . double2FloatV . asReal |
45 | float2DoubleG = asComplex . float2DoubleV . asReal | 45 | float2DoubleG = asComplex . float2DoubleV . asReal |
46 | 46 | ||
47 | instance Precision I Z where | ||
48 | double2FloatG = long2intV | ||
49 | float2DoubleG = int2longV | ||
50 | |||
51 | |||
47 | -- | Supported real types | 52 | -- | Supported real types |
48 | class (Element t, Element (Complex t), RealFloat t) | 53 | class (Element t, Element (Complex t), RealFloat t) |
49 | => RealElement t | 54 | => RealElement t |
diff --git a/packages/base/src/Internal/LAPACK.hs b/packages/base/src/Internal/LAPACK.hs index d6a2e6e..469b0d5 100644 --- a/packages/base/src/Internal/LAPACK.hs +++ b/packages/base/src/Internal/LAPACK.hs | |||
@@ -37,6 +37,7 @@ foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TMMM C | |||
37 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TMMM F | 37 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TMMM F |
38 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TMMM Q | 38 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TMMM Q |
39 | foreign import ccall unsafe "multiplyI" c_multiplyI :: CInt ::> CInt ::> CInt ::> Ok | 39 | foreign import ccall unsafe "multiplyI" c_multiplyI :: CInt ::> CInt ::> CInt ::> Ok |
40 | foreign import ccall unsafe "multiplyL" c_multiplyL :: Z ::> Z ::> Z ::> Ok | ||
40 | 41 | ||
41 | isT Matrix{order = ColumnMajor} = 0 | 42 | isT Matrix{order = ColumnMajor} = 0 |
42 | isT Matrix{order = RowMajor} = 1 | 43 | isT Matrix{order = RowMajor} = 1 |
@@ -75,6 +76,14 @@ multiplyI a b = unsafePerformIO $ do | |||
75 | app3 c_multiplyI omat a omat b omat s "c_multiplyI" | 76 | app3 c_multiplyI omat a omat b omat s "c_multiplyI" |
76 | return s | 77 | return s |
77 | 78 | ||
79 | multiplyL :: Matrix Z -> Matrix Z -> Matrix Z | ||
80 | multiplyL a b = unsafePerformIO $ do | ||
81 | when (cols a /= rows b) $ error $ | ||
82 | "inconsistent dimensions in matrix product "++ shSize a ++ " x " ++ shSize b | ||
83 | s <- createMatrix ColumnMajor (rows a) (cols b) | ||
84 | app3 c_multiplyL omat a omat b omat s "c_multiplyL" | ||
85 | return s | ||
86 | |||
78 | ----------------------------------------------------------------------------- | 87 | ----------------------------------------------------------------------------- |
79 | 88 | ||
80 | type TSVD t = t ..> t ..> R :> t ..> Ok | 89 | type TSVD t = t ..> t ..> R :> t ..> Ok |
diff --git a/packages/base/src/Internal/Matrix.hs b/packages/base/src/Internal/Matrix.hs index d715cbf..8de06ce 100644 --- a/packages/base/src/Internal/Matrix.hs +++ b/packages/base/src/Internal/Matrix.hs | |||
@@ -333,6 +333,16 @@ instance Element (CInt) where | |||
333 | selectV = selectI | 333 | selectV = selectI |
334 | remapM = remapI | 334 | remapM = remapI |
335 | 335 | ||
336 | instance Element Z where | ||
337 | transdata = transdataAux ctransL | ||
338 | constantD = constantAux cconstantL | ||
339 | extractR = extractAux c_extractL | ||
340 | sortI = sortIdxL | ||
341 | sortV = sortValL | ||
342 | compareV = compareL | ||
343 | selectV = selectL | ||
344 | remapM = remapL | ||
345 | |||
336 | ------------------------------------------------------------------- | 346 | ------------------------------------------------------------------- |
337 | 347 | ||
338 | transdataAux fun c1 d c2 = | 348 | transdataAux fun c1 d c2 = |
@@ -357,6 +367,7 @@ foreign import ccall unsafe "transR" ctransR :: TMM Double | |||
357 | foreign import ccall unsafe "transQ" ctransQ :: TMM (Complex Float) | 367 | foreign import ccall unsafe "transQ" ctransQ :: TMM (Complex Float) |
358 | foreign import ccall unsafe "transC" ctransC :: TMM (Complex Double) | 368 | foreign import ccall unsafe "transC" ctransC :: TMM (Complex Double) |
359 | foreign import ccall unsafe "transI" ctransI :: TMM CInt | 369 | foreign import ccall unsafe "transI" ctransI :: TMM CInt |
370 | foreign import ccall unsafe "transL" ctransL :: TMM Z | ||
360 | 371 | ||
361 | ---------------------------------------------------------------------- | 372 | ---------------------------------------------------------------------- |
362 | 373 | ||
@@ -433,6 +444,7 @@ foreign import ccall unsafe "extractF" c_extractF :: Extr Float | |||
433 | foreign import ccall unsafe "extractC" c_extractC :: Extr (Complex Double) | 444 | foreign import ccall unsafe "extractC" c_extractC :: Extr (Complex Double) |
434 | foreign import ccall unsafe "extractQ" c_extractQ :: Extr (Complex Float) | 445 | foreign import ccall unsafe "extractQ" c_extractQ :: Extr (Complex Float) |
435 | foreign import ccall unsafe "extractI" c_extractI :: Extr CInt | 446 | foreign import ccall unsafe "extractI" c_extractI :: Extr CInt |
447 | foreign import ccall unsafe "extractL" c_extractL :: Extr Z | ||
436 | 448 | ||
437 | -------------------------------------------------------------------------------- | 449 | -------------------------------------------------------------------------------- |
438 | 450 | ||
@@ -444,18 +456,22 @@ sortG f v = unsafePerformIO $ do | |||
444 | sortIdxD = sortG c_sort_indexD | 456 | sortIdxD = sortG c_sort_indexD |
445 | sortIdxF = sortG c_sort_indexF | 457 | sortIdxF = sortG c_sort_indexF |
446 | sortIdxI = sortG c_sort_indexI | 458 | sortIdxI = sortG c_sort_indexI |
459 | sortIdxL = sortG c_sort_indexL | ||
447 | 460 | ||
448 | sortValD = sortG c_sort_valD | 461 | sortValD = sortG c_sort_valD |
449 | sortValF = sortG c_sort_valF | 462 | sortValF = sortG c_sort_valF |
450 | sortValI = sortG c_sort_valI | 463 | sortValI = sortG c_sort_valI |
464 | sortValL = sortG c_sort_valL | ||
451 | 465 | ||
452 | foreign import ccall unsafe "sort_indexD" c_sort_indexD :: CV Double (CV CInt (IO CInt)) | 466 | foreign import ccall unsafe "sort_indexD" c_sort_indexD :: CV Double (CV CInt (IO CInt)) |
453 | foreign import ccall unsafe "sort_indexF" c_sort_indexF :: CV Float (CV CInt (IO CInt)) | 467 | foreign import ccall unsafe "sort_indexF" c_sort_indexF :: CV Float (CV CInt (IO CInt)) |
454 | foreign import ccall unsafe "sort_indexI" c_sort_indexI :: CV CInt (CV CInt (IO CInt)) | 468 | foreign import ccall unsafe "sort_indexI" c_sort_indexI :: CV CInt (CV CInt (IO CInt)) |
469 | foreign import ccall unsafe "sort_indexL" c_sort_indexL :: Z :> I :> Ok | ||
455 | 470 | ||
456 | foreign import ccall unsafe "sort_valuesD" c_sort_valD :: CV Double (CV Double (IO CInt)) | 471 | foreign import ccall unsafe "sort_valuesD" c_sort_valD :: CV Double (CV Double (IO CInt)) |
457 | foreign import ccall unsafe "sort_valuesF" c_sort_valF :: CV Float (CV Float (IO CInt)) | 472 | foreign import ccall unsafe "sort_valuesF" c_sort_valF :: CV Float (CV Float (IO CInt)) |
458 | foreign import ccall unsafe "sort_valuesI" c_sort_valI :: CV CInt (CV CInt (IO CInt)) | 473 | foreign import ccall unsafe "sort_valuesI" c_sort_valI :: CV CInt (CV CInt (IO CInt)) |
474 | foreign import ccall unsafe "sort_valuesL" c_sort_valL :: Z :> Z :> Ok | ||
459 | 475 | ||
460 | -------------------------------------------------------------------------------- | 476 | -------------------------------------------------------------------------------- |
461 | 477 | ||
@@ -467,10 +483,12 @@ compareG f u v = unsafePerformIO $ do | |||
467 | compareD = compareG c_compareD | 483 | compareD = compareG c_compareD |
468 | compareF = compareG c_compareF | 484 | compareF = compareG c_compareF |
469 | compareI = compareG c_compareI | 485 | compareI = compareG c_compareI |
486 | compareL = compareG c_compareL | ||
470 | 487 | ||
471 | foreign import ccall unsafe "compareD" c_compareD :: CV Double (CV Double (CV CInt (IO CInt))) | 488 | foreign import ccall unsafe "compareD" c_compareD :: CV Double (CV Double (CV CInt (IO CInt))) |
472 | foreign import ccall unsafe "compareF" c_compareF :: CV Float (CV Float (CV CInt (IO CInt))) | 489 | foreign import ccall unsafe "compareF" c_compareF :: CV Float (CV Float (CV CInt (IO CInt))) |
473 | foreign import ccall unsafe "compareI" c_compareI :: CV CInt (CV CInt (CV CInt (IO CInt))) | 490 | foreign import ccall unsafe "compareI" c_compareI :: CV CInt (CV CInt (CV CInt (IO CInt))) |
491 | foreign import ccall unsafe "compareL" c_compareL :: Z :> Z :> I :> Ok | ||
474 | 492 | ||
475 | -------------------------------------------------------------------------------- | 493 | -------------------------------------------------------------------------------- |
476 | 494 | ||
@@ -482,6 +500,7 @@ selectG f c u v w = unsafePerformIO $ do | |||
482 | selectD = selectG c_selectD | 500 | selectD = selectG c_selectD |
483 | selectF = selectG c_selectF | 501 | selectF = selectG c_selectF |
484 | selectI = selectG c_selectI | 502 | selectI = selectG c_selectI |
503 | selectL = selectG c_selectL | ||
485 | selectC = selectG c_selectC | 504 | selectC = selectG c_selectC |
486 | selectQ = selectG c_selectQ | 505 | selectQ = selectG c_selectQ |
487 | 506 | ||
@@ -492,6 +511,7 @@ foreign import ccall unsafe "chooseF" c_selectF :: Sel Float | |||
492 | foreign import ccall unsafe "chooseI" c_selectI :: Sel CInt | 511 | foreign import ccall unsafe "chooseI" c_selectI :: Sel CInt |
493 | foreign import ccall unsafe "chooseC" c_selectC :: Sel (Complex Double) | 512 | foreign import ccall unsafe "chooseC" c_selectC :: Sel (Complex Double) |
494 | foreign import ccall unsafe "chooseQ" c_selectQ :: Sel (Complex Float) | 513 | foreign import ccall unsafe "chooseQ" c_selectQ :: Sel (Complex Float) |
514 | foreign import ccall unsafe "chooseL" c_selectL :: Sel Z | ||
495 | 515 | ||
496 | --------------------------------------------------------------------------- | 516 | --------------------------------------------------------------------------- |
497 | 517 | ||
@@ -503,6 +523,7 @@ remapG f i j m = unsafePerformIO $ do | |||
503 | remapD = remapG c_remapD | 523 | remapD = remapG c_remapD |
504 | remapF = remapG c_remapF | 524 | remapF = remapG c_remapF |
505 | remapI = remapG c_remapI | 525 | remapI = remapG c_remapI |
526 | remapL = remapG c_remapL | ||
506 | remapC = remapG c_remapC | 527 | remapC = remapG c_remapC |
507 | remapQ = remapG c_remapQ | 528 | remapQ = remapG c_remapQ |
508 | 529 | ||
@@ -513,6 +534,7 @@ foreign import ccall unsafe "remapF" c_remapF :: Rem Float | |||
513 | foreign import ccall unsafe "remapI" c_remapI :: Rem CInt | 534 | foreign import ccall unsafe "remapI" c_remapI :: Rem CInt |
514 | foreign import ccall unsafe "remapC" c_remapC :: Rem (Complex Double) | 535 | foreign import ccall unsafe "remapC" c_remapC :: Rem (Complex Double) |
515 | foreign import ccall unsafe "remapQ" c_remapQ :: Rem (Complex Float) | 536 | foreign import ccall unsafe "remapQ" c_remapQ :: Rem (Complex Float) |
537 | foreign import ccall unsafe "remapL" c_remapL :: Rem Z | ||
516 | 538 | ||
517 | -------------------------------------------------------------------------------- | 539 | -------------------------------------------------------------------------------- |
518 | 540 | ||
diff --git a/packages/base/src/Internal/Numeric.hs b/packages/base/src/Internal/Numeric.hs index 879daf8..85594cc 100644 --- a/packages/base/src/Internal/Numeric.hs +++ b/packages/base/src/Internal/Numeric.hs | |||
@@ -24,7 +24,7 @@ import Internal.Element | |||
24 | import Internal.ST as ST | 24 | import Internal.ST as ST |
25 | import Internal.Conversion | 25 | import Internal.Conversion |
26 | import Internal.Vectorized | 26 | import Internal.Vectorized |
27 | import Internal.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ,multiplyI) | 27 | import Internal.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ,multiplyI,multiplyL) |
28 | import Data.List.Split(chunksOf) | 28 | import Data.List.Split(chunksOf) |
29 | 29 | ||
30 | -------------------------------------------------------------------------------- | 30 | -------------------------------------------------------------------------------- |
@@ -129,6 +129,45 @@ instance Container Vector I | |||
129 | fromInt' = id | 129 | fromInt' = id |
130 | toInt' = id | 130 | toInt' = id |
131 | 131 | ||
132 | |||
133 | instance Container Vector Z | ||
134 | where | ||
135 | conj' = id | ||
136 | size' = dim | ||
137 | scale' = vectorMapValL Scale | ||
138 | addConstant = vectorMapValL AddConstant | ||
139 | add = vectorZipL Add | ||
140 | sub = vectorZipL Sub | ||
141 | mul = vectorZipL Mul | ||
142 | equal u v = dim u == dim v && maxElement' (vectorMapL Abs (sub u v)) == 0 | ||
143 | scalar' x = fromList [x] | ||
144 | konst' = constantD | ||
145 | build' = buildV | ||
146 | cmap' = mapVector | ||
147 | atIndex' = (@>) | ||
148 | minIndex' = emptyErrorV "minIndex" (fromIntegral . toScalarL MinIdx) | ||
149 | maxIndex' = emptyErrorV "maxIndex" (fromIntegral . toScalarL MaxIdx) | ||
150 | minElement' = emptyErrorV "minElement" (toScalarL Min) | ||
151 | maxElement' = emptyErrorV "maxElement" (toScalarL Max) | ||
152 | sumElements' = sumL | ||
153 | prodElements' = prodL | ||
154 | step' = stepL | ||
155 | find' = findV | ||
156 | assoc' = assocV | ||
157 | accum' = accumV | ||
158 | ccompare' = compareCV compareV | ||
159 | cselect' = selectCV selectV | ||
160 | scaleRecip = undefined -- cannot match | ||
161 | divide = undefined | ||
162 | arctan2' = undefined | ||
163 | cmod' m x | ||
164 | | m /= 0 = vectorMapValL ModVS m x | ||
165 | | otherwise = error $ "cmod 0 on vector of size "++(show $ dim x) | ||
166 | fromInt' = int2longV | ||
167 | toInt' = long2intV | ||
168 | |||
169 | |||
170 | |||
132 | instance Container Vector Float | 171 | instance Container Vector Float |
133 | where | 172 | where |
134 | conj' = id | 173 | conj' = id |
@@ -540,6 +579,13 @@ instance Product I where | |||
540 | normInf = emptyVal (maxElement . vectorMapI Abs) | 579 | normInf = emptyVal (maxElement . vectorMapI Abs) |
541 | multiply = emptyMul multiplyI | 580 | multiply = emptyMul multiplyI |
542 | 581 | ||
582 | instance Product Z where | ||
583 | norm2 = undefined | ||
584 | absSum = emptyVal (sumElements . vectorMapL Abs) | ||
585 | norm1 = absSum | ||
586 | normInf = emptyVal (maxElement . vectorMapL Abs) | ||
587 | multiply = emptyMul multiplyL | ||
588 | |||
543 | 589 | ||
544 | emptyMul m a b | 590 | emptyMul m a b |
545 | | x1 == 0 && x2 == 0 || r == 0 || c == 0 = konst' 0 (r,c) | 591 | | x1 == 0 && x2 == 0 || r == 0 || c == 0 = konst' 0 (r,c) |
@@ -676,6 +722,7 @@ type instance RealOf Float = Float | |||
676 | type instance RealOf (Complex Float) = Float | 722 | type instance RealOf (Complex Float) = Float |
677 | 723 | ||
678 | type instance RealOf I = I | 724 | type instance RealOf I = I |
725 | type instance RealOf Z = Z | ||
679 | 726 | ||
680 | type family ComplexOf x | 727 | type family ComplexOf x |
681 | 728 | ||
diff --git a/packages/base/src/Internal/Vectorized.hs b/packages/base/src/Internal/Vectorized.hs index b9b8239..b1ad424 100644 --- a/packages/base/src/Internal/Vectorized.hs +++ b/packages/base/src/Internal/Vectorized.hs | |||
@@ -98,6 +98,8 @@ sumC = sumg c_sumC | |||
98 | sumI :: Vector CInt -> CInt | 98 | sumI :: Vector CInt -> CInt |
99 | sumI = sumg c_sumI | 99 | sumI = sumg c_sumI |
100 | 100 | ||
101 | sumL = sumg c_sumL | ||
102 | |||
101 | sumg f x = unsafePerformIO $ do | 103 | sumg f x = unsafePerformIO $ do |
102 | r <- createVector 1 | 104 | r <- createVector 1 |
103 | app2 f vec x vec r "sum" | 105 | app2 f vec x vec r "sum" |
@@ -110,6 +112,7 @@ foreign import ccall unsafe "sumR" c_sumR :: TVV Double | |||
110 | foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float) | 112 | foreign import ccall unsafe "sumQ" c_sumQ :: TVV (Complex Float) |
111 | foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double) | 113 | foreign import ccall unsafe "sumC" c_sumC :: TVV (Complex Double) |
112 | foreign import ccall unsafe "sumI" c_sumI :: TVV CInt | 114 | foreign import ccall unsafe "sumI" c_sumI :: TVV CInt |
115 | foreign import ccall unsafe "sumL" c_sumL :: TVV Z | ||
113 | 116 | ||
114 | -- | product of elements | 117 | -- | product of elements |
115 | prodF :: Vector Float -> Float | 118 | prodF :: Vector Float -> Float |
@@ -131,6 +134,7 @@ prodC = prodg c_prodC | |||
131 | prodI :: Vector CInt -> CInt | 134 | prodI :: Vector CInt -> CInt |
132 | prodI = prodg c_prodI | 135 | prodI = prodg c_prodI |
133 | 136 | ||
137 | prodL = prodg c_prodL | ||
134 | 138 | ||
135 | prodg f x = unsafePerformIO $ do | 139 | prodg f x = unsafePerformIO $ do |
136 | r <- createVector 1 | 140 | r <- createVector 1 |
@@ -143,6 +147,7 @@ foreign import ccall unsafe "prodR" c_prodR :: TVV Double | |||
143 | foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float) | 147 | foreign import ccall unsafe "prodQ" c_prodQ :: TVV (Complex Float) |
144 | foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double) | 148 | foreign import ccall unsafe "prodC" c_prodC :: TVV (Complex Double) |
145 | foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt) | 149 | foreign import ccall unsafe "prodI" c_prodI :: TVV (CInt) |
150 | foreign import ccall unsafe "prodL" c_prodL :: TVV Z | ||
146 | 151 | ||
147 | ------------------------------------------------------------------ | 152 | ------------------------------------------------------------------ |
148 | 153 | ||
@@ -200,6 +205,13 @@ toScalarI oper = toScalarAux c_toScalarI (fromei oper) | |||
200 | 205 | ||
201 | foreign import ccall unsafe "toScalarI" c_toScalarI :: CInt -> TVV CInt | 206 | foreign import ccall unsafe "toScalarI" c_toScalarI :: CInt -> TVV CInt |
202 | 207 | ||
208 | -- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. | ||
209 | toScalarL :: FunCodeS -> Vector Z -> Z | ||
210 | toScalarL oper = toScalarAux c_toScalarL (fromei oper) | ||
211 | |||
212 | foreign import ccall unsafe "toScalarL" c_toScalarL :: CInt -> TVV Z | ||
213 | |||
214 | |||
203 | ------------------------------------------------------------------ | 215 | ------------------------------------------------------------------ |
204 | 216 | ||
205 | -- | map of real vectors with given function | 217 | -- | map of real vectors with given function |
@@ -232,6 +244,12 @@ vectorMapI = vectorMapAux c_vectorMapI | |||
232 | 244 | ||
233 | foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt | 245 | foreign import ccall unsafe "mapI" c_vectorMapI :: CInt -> TVV CInt |
234 | 246 | ||
247 | -- | map of real vectors with given function | ||
248 | vectorMapL :: FunCodeV -> Vector Z -> Vector Z | ||
249 | vectorMapL = vectorMapAux c_vectorMapL | ||
250 | |||
251 | foreign import ccall unsafe "mapL" c_vectorMapL :: CInt -> TVV Z | ||
252 | |||
235 | ------------------------------------------------------------------- | 253 | ------------------------------------------------------------------- |
236 | 254 | ||
237 | -- | map of real vectors with given function | 255 | -- | map of real vectors with given function |
@@ -264,6 +282,12 @@ vectorMapValI oper = vectorMapValAux c_vectorMapValI (fromei oper) | |||
264 | 282 | ||
265 | foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt | 283 | foreign import ccall unsafe "mapValI" c_vectorMapValI :: CInt -> Ptr CInt -> TVV CInt |
266 | 284 | ||
285 | -- | map of real vectors with given function | ||
286 | vectorMapValL :: FunCodeSV -> Z -> Vector Z -> Vector Z | ||
287 | vectorMapValL oper = vectorMapValAux c_vectorMapValL (fromei oper) | ||
288 | |||
289 | foreign import ccall unsafe "mapValL" c_vectorMapValL :: CInt -> Ptr Z -> TVV Z | ||
290 | |||
267 | 291 | ||
268 | ------------------------------------------------------------------- | 292 | ------------------------------------------------------------------- |
269 | 293 | ||
@@ -299,6 +323,11 @@ vectorZipI = vectorZipAux c_vectorZipI | |||
299 | 323 | ||
300 | foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt | 324 | foreign import ccall unsafe "zipI" c_vectorZipI :: CInt -> TVVV CInt |
301 | 325 | ||
326 | -- | elementwise operation on CInt vectors | ||
327 | vectorZipL :: FunCodeVV -> Vector Z -> Vector Z -> Vector Z | ||
328 | vectorZipL = vectorZipAux c_vectorZipL | ||
329 | |||
330 | foreign import ccall unsafe "zipL" c_vectorZipL :: CInt -> TVVV Z | ||
302 | 331 | ||
303 | -------------------------------------------------------------------------------- | 332 | -------------------------------------------------------------------------------- |
304 | 333 | ||
@@ -385,6 +414,12 @@ float2IntV = tog c_float2int | |||
385 | int2floatV :: Vector CInt -> Vector Float | 414 | int2floatV :: Vector CInt -> Vector Float |
386 | int2floatV = tog c_int2float | 415 | int2floatV = tog c_int2float |
387 | 416 | ||
417 | int2longV :: Vector I -> Vector Z | ||
418 | int2longV = tog c_int2long | ||
419 | |||
420 | long2intV :: Vector Z -> Vector I | ||
421 | long2intV = tog c_long2int | ||
422 | |||
388 | 423 | ||
389 | tog f v = unsafePerformIO $ do | 424 | tog f v = unsafePerformIO $ do |
390 | r <- createVector (dim v) | 425 | r <- createVector (dim v) |
@@ -397,6 +432,8 @@ foreign import ccall unsafe "int2double" c_int2double :: CInt :> Double :> O | |||
397 | foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok | 432 | foreign import ccall unsafe "double2int" c_double2int :: Double :> CInt :> Ok |
398 | foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok | 433 | foreign import ccall unsafe "int2float" c_int2float :: CInt :> Float :> Ok |
399 | foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok | 434 | foreign import ccall unsafe "float2int" c_float2int :: Float :> CInt :> Ok |
435 | foreign import ccall unsafe "int2long" c_int2long :: I :> Z :> Ok | ||
436 | foreign import ccall unsafe "long2int" c_long2int :: Z :> I :> Ok | ||
400 | 437 | ||
401 | 438 | ||
402 | --------------------------------------------------------------- | 439 | --------------------------------------------------------------- |
@@ -415,10 +452,14 @@ stepF = stepg c_stepF | |||
415 | stepI :: Vector CInt -> Vector CInt | 452 | stepI :: Vector CInt -> Vector CInt |
416 | stepI = stepg c_stepI | 453 | stepI = stepg c_stepI |
417 | 454 | ||
455 | stepL :: Vector Z -> Vector Z | ||
456 | stepL = stepg c_stepL | ||
457 | |||
458 | |||
418 | foreign import ccall unsafe "stepF" c_stepF :: TVV Float | 459 | foreign import ccall unsafe "stepF" c_stepF :: TVV Float |
419 | foreign import ccall unsafe "stepD" c_stepD :: TVV Double | 460 | foreign import ccall unsafe "stepD" c_stepD :: TVV Double |
420 | foreign import ccall unsafe "stepI" c_stepI :: TVV CInt | 461 | foreign import ccall unsafe "stepI" c_stepI :: TVV CInt |
421 | 462 | foreign import ccall unsafe "stepL" c_stepL :: TVV Z | |
422 | 463 | ||
423 | -------------------------------------------------------------------------------- | 464 | -------------------------------------------------------------------------------- |
424 | 465 | ||
@@ -461,6 +502,7 @@ foreign import ccall unsafe "constantR" cconstantR :: TConst Double | |||
461 | foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float) | 502 | foreign import ccall unsafe "constantQ" cconstantQ :: TConst (Complex Float) |
462 | foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double) | 503 | foreign import ccall unsafe "constantC" cconstantC :: TConst (Complex Double) |
463 | foreign import ccall unsafe "constantI" cconstantI :: TConst CInt | 504 | foreign import ccall unsafe "constantI" cconstantI :: TConst CInt |
505 | foreign import ccall unsafe "constantL" cconstantL :: TConst Z | ||
464 | 506 | ||
465 | ---------------------------------------------------------------------- | 507 | ---------------------------------------------------------------------- |
466 | 508 | ||