Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-26 Thread gutti
Jep, finally got it - that code works now. The Problem I had at the end was that I didn't distinguish between type declaration of a function and a value. -- the commented line for matrix 3 below shows what I did wrong. I think we can close that topic for now - Thanks a lot for Your help Henning

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-25 Thread Henning Thielemann
On Sat, 25 Dec 2010, gutti wrote: this line works : matrixfunction x y = liftMatrix2 (zipVectorWith(\a1 a2 -> if a2>=0 then a1 else 0)) x y but when I use this line : matrixfunction f x y = liftMatrix2 (zipVectorWith f) x y how can / do I have to define f in a seperate line a way, that it

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-25 Thread gutti
Hi, Thanks for the help on the typing issue, that helped my understanding a lot. Regarding the lift2 Matrix: this line works : matrixfunction x y = liftMatrix2 (zipVectorWith(\a1 a2 -> if a2>=0 then a1 else 0)) x y but when I use this line : matrixfunction f x y = liftMatrix2 (zipVector

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-22 Thread Henning Thielemann
On Wed, 22 Dec 2010, gutti wrote: question 1. u see the two commented lines I tried to get ur original line running, but didn't know how to specify f What 'f' ? Do you mean matrixfunction f x y = liftMatrix2 (zipVectorWith f) x y ? ## Code import Numeric.LinearAlgebra import G

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-22 Thread gutti
Hi Henning, You definitly caught me on that little Germanism :-) About Your comments - a lot to learn and take in, but it really helps. - Thanks a lot. I just manged to get the Matrix masking running code looks like (code A see below). Two quick questions: question 1. u see the two commented

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread Henning Thielemann
On Tue, 21 Dec 2010, gutti wrote: One thing that still confuses me a litte: polynom: double -> double ->double polynom x y = y^2 + x^2 + 2*x*y Type declaration for this polynom with two inputs I guess you mean upper case "Double", otherwise it's a type variable and the compiler will ask fo

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread gutti
Hi Henning, Yes I just realised my mistake myself - I hand over the function instead of the result. A really facinating concept by the way. Thanks again for the Matrix notation - will give it a go right away now. And the "manoever critics" on the code is really nice. - Helps me a lot to embrac

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread Henning Thielemann
thanks for the quick and comprehensive help. - I managed to implement Hennings suggestion with mapVector and zipWithVector. -- However have a type inference problem with zipVectorWith -- probably a stupid beginners mistake. (have a look below). I want to look into the matrix thing as well, but

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread gutti
Hi Henning, Hi Alberto, thanks for the quick and comprehensive help. - I managed to implement Hennings suggestion with mapVector and zipWithVector. -- However have a type inference problem with zipVectorWith -- probably a stupid beginners mistake. (have a look below). I want to look into the ma

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread Henning Thielemann
On Tue, 21 Dec 2010, Alberto Ruiz wrote: Vectorized boolean operations are not yet implemented but I hope to get them ready soon, including a "find" function. In the meantime you can use zipVectorWith, as mentioned by Henning. I would not find it a great idea to support the MatLab style of h

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-21 Thread Alberto Ruiz
Hi Phil, On 12/20/2010 10:49 PM, gutti wrote: Hi all, In Matlab the following line of code: V3 = V1.*(V2>0) (V2>0) gives a Bool-Vector with ones (trues) and zero's where elements of V2 are> 0; Then this Bool vector is used to multiply all elements in V1 to zero where the condition V2>0 is no

Re: [Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-20 Thread Henning Thielemann
On Mon, 20 Dec 2010, gutti wrote: In Matlab the following line of code: V3 = V1.*(V2>0) What you certainly need is a zipWith function on matrices that lets you write Matrix.zipWith (\a1 a2 -> if a2>0 then a1 else 0) v1 v2 I can't see such a function in Matrix, but in Vector (zipVectorWi

[Haskell-cafe] Matlab Style Logic Operations ala V1.*(V2>0) on Vectors and Matrices with HMatrix ??

2010-12-20 Thread gutti
Hi all, In Matlab the following line of code: V3 = V1.*(V2>0) (V2>0) gives a Bool-Vector with ones (trues) and zero's where elements of V2 are > 0; Then this Bool vector is used to multiply all elements in V1 to zero where the condition V2>0 is not fulfilled. How can I do that in Haskell ?