Re: [Haskell-cafe] Data Type Inheritance ala OO - Inheritence -- howto best in Haskell ?

2011-06-16 Thread gutti
Hi David, 

thanks for the links. I had a lok at the OO-paper some time ago already,
heard however that its quite unusual and rather tricky to do OO-style
programming in Haskell. So I'm looking for suggestions how to tackle this
problem in a functional way.

Cheers Phil

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Data-Type-Inheritance-ala-OO-Inheritence-howto-best-in-Haskell-tp4494800p4496726.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] ANN: hmatrix-0.11

2011-01-26 Thread gutti

Hi Alberto. 

first of all thanks for an awesome library, it really makes life a lot
easier. 

Then thanks as well for Your openness on the re-licensing issue. 

I played with the thought of starting some numeric software with haskell -
haskell is a really exiting language in that respect, the efficient matrix
calcs however are of the essence.

Very likely it won't happen now - for other reasons, but I realised that for
promoting Haskell further
this could be a key issue.

Now it definitely doesn't sound trivial to get away from the external
libraries for efficient matrix storage via optimised c-code, but whatever u
can move without big effort is a start.

But no pressure from my side,
 

Cheers Phil  


-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/ANN-hmatrix-0-11-tp3357796p3358841.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] GPL License of H-Matrix and prelude numeric

2011-01-25 Thread gutti

Hi Ivan, 

thanks for making me aware that this is a potentialy controverse topic. -- I
have highest respect of people writing open source and I totally respect
their decision.


-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/GPL-License-of-H-Matrix-and-prelude-numeric-tp3357022p3357131.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 ??

2011-01-25 Thread gutti

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


[Haskell-cafe] GPL License of H-Matrix and prelude numeric

2011-01-25 Thread gutti

Hi all, 

I realised that haskell in the base libraries tries to consistently stick to
the permissive BSD license to also give the language traction in the
commercial world.

The H-Matrix and the prelude numeric packages however, which in my mind
cover really important ground work, are issued under the resprictive GPL. 

Is that only because they link into other external GNU - libaries with GPL
license ? -- If yes would be repackaging the haskell-native bits in an extra
BSD package an option ?  

Cheers Phil

 
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/GPL-License-of-H-Matrix-and-prelude-numeric-tp3357022p3357022.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 ??

2011-01-25 Thread gutti


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 ??

2011-01-22 Thread gutti

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 ??

2011-01-22 Thread gutti

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 ??

2011-01-22 Thread gutti

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


[Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??

2011-01-22 Thread gutti

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] H98, OOHaskell - getting started with objects in Haskell

2011-01-18 Thread gutti

Thanks to all of You, 

I think I learnt really a lot just on this thread about Haskell and also OO
in general. 

I fear I'm too busy in the near future to come up with a good example and
some more questions. Might happen later, because this topic is really
interesting. Till then -- Thanks Philipp 


-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3346982.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] H98, OOHaskell - getting started with objects in Haskell

2011-01-16 Thread gutti

Hi Nick, 

thanks a lot -- timber-lang seems very interesting, but seems still too
young for productive useage. That language probably needs 2 more years to
stabilise, but its defintely good that its so haskell related.

The other links are very interesting (especially the coding examples), but
I'll need some time to digest. -- Might come back with some questions.

Cheers Phil






-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3343777.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] H98, OOHaskell - getting started with objects in Haskell

2011-01-16 Thread gutti

On Fri, 14 Jan 2011 12:36:22 -0800 (PST)
"Wolfgang Jeltsch-2 [via Haskell]"
 wrote:

> Is this really ideal for OO? I thought that in a cellular automaton,
> all cells have to change synchronously. In addition, cells have to
> access the old states of their neighbours to compute their new
> states. So you would have to heavily synchronize the objects.
> 
> In this light, I’d say that the distributed OO approach isn’t very
> practical. A global control of the whole system might be better.
> 
> Note that I’m by no way an expert in cellular automata. I’m just
> thinking of the game of life. :-) 
> 
> Best wishes,
> Wolfgang

Hi Wolfgang, 

I don't yet have experience with cellular automata either. What u say
seems plausible, but then the life game might have been coded that way,
because most OO language don't offer concurrent objects and the
distributed OO approach (seems to be a very recent concept). 

Looking at life u probably could save time, if u only would evaluate
code on cells, where the neighbors have changed status. So rather than
triggering them all centrally and each checks its neighbours, we could
use the concept:

- let the active ones trigger the neighbours & so pass on activity
  
  
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
> __
> View message @
> http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3341886.html
> 
> To unsubscribe from H98, OOHaskell - getting started with objects in
> Haskell, visit
> http://haskell.1045720.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3338991&code=cGhpbGlwcC5ndXR0ZW5iZXJnQGdteC5uZXR8MzMzODk5MXwxNDUxNzE5MDIw

-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3343767.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] H98, OOHaskell - getting started with objects in Haskell

2011-01-13 Thread gutti

Hi, 

thanks for all Your answers (and again I'm amazed how active and good this
forum is).
 
I expected OOHaskell to be on the somewhat "extended" side, but I didn't
expect it to be so uncommon. 
This very strong and clear feedback is indeed very valuable.

I think I see the complexities of OO-programming in larger programs
(unforeseen interactions), but I'm still doubtfull, that functional
programming can equally adress all tasks equally efficient. 

I'm especially interestes in engineering calculation tasks where cellular
automata could be used. In that case all u have to do is to give the class
the right properties and that "let it grow". 

Such a localised intelligence approach seems an ideal OO - task. I don't
know whether something functional could achieve the same. 

Sounds like a nice challenge. -- I'll chew on a small example. 

Cheers Phil
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3340604.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] H98, OOHaskell - getting started with objects in Haskell

2011-01-12 Thread gutti

Hi, 

I wanted to check whether Haskell offers reasonably easy object oriented
programming -- I already had a look into "Haskell's overlooked object
system" und "A Gentle Introduction to Haskell 98" [H98] 

There are a few things where I could use advice with:

1. OOHaskell doesn't seem to be available in the HackageDB (cabal) -- so how
do I install it especially on Debian ?

2. is OOHaskell the right way to go - is it standardised (H98) or is it
extension and is it widely used and recommended  ?

3. Haskell 98 offers datatypes and some sort of monadic classes -- is it
possible to build simple objects without OOHaskell ?   

4. When I want object properties to change, when should I use IORef when
STRef ? 

Thanks in advance, 

Phil

-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/H98-OOHaskell-getting-started-with-objects-in-Haskell-tp3338991p3338991.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] 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, 

Cheers Phil 
 
 Code ##

import Numeric.LinearAlgebra
import Graphics.Plot

matrix1:: Matrix Double 
matrix1 = fromLists [[1,2],[3,4],[5,6]]

matrix2:: Matrix Double
matrix2 = fromLists [[-1,2],[-3,4],[5,-6]]

funct:: Double -> Double -> Double
funct = \a1 a2 -> if a2>=0 then a1 else 0

matrixfunction:: (Double -> Double -> Double) -> Matrix Double -> Matrix
Double -> Matrix Double
matrixfunction f x y = liftMatrix2 (zipVectorWith f ) x y 

matrix3:: Matrix Double 
-- matrix3 :: (Double -> Double -> Double) -> Matrix Double -> Matrix Double
-> Matrix Double
matrix3 = matrixfunction funct matrix1 matrix2
disp = putStr . disps 2
  
main = do 

  disp matrix1
  disp matrix3

-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3318891.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] 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 (zipVectorWith f) x y 

how can / do I have to define f in a seperate line a way, that it works and
gives the same result ?

Cheers Phil
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3318471.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] 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 lines I tried to get ur original line
running, but didn't know how to specify f

## Code 

import Numeric.LinearAlgebra
import Graphics.Plot

matrix1 = fromLists [[0 .. 5],[30 .. 35],[50 .. 55]]
matrix2 = fromLists [[-1,2],[-3,4],[5,-6]]

-- matrix1 = buildMatrix 3 4 ( (r,c) -> fromIntegral r * fromIntegral c)
(3><4)
-- posPart v  =  mapVector (\a -> if a>=0 then a else 0) v 

-- function2map a1 a2 = (\a1 a2 -> if a1>=0 then a2/a1 else a1/a2)
matrixfunction x y = liftMatrix2 (zipVectorWith(\a1 a2 -> if a2>=0 then a1
else 0)) x y 

matrix3 = matrixfunction matrix1 matrix2

disp = putStr . disps 2
  
main = do 

  disp matrix1
  disp matrix2
--  disp matrix3
  mesh matrix1


#


question 2: - the compiler comes up with some weired data type problem --
ghci has no problem this line :

matrixTest_Fail.hs:5:10:
Ambiguous type variable `t' in the constraints:
  `Element t'
arising from a use of `fromLists' at matrixTest_Fail.hs:5:10-38
  `Num t' arising from the literal `1' at matrixTest_Fail.hs:5:22
Possible cause: the monomorphism restriction applied to the following:
  matrix2 :: Matrix t (bound at matrixTest_Fail.hs:5:0)
Probable fix: give these definition(s) an explicit type signature
  or use -XNoMonomorphismRestriction
 
## Code #

import Numeric.LinearAlgebra
import Graphics.Plot

matrix1 = fromLists [[1,2],[3,4],[5,6]]
matrix2 = fromLists [[1,2],[3,4],[5,6]]

disp = putStr . disps 2

main = do 

  disp matrix1

#
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3315761.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] 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
embrace the haskell syntax. 

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 - what is input and what
is output and which way a I supposed to read it ? -- x,y,polynom ? and when
would I use double -> double => double

Is there by the way the possibility in haskell to create functions with
several outputs - ala Matlab function declation:

function [N,k] = histogram(v,n)

Hope I'm not asking too basic questions here, so feel free to point me to
the right tutorial.

Cheers Phil
 

-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3314252.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] 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 matrix thing as well,
but that might take a bit.

Its very good to hear that HMatrix develpment is going on and there are
plans to implement more of Matlabs syntax. 

I see the point, that its probably not the "cleanest" way (bool to 0 & 1)
but its damn convinient (laziness at its best). 

Maybe there could be a haskell way to implement the "lazy" matlab matrix and
vector operation syntax (like explicit function for bool 2 num)

Cheers Phil   



 Code

import Numeric.LinearAlgebra
import Graphics.Plot

time = 101 |> [0, 0.1 .. 100 :: Double];

vector1 = sin(time); 
vector2 = vector1*0.9;
 
posPart:: Vector Double -> Vector Double
posPart v  =  mapVector (\a -> if a>=0 then a else 0) v 

v3:: Vector Double -> Vector Double -> Vector Double
v3 v1 v2 = zipVectorWith(\a1 a2 -> if a1>=0 then a2/a1 else a1/a2) v1 v2

main = do  

  
  -- print(v3)
mplot [v3]
mplot [posPart vector1]


### Compile error
   
Couldn't match expected type `Vector Double'
   against inferred type `Vector Double
  -> Vector Double
  -> Vector Double'
In the expression: v3
In the first argument of `mplot', namely `[v3]'
In a stmt of a 'do' expression: mplot [v3]



-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3314171.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] 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 ?  (I haven't seen bol operations or mapping
functions into vectors, arrays
in the HMatrix.pdf).

. -- Many thanks in advance Phil



-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Matlab-Style-Logic-Operations-ala-V1-V2-0-on-Vectors-and-Matrices-with-HMatrix-tp3312601p3312601.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] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-20 Thread gutti

Hi Henk-Jan, 

thanks for the advice - using hmatrix already worked, but only with simple
matrices. I'll check the dependencies thanks. 

Hi Jason, 

thanks a lot for the response. Looks like I found a like minded soul. These
links indeed sound very relevent for me. 

Thanks and see u around,  

Philipp

-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Haskell-on-Debian-gcc-compilation-problem-with-cabal-installed-libs-like-hmatrix-etc-tp3311396p3312494.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] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread gutti

Hi Jason, 

many,many thanks - it works. -- u saved the day 

Haskell rather seems like a steeper slope to be honest,
but I find the whole language concept very fascinating.

What I can't imagine yet, how to address typical oo-problems especially
when its "not allowed" to update and change variables ...

Cheers Phil
-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Haskell-on-Debian-gcc-compilation-problem-with-cabal-installed-libs-like-hmatrix-etc-tp3311396p3311494.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] Haskell on Debian - gcc compilation problem with cabal installed libs like hmatrix, etc.

2010-12-19 Thread gutti

Hi, 

I'm very new to Haskell and this Forum, just doing my first steps ... -- Try
to use the hmatrix package for vector and matrix calculations. 

The haskell compilation works (no problem in GHCi mode), the gcc however
compilation fails with messages like: 
EFA.o: In function `r1bo_info':
(.text+0x48): undefined reference to
`hmatrixzm0zi10zi0zi0_NumericziVector_zdfNumVector1_closure'
EFA.o: In function `r1bs_info':
(.text+0x10a): undefined reference to
`hmatrixzm0zi10zi0zi0_NumericziVector_zdfFractionalVector_closure'

Obviously gcc doesn't know where the according libraries are installed. Same
problem with other packages. 

I installed the haskell base system over debian (debian squeeze), gcc
version 4.4.5. - Hmatrix and other packages are installed and build over
cabel into local folder ~/.cabal/lib

Do I need to set a system path, or change cabal options or .. ? 

Thanks in advance, Phil 



-- 
View this message in context: 
http://haskell.1045720.n5.nabble.com/Haskell-on-Debian-gcc-compilation-problem-with-cabal-installed-libs-like-hmatrix-etc-tp3311396p3311396.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