[Haskell-cafe] hmatrix under ghci on x86_64
I'm using ghci + hmatrix and a few other packages as a Haskell based replacement for Matlab, everything works well so far in terms of available functionality. However, I have encountered an issue when running in ghci on x86_64 systems - calls into functions that in turn call gsl functions will result in a bus error, e.g: Prelude :m +Numeric.Container Prelude Numeric.Container randomVector 10 Gaussian 10 fromList Bus error (core dumped) I attached gdb and found the bus error was happening in gsl_rng_alloc() but some investigation indicate that the problem is probably due to this bug in ghci: http://hackage.haskell.org/trac/ghc/ticket/2912 which has been marked as a duplicate of http://hackage.haskell.org/trac/ghc/ticket/781 and a recent update to 781 indicates that it won't be addressed until at least v 7.6.1 (781 also references http://hackage.haskell.org/trac/ghc/ticket/3658 and it seems that this is a pretty large piece of work - moving to fully dynamically linked ghci which has been around for a while and pushed back a few times). Does anyone know of a workaround that would allow ghci to use wrapped gsl functionality on x86_64 systems in the meantime? Most linux boxes used by quants are x86_64 now, so this issue will impact many people who would like to use Haskell instead of Matlab. Thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hmatrix-static with ghc 7.0.2
Hi all, Has anyone managed to get hmatrix-static to compile with ghc 7.0.2, and if so would you be willing to share a patch? With best wishes, Anand ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hmatrix-repa: hmatrix and Repa interoperability
Hi, I have uploaded a module to hackage in the package hmatrix-repa. It provides conversion functions between hmatrix vectors/matrices and repa arrays. I don't know whether it will be of much use, but even the Repa documentation suggests using LAPACK for performance critical tasks, such as matrix multiplication. These are reference implementations and might benefit from some optimisations. Cheers, VIvian DISCLAIMER This transmission contains information that may be confidential. It is intended for the named addressee only. Unless you are the named addressee you may not copy or use it or disclose it to anyone else. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi, I created some code from scratch - probably ugly beginners style - so I'm keen to get tips how to make it more pretty and faster Cheers Phil import Data.List -- Input Data xi :: [Double] xi = [0 .. 10] yi :: [Double] yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] x = 11 :: Double -- Functions limIndex xi idx | idx 0 = 0 | idx (length xi)-2 = (length xi)-2 | otherwise = idx getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] interp xi yi x = let pts = getPnts xi yi (getIndex xi x) in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 -- Calc y = interp xi yi x main = do -- Output Data print (y) -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3356966.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Tuesday 25 January 2011 22:05:34, gutti wrote: Hi, I created some code from scratch - probably ugly beginners style - so I'm keen to get tips how to make it more pretty and faster Cheers Phil import Data.List -- Input Data xi :: [Double] xi = [0 .. 10] yi :: [Double] yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] x = 11 :: Double -- Functions limIndex xi idx | idx 0 = 0 | idx (length xi)-2 = (length xi)-2 | otherwise = idx limIndex xi idx = max 0 (min idx (length xi - 2)) not necessarily better, but different getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) maybe val id is the same as fromMaybe val getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] getPnts xi yi idx = case drop idx $ zip xi yi of ((x1,y1):(x2,y2):_) - [x1,x2,y1,y2] _ - error Not enough points interp xi yi x = let pts = getPnts xi yi (getIndex xi x) in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 let (x1:x2:y1:y2:_) = getPnts xi yi (getIndex xi x) in (y2 - y1)/(x2 - x1)*(x-x1) + y1 -- Calc y = interp xi yi x main = do -- Output Data print (y) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Tue, 25 Jan 2011, gutti wrote: I created some code from scratch - probably ugly beginners style - so I'm keen to get tips how to make it more pretty and faster Can you please add type signatures? This would help me understanding. import Data.List -- Input Data xi :: [Double] xi = [0 .. 10] yi :: [Double] yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] x = 11 :: Double -- Functions limIndex xi idx | idx 0 = 0 | idx (length xi)-2 = (length xi)-2 | otherwise = idx limIndex :: [a] - Int - Int limIndex xi idx = max 0 (min (length xi - 2) idx) see also utility-ht:Data.Ord.HT.limit http://hackage.haskell.org/packages/archive/utility-ht/0.0.5.1/doc/html/Data-Ord-HT.html getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] Since this list has always four elements, I suggest a quadruple: getPnts xi yi idx = (xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)) (!!) is not very efficient, but for now I imagine that's an access to a HMatrix-Vector. interp xi yi x = let pts = getPnts xi yi (getIndex xi x) in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 let (x0,x1,y0,y1) = getPnts xi yi (getIndex xi x) in (y1-y0)/(x1-x0)*(x-x0)+y0 For more clarity you might define a function for linear interpolation between two nodes. I use the following implementation that is more symmetric. I hope it is more robust with respect to cancelations: interpolateLinear :: Fractional a = (a,a) - (a,a) - a - a interpolateLinear (x0,y0) (x1,y1) x = (y0*(x1-x) + y1*(x-x0))/(x1-x0) (Taken from http://code.haskell.org/~thielema/htam/src/Numerics/Interpolation/Linear.hs) -- Calc y = interp xi yi x main = do -- Output Data print (y) print y is just fine, orprint (interp xi yi x) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Henning, thanks for the code review -- reason that I don't use the type declaration a lot -- It causes trouble , because I don't yet fully understand it. When I declare what I think is right is fails - see Message at bottom -- so what's wrong ? By the way I just used lists so far - no arrays -- Why is !! inefficient ? - what is better - Cheers Phil 1 import Data.List 2 3 -- Input Data 4 xi :: [Double] 5 xi = [0 .. 10] 6 yi :: [Double] 7 yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] 8 x = 11 :: Double 9 10 -- Functions 11 limIndex :: [a] - Int - Int 12 limIndex xi idx 13| idx 0 = 0 14 | idx (length xi)-2 = (length xi)-2 15| otherwise = idx 16 17 getIndex :: [a] - Double - Int 18 getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) 19 20 getPnts :: [a] - [a] - Int - [a] 21 getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] 22 23 interp :: [a] - [a] - Double - Double 24 interp xi yi x = 25 let pts = getPnts xi yi (getIndex xi x) 26 in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 27 28 -- Calc 29 y = interp xi yi x 30 31 main = do 32 -- Output Data 33 print (y) === Compiler Error Message === interp_v4.hs:18:66: Couldn't match expected type `Double' against inferred type `a' `a' is a rigid type variable bound by the type signature for `getIndex' at interp_v4.hs:17:13 Expected type: [Double] Inferred type: [a] In the second argument of `findIndex', namely `xi' In the third argument of `maybe', namely `(findIndex ( x) xi)' interp_v4.hs:26:39: Couldn't match expected type `Double' against inferred type `a' `a' is a rigid type variable bound by the type signature for `interp' at interp_v4.hs:23:11 In the second argument of `(-)', namely `pts !! 0' In the second argument of `(*)', namely `(x - pts !! 0)' In the first argument of `(+)', namely `(pts !! 3 - pts !! 2) / (pts !! 1 - pts !! 0) * (x - pts !! 0)' -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3357089.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Tuesday 25 January 2011 23:16:49, gutti wrote: Hi Henning, thanks for the code review -- reason that I don't use the type declaration a lot -- It causes trouble , because I don't yet fully understand it. When I declare what I think is right is fails - see Message at bottom -- so what's wrong ? See inline. By the way I just used lists so far - no arrays -- Why is !! inefficient ? - what is better - Cheers Phil (!!) is inefficient because it has to traverse the list from the start to the desired index. That's fine if you do it once, but if you do it a lot, you're probably doing something wrong. 1 import Data.List 2 3 -- Input Data 4 xi :: [Double] 5 xi = [0 .. 10] 6 yi :: [Double] 7 yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] 8 x = 11 :: Double 9 10 -- Functions 11 limIndex :: [a] - Int - Int 12 limIndex xi idx 13| idx 0 = 0 14 | idx (length xi)-2 = (length xi)-2 15| otherwise = idx 16 17 getIndex :: [a] - Double - Int 18 getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) The type of () is () :: Ord a = a - a - Bool , so both arguments to () must have the same type and that type must be an instance of the Ord class. Since the type of x is stated to be Double, ( x) :: Double - Bool, so the list needs to have the type [Double]. You can ask ghci what the (most general) type of your function is, here it's getIndex :: Ord a = [a] - a - Int 19 20 getPnts :: [a] - [a] - Int - [a] 21 getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] 22 23 interp :: [a] - [a] - Double - Double 24 interp xi yi x = 25let pts = getPnts xi yi (getIndex xi x) 26in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 (-) :: Num a = a - a - a The two arguments of (-) must have the same type and the result has the same type too. x is stated to be a Double by the signature, so we must have pts :: [Double] and hence xi :: [Double], yi :: [Double]. For the most general type, the use of getIndex implies an Ord constraint, (-) and (*) give a Num constraint and (/) :: Fractional a = a - a - a , so the use of (/) adds a Fractional constraint. Fractional implies Num, hence interp :: (Ord a, Fractional a) = [a] - [a] - a - a 27 28 -- Calc 29 y = interp xi yi x 30 31 main = do 32-- Output Data 33print (y) === Compiler Error Message === interp_v4.hs:18:66: Couldn't match expected type `Double' against inferred type `a' `a' is a rigid type variable bound by the type signature for `getIndex' at interp_v4.hs:17:13 Expected type: [Double] Inferred type: [a] In the second argument of `findIndex', namely `xi' In the third argument of `maybe', namely `(findIndex ( x) xi)' interp_v4.hs:26:39: Couldn't match expected type `Double' against inferred type `a' `a' is a rigid type variable bound by the type signature for `interp' at interp_v4.hs:23:11 In the second argument of `(-)', namely `pts !! 0' In the second argument of `(*)', namely `(x - pts !! 0)' In the first argument of `(+)', namely `(pts !! 3 - pts !! 2) / (pts !! 1 - pts !! 0) * (x - pts !! 0)' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi, I've taken a look at your code and refactored a bit to use Haskell's list functions. The functionality should be identical. One of the advantages of using the list functions is that you don't have to worry about an out-of-bounds exception - which is what your limIndex function corrects for. Also instead of grabbing list indices I've created a data structure for points. I'll just present the code and let you ask me any questions. -deech import Data.List -- Input Data xi :: [Double] xi = [0 .. 10] yi :: [Double] yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] x = 11 :: Double type Point = ((Double,Double),(Double,Double)) getPnts :: Double - [Point] - Point getPnts x [] = error empty list getPnts x xs = case (break (\((i,_),_) - i x) xs) of (_,[]) - last xs (_,xs) - head xs byTwos :: [a] - [(a,a)] byTwos []= [] byTwos (x:[])= [] byTwos (x:y:xs) = (x,y) : byTwos (y:xs) interp :: [Double] - [Double] - Double - Double interp xi yi x = let ((x1,x2),(y1,y2)) = getPnts x $ zip (byTwos xi) (byTwos yi) in (y2-y1)/(x2-x1) * (x-x1) + x2 main = print $ interp xi yi 11 On Tue, Jan 25, 2011 at 3:05 PM, gutti philipp.guttenb...@gmx.net wrote: Hi, I created some code from scratch - probably ugly beginners style - so I'm keen to get tips how to make it more pretty and faster Cheers Phil import Data.List -- Input Data xi :: [Double] xi = [0 .. 10] yi :: [Double] yi = [2, 3, 5, 6, 7, 8, 9, 10 , 9, 8, 7] x = 11 :: Double -- Functions limIndex xi idx | idx 0 = 0 | idx (length xi)-2 = (length xi)-2 | otherwise = idx getIndex xi x = limIndex xi (maybe (length xi) id (findIndex (x) xi)-1) getPnts xi yi idx = [xi !! idx, xi !! (idx+1), yi !! idx, yi !! (idx+1)] interp xi yi x = let pts = getPnts xi yi (getIndex xi x) in (pts!!3-pts!!2)/(pts!!1-pts!!0)*(x-pts!!0)+pts!!2 -- Calc y = interp xi yi x main = do -- Output Data print (y) -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3356966.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Phil, On 22/01/11 23:13, gutti wrote: - are t a b c d points or curve parameters ? a b c d are points, t is the interpolation coefficient (between 0 and 1) - how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't see how it works essentially, it creates a matrix of 1d splines, but now I see that this isn't what you wanted... for interpolated 2d matrix lookup, something like this, perhaps: -- using the cubic interpolator from earlier in the thread m @@+ (x, y) = let (i, j) = (floor x, floor y) (s, t) = (x - fromIntegral i, y - fromIntegral j) cx j' = cubic s (m@@(i-1,j')) (m@@(i,j')) (m@@(i+1,j')) (m@@(i+2,j')) in cubic t (cx (j-1)) (cx j) (cx (j+1)) (cx (j+2)) test = let m = (1616) [0 ..] n = 36 r = 5 (x0, y0) = (8, 8) in [ m @@+ (x, y) | a - [0 .. n - 1] , let a' = 2 * pi * fromIntegral a / fromIntegral n , let x = x0 + r * cos a' , let y = y0 + r * sin a' ] Claude -- http://claudiusmaximus.goto10.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Sun, 23 Jan 2011, Claude Heiland-Allen wrote: essentially, it creates a matrix of 1d splines, but now I see that this isn't what you wanted... for interpolated 2d matrix lookup, something like this, perhaps: Interpolated matrix or vector lookup can of course be written as interpolation of sub-matrices or sub-vectors. For lazy matrices and vectors this would be almost as efficient. interp i v = vectorIndex (floor i) $ interpolateVectorSpace (fraction i) (Vector.take (n-3) $ Vector.drop 0 v) (Vector.take (n-3) $ Vector.drop 1 v) (Vector.take (n-3) $ Vector.drop 2 v) (Vector.take (n-3) $ Vector.drop 3 v) (Sorry for the many fictional functions.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Dear Haskellers, I'm looking for Vector and especially Matric interpolation ala: z = interp2 (xMatrix, yMatrix, zMatrix, x, y) - x and y can be single values or also vectors or matrices - indeally with the options nearest, linear, quadratic, qubic.. Any hope that there is something similar especially using the HMatrix matrices (Matrix Double). - If I have to code it any suggestions ? Cheers Phil -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3352833.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Phil, On 22/01/11 14:07, gutti wrote: Dear Haskellers, I'm looking for Vector and especially Matric interpolation ala: z = interp2 (xMatrix, yMatrix, zMatrix, x, y) - x and y can be single values or also vectors or matrices - indeally with the options nearest, linear, quadratic, qubic.. Any hope that there is something similar especially using the HMatrix matrices (Matrix Double). - If I have to code it any suggestions ? Cheers Phil I'm not sure if this is what you mean, as I'm not familiar with matlab, so apologies if this is totally a waste of time.. But I had a simple cubic interpolation implemented already, it wasn't too hard to lift it into matrices (there are many elevation permutations, I imagine), I used (fromLists ...stuff... toLists), but maybe there's a better way: {-# LANGUAGE NoMonomorphismRestriction #-} module Interpolate where import Numeric.LinearAlgebra import Data.List (zipWith5) -- cubic interpolation cubic t a b c d = let a1 = 0.5 * (c - a) a2 = a - 2.5 * b + 2.0 * c - 0.5 * d a3 = 0.5 * (d - a) + 1.5 * (b - c) in ((a3 * t + a2) * t + a1) * t + b -- boring manual lifting liftMatrix5 f a b c d e = let la = toLists a lb = toLists b lc = toLists c ld = toLists d le = toLists e in fromLists (zipWith5 (zipWith5 f) la lb lc ld le) -- test mt = (33) [0, 0.1 ..] ma = (33) [0, 1 ..] mb = (33) [0, 2 ..] mc = (33) [0, 3 ..] md = (33) [0, 4 ..] test = liftMatrix5 cubic mt ma mb mc md {- test output (33) [0.0, 2.1, 4.4 ,6.9, 9.6, 12.5 , 15.601, 18.9, 22.4 ] -} -- http://claudiusmaximus.goto10.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Sat, 22 Jan 2011, gutti wrote: I'm looking for Vector and especially Matric interpolation ala: z = interp2 (xMatrix, yMatrix, zMatrix, x, y) - x and y can be single values or also vectors or matrices - indeally with the options nearest, linear, quadratic, qubic.. Any hope that there is something similar especially using the HMatrix matrices (Matrix Double). - If I have to code it any suggestions ? Here is the power of Haskell - I have implemented some interpolations in terms of Vector spaces, that is you can interpolate Vectors, Matrices, Functions, or whatever you like: http://code.haskell.org/synthesizer/core/src/Synthesizer/Interpolation/Module.hs However this code is specialised to interpolate between adjacent objects in a stream, and needs numeric-prelude, and you have to declare an instance for Algebra.Module.C Double (HMatrix Double) and this would be an orphan instance that should better go to an official separate package ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Henning, thanks - I don't claim I understand that yet with my limited haskell knowledge, but it looks rather advanced passing modules around. If there isn't anything standard of the shelf (which is important feedback), than its probably the best for me to pull it up from scratch and go through the learning curve. Many thanks, Philipp -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3353225.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Claude, thanks a lot. - Your code looks interesting. I just don't fully get how it works: - are t a b c d points or curve parameters ? - how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't see how it works Cheers Phil -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3353231.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
Hi Claude, thanks a lot. - Your code looks interesting. I just don't fully get how it works: - are t a b c d points or curve parameters ? - how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't see how it works Cheers Phil -- View this message in context: http://haskell.1045720.n5.nabble.com/HMatrix-Vector-Matrix-interpolation-ala-Matlab-interp-interp2-tp3352833p3353230.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??
On Sat, 22 Jan 2011, gutti wrote: I just don't fully get how it works: - are t a b c d points or curve parameters ? - how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't see how it works I think it interpolates cubically between four equidistant nodes, then it lifts the interpolation from scalar values to matrices. However, I would avoid interim lists, but just perform a zipMatrix5. I hope there is one ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix on os x
Hi, yep - that's the problem I had. run cabal with the -v (verbose option) cabal install -v so you can see exactly where it's failing try the following : --extra-lib-dirs=PATH where PATH was (for me) was /sw/lib I'm not sure but I may have had to use --extra-include-dirs also. Generally I have a lot of trouble with cabal installing things properly using the mac, but the above options usually fix the problem. I did get hmatrix working. Then when I ran a an example which did a simple vector operation, it segfaulted. However the linear algebra routines all seemed to work. Let me know what happens. The linux pc gave me even more problems which I eventually traced to LD_LIBRARY_PATH needing to include the lib dirs. HTH. Brian On Sep 9, 2009, at 11:57 PM, Martijn van Steenbergen wrote: brian wrote: yep I had some trouble too, although interestingly less than on linux pc. can you provide some error messages and we can see if your problems are the same one's I saw. If this helps, here is the error message I got: Configuring hmatrix-0.5.2.2... Checking foreign libraries... FAIL *** Sorry, I can't link GSL. *** Please make sure that the appropriate -dev packages are installed. *** You can also specify the required libraries using *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc. setup: Package hmatrix-0.5.2.2 can't be built on this system. cabal: Error: some packages failed to install: hmatrix-0.5.2.2 failed during the building phase. The exception was: exit: ExitFailure 1 M. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix on os x
yep I had some trouble too, although interestingly less than on linux pc. can you provide some error messages and we can see if your problems are the same one's I saw. I think most of my problem involved the location of the libraries. Also I think that you are really going to want to have fink installed. Brian On Sep 7, 2009, at 7:06 PM, Ben wrote: hello -- i've been having a heck of a time installing hmatrix on mac os x. i've seen the help pages including http://mit.edu/harold/Public/easyVisionNotes.html but they haven't helped me. my setup is haskell platform 2009.2.0.2 (ghc 6.10.4) os x 10.5 macports -- i've tried installing gsl and gsl-devel to no avail. i've tried cabal install with various options, to no avail. has anyone else have luck with this? best, ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix on os x
brian wrote: yep I had some trouble too, although interestingly less than on linux pc. can you provide some error messages and we can see if your problems are the same one's I saw. If this helps, here is the error message I got: Configuring hmatrix-0.5.2.2... Checking foreign libraries... FAIL *** Sorry, I can't link GSL. *** Please make sure that the appropriate -dev packages are installed. *** You can also specify the required libraries using *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc. setup: Package hmatrix-0.5.2.2 can't be built on this system. cabal: Error: some packages failed to install: hmatrix-0.5.2.2 failed during the building phase. The exception was: exit: ExitFailure 1 M. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hmatrix on os x
hello -- i've been having a heck of a time installing hmatrix on mac os x. i've seen the help pages including http://mit.edu/harold/Public/easyVisionNotes.html but they haven't helped me. my setup is haskell platform 2009.2.0.2 (ghc 6.10.4) os x 10.5 macports -- i've tried installing gsl and gsl-devel to no avail. i've tried cabal install with various options, to no avail. has anyone else have luck with this? best, ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
Hi The INSTALL file in the hmatrix repository has some very clear instructions for installation on Windows. http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALL However note this section at the bottom: Unfortunately the lapack dll supplied by the R system does not include zgels_, zgelss_, and zgees_, so the functions depending on them (linearSolveLS, linearSolveSVD, and schur for complex data) will produce a non supported in this OS runtime error. Of course linearSolve is exactly what you will be wanting so this won't work for you. I ran into exactly this problem myself. I actually didn't get as far as a run-time error as I got a linker error. I don't have any solution for you though, sorry. regards allan Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
I was planning to recompile everything (ATLAS, LAPACK and GHC included) this weekend, so I can have a similar environment on Windows and Linux... Having to borrow libraries Since I am married, this means it will actually happen on some weekend till 2010. What I really would like to try is a (purely?) functional approach to create a (P)LU decomposition of a matrix. I am not too much worried (at first) with performance or memory constraints, since I only want to see how beautiful it gets (or not!). (This one might happen somewhere in this century...) Thanks anyway On Wed, Jan 28, 2009 at 07:57, allan a.d.cl...@ed.ac.uk wrote: Hi The INSTALL file in the hmatrix repository has some very clear instructions for installation on Windows. http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALLhttp://perception.inf.um.es/%7Earuiz/darcs/hmatrix/INSTALL However note this section at the bottom: Unfortunately the lapack dll supplied by the R system does not include zgels_, zgelss_, and zgees_, so the functions depending on them (linearSolveLS, linearSolveSVD, and schur for complex data) will produce a non supported in this OS runtime error. Of course linearSolve is exactly what you will be wanting so this won't work for you. I ran into exactly this problem myself. I actually didn't get as far as a run-time error as I got a linker error. I don't have any solution for you though, sorry. regards allan Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
Well, I guess I am not the only one! This blog show exactly what I am looking for! http://quantile95.com/2008/10/31/ann-blas-bindings-for-haskell-version-06/ On Wed, Jan 28, 2009 at 08:21, Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com wrote: I was planning to recompile everything (ATLAS, LAPACK and GHC included) this weekend, so I can have a similar environment on Windows and Linux... Having to borrow libraries Since I am married, this means it will actually happen on some weekend till 2010. What I really would like to try is a (purely?) functional approach to create a (P)LU decomposition of a matrix. I am not too much worried (at first) with performance or memory constraints, since I only want to see how beautiful it gets (or not!). (This one might happen somewhere in this century...) Thanks anyway On Wed, Jan 28, 2009 at 07:57, allan a.d.cl...@ed.ac.uk wrote: Hi The INSTALL file in the hmatrix repository has some very clear instructions for installation on Windows. http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALLhttp://perception.inf.um.es/%7Earuiz/darcs/hmatrix/INSTALL However note this section at the bottom: Unfortunately the lapack dll supplied by the R system does not include zgels_, zgelss_, and zgees_, so the functions depending on them (linearSolveLS, linearSolveSVD, and schur for complex data) will produce a non supported in this OS runtime error. Of course linearSolve is exactly what you will be wanting so this won't work for you. I ran into exactly this problem myself. I actually didn't get as far as a run-time error as I got a linker error. I don't have any solution for you though, sorry. regards allan Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
Hi, allan wrote: Hi The INSTALL file in the hmatrix repository has some very clear instructions for installation on Windows. http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALL However note this section at the bottom: Unfortunately the lapack dll supplied by the R system does not include zgels_, zgelss_, and zgees_, so the functions depending on them (linearSolveLS, linearSolveSVD, and schur for complex data) will produce a non supported in this OS runtime error. Note also the next sentence: If you find an alternative free and complete lapack.dll which works well for this system please let me know. Perhaps some Windows expert can give advice on the required dll's for Haskell programs using LAPACK in Windows. Thanks, Alberto Of course linearSolve is exactly what you will be wanting so this won't work for you. I ran into exactly this problem myself. I actually didn't get as far as a run-time error as I got a linker error. I don't have any solution for you though, sorry. regards allan Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
Well, I guess I am not the only one! This blog show exactly what I am looking for! http://quantile95.com/2008/10/31/ann-blas-bindings-for-haskell-version-06/ If you're looking to implement other linear algebra algorithms in Haskell, there's enough at http://github.com/patperry/lapack to implement a QR decomposition with column pivoting with fairly minimal effort. Householder reflections and permutation matrices are already supported. You will also need the latest BLAS bindings, also available at github. Note that these libraries are not compatible with hmatrix. What would *really* be awesome would be an implementation of an SVD algorithm: take a bidiagonal matrix and produce a (lazy) list of Givens rotations that diagonalizes the matrix. That would probably be a 2-4 week project, but would be really useful. Take a look at the code and references at http://netlib.org/lapack/explore-html/zbdsqr.f.html if you're interested. The LAPACK version, zbdsqr, takes B and factors it as B = Q S P^H. Optionally, it sets U := U Q VT := P^H VT C := Q^H C Annoyingly, there is no way to specify an input matrix D and set D := D P. It'd be really cool to have a Haskell function of type svdBidiagonal :: (WriteBanded a m) = a (n,p) e - m [(Givens,Givens)] The type signature means that a is a mutable banded matrix of shape (n,p) with elements of type e that can be modified in monad m. I'm envisioning that the result is a lazy list, gs, and that no computation gets done until the gs list is traversed. So, if someone just wants singular values, then they would do liftM length . svdBidiagonal. If they want to update U := U Q, then they would do something like: mapM_ (applyGivens u) $ liftM (fst . unzip) $ svdDidiagonal a The user has the option to update as many matrices they want in whatever way they want. This is only possible with laziness. It is a perfect example of the glue John Hughes talks about in Why Functional Programming Matters. Patrick On Wed, Jan 28, 2009 at 08:21, Rafael Gustavo da Cunha Pereira Pinto RafaelGCPP.Linux at gmail.com wrote: I was planning to recompile everything (ATLAS, LAPACK and GHC included) this weekend, so I can have a similar environment on Windows and Linux... Having to borrow libraries Since I am married, this means it will actually happen on some weekend till 2010. What I really would like to try is a (purely?) functional approach to create a (P)LU decomposition of a matrix. I am not too much worried (at first) with performance or memory constraints, since I only want to see how beautiful it gets (or not!). (This one might happen somewhere in this century...) Thanks anyway On Wed, Jan 28, 2009 at 07:57, allan a.d.clark at ed.ac.uk wrote: Hi The INSTALL file in the hmatrix repository has some very clear instructions for installation on Windows. http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALLhttp://perception.inf.um.es/%7Earuiz/darcs/hmatrix/INSTALL However note this section at the bottom: Unfortunately the lapack dll supplied by the R system does not include zgels_, zgelss_, and zgees_, so the functions depending on them (linearSolveLS, linearSolveSVD, and schur for complex data) will produce a non supported in this OS runtime error. Of course linearSolve is exactly what you will be wanting so this won't work for you. I ran into exactly this problem myself. I actually didn't get as far as a run-time error as I got a linker error. I don't have any solution for you though, sorry. regards allan Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -- next part
[Haskell-cafe] hmatrix, Windows and GCC
Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. My questions: 1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete! 2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is there any guide for doing this? 3) Has any of you tried hmatrix on Windows? How did you do it? Thanks, Rafael -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix, Windows and GCC
On Tue, 2009-01-27 at 09:33 -0200, Rafael Gustavo da Cunha Pereira Pinto wrote: Hi all, I am writing a program that uses hmatrix for solving some linear systems. The hmatrix package depends on BLAS, which, in turn, depend on GCC 4.2 to be built (at least ATLAS does). GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me with the impression that I would have incompatible ABIs. Check the GCC documentation. I would expect that the C ABI is completely stable on Windows. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [hmatrix] build error
Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas? -- error doing runhaskell Setup build -- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make -- error doing runhaskell Setup build -- I believe `__powidf2' is a internal symbol in gcc and it is hidden. The system is archlinux x86_64 and the software I used are atlas-lapack 3.8.2-1 gcc 4.3.2-1 Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic Thread model: posix gcc version 4.3.2 (GCC) ghc 6.8.2-2 [(Project name,The Glorious Glasgow Haskell Compilation System) ,(Project version,6.8.2) ,(Booter version,6.8.2) ,(Stage,2) ,(Interface file version,6) ,(Have interpreter,YES) ,(Object splitting,YES) ,(Have native code generator,YES) ,(Support SMP,YES) ,(Unregisterised,NO) ,(Tables next to code,YES) ,(Win32 DLLs,) ,(RTS ways, debug thr thr_p thr_debug) ,(Leading underscore,NO) ] I googled but no useful information. Best, Xiao-Yong -- c/*__o/* \ * (__ */\ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [hmatrix] build error
Xiao-Yong Jin [EMAIL PROTECTED] writes: Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas? -- error doing runhaskell Setup build -- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make -- error doing runhaskell Setup build -- It might be a problem of atlas. With Intel's MKL, it builds fine. -- c/*__o/* \ * (__ */\ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hmatrix
What is the most efficient way to update a position in a matrix or a vector? I came up with this: updateVector :: Vector Double - Int - Double - Vector Double updateVector vec pos val = vec `add` v2 where v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @ pos)):(replicate ((dim vec)- pos - 1) 0.0)) but this seems pretty inefficient to me. thanks, Anatoly ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix
what package do you install/import to get at Vector? 2008/5/31 Thomas Hartman [EMAIL PROTECTED]: what package do you install/import to get at Vector? 2008/5/31 Anatoly Yakovenko [EMAIL PROTECTED]: What is the most efficient way to update a position in a matrix or a vector? I came up with this: updateVector :: Vector Double - Int - Double - Vector Double updateVector vec pos val = vec `add` v2 where v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @ pos)):(replicate ((dim vec)- pos - 1) 0.0)) but this seems pretty inefficient to me. thanks, Anatoly ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hmatrix
http://perception.inf.um.es/~aruiz/darcs/hmatrix/doc/html/Data-Packed-Vector.html provided by hmatrix On Sat, May 31, 2008 at 3:20 PM, Thomas Hartman [EMAIL PROTECTED] wrote: what package do you install/import to get at Vector? 2008/5/31 Thomas Hartman [EMAIL PROTECTED]: what package do you install/import to get at Vector? 2008/5/31 Anatoly Yakovenko [EMAIL PROTECTED]: What is the most efficient way to update a position in a matrix or a vector? I came up with this: updateVector :: Vector Double - Int - Double - Vector Double updateVector vec pos val = vec `add` v2 where v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @ pos)):(replicate ((dim vec)- pos - 1) 0.0)) but this seems pretty inefficient to me. thanks, Anatoly ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe