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

Henning Thielemann lemming at henning-thielemann.de
Mon Dec 20 23:19:00 CET 2010

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 

   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 (zipVectorWith) that 
can be lifted to Matrices by (Matrix.liftMatrix2). Maybe there is some 
magic type class that already handles this - if there wouldn't be the 
Element constraint, it would be the Applicative type class and the liftA2 

More information about the Haskell-Cafe mailing list