Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How strict is -set matastrict-?


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   st: How strict is -set matastrict-?
Date   Tue, 23 May 2006 15:56:10 +0900

I noticed that in Mata you can willy-nilly change the organizational type of
a declared variable, including one that is not declared a transmorphic
matrix, and even with -mata set matastrict on- (see below).  It does lend
some flexibility, but I'm surprised that Mata lets you do it.  Is the
philosophy behind this covered in the user's manual?  I haven't run across
it.  Is it a why-not philosophy?

Also, what is the intention of having three distinct vector organizational
type definitions (vector, rowvector and colvector)?   Especially when you
can recast the variable so easily between row and column vectors after
having declared it the other?  I'm still plodding through the manual, so it
might all be in there yet.

Joseph Coveney

: mata clear

: mata set matastrict on

:
: real colvector function flipem()
> {
>     real rowvector A    // Why does this
>     A = (1, 2, 3)
>     A = A'              // allow this?
>     return(A)
> }

:
: flipem()
       1
    +-----+
  1 |  1  |
  2 |  2  |
  3 |  3  |
    +-----+

:
: real colvector function expandem()
> {
>     real scalar B       // Why does this
>     B = 2
>     B = J(B, 1, 1)      // allow this?
>     return(B)
> }

:
: expandem()
       1
    +-----+
  1 |  1  |
  2 |  1  |
    +-----+

:
: end


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index