[Gretl-users] element-wise matrix operator .<

artur tarassow artur.tarassow at googlemail.com
Wed Sep 19 06:52:31 EDT 2012


2012/9/18 Allin Cottrell <cottrell at wfu.edu>

> On Tue, 18 Sep 2012, artur tarassow wrote:
>
> > according to the latest changelog it should be possible to use the
> > element-wise matrix operator ".<"
>
> What's new is ".<=" and ".>="; ".<" has been around for a
> while. But anyway...
>
> > I tried this using the latest cvs (Windows), but it does not
> > seem to work, or at least I didn't get the correct syntax. I
> > tried this example
> >
> > matrix A = { 0.6, 1 ; -0.3 , 2 }
> > if A .< 1
> >    print "Hello world"
> > endif
>
> Since ".<" is an element-wise operator, the expression
>
>   A .< 1
>
> produces a matrix result, as you see by doing
>
> <hansl>
> matrix A = { 0.6, 1 ; -0.3 , 2 }
> print A
> Test = A .< 1
> print Test
> </hansl>
>

Of course,  I should have been aware of this.

>
> Such a result cannot be coerced to a boolean value, as
> required by "if". Maybe what you want is
>
> <hansl>
> matrix A = { 0.6, 1 ; -0.3 , 2 }
> if A < 1
>      print "Hello world"
> endif
> </hansl>
>
> (This will not print "Hello world" since the test is for all
> elements less than 1.)
>

Indeed, I was looking for exactly this.

>
> Allin Cottrell
> _______________________________________________
> Gretl-users mailing list
> Gretl-users at lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>

Thanks for helping, Allin.
Best,
Artur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wfu.edu/pipermail/gretl-users/attachments/20120919/ce14b922/attachment.html 


More information about the Gretl-users mailing list