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

Allin Cottrell cottrell at wfu.edu
Tue Sep 18 10:11:26 EDT 2012


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>

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.)

Allin Cottrell


More information about the Gretl-users mailing list