Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: st: no room to add more double literals


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: Re: st: no room to add more double literals
Date   Tue, 18 Jan 2011 16:02:30 +0000

In response to

> 1) if I try to input a matrix with 1,1,1,1\2,2,2,2\3,3,3,3.... it hits
> the limit as well with a different error
> message, but still pretty soon to be practical.

I may be wrenching this out of context, but I note that there is no
obvious need to spell out every value of a matrix with such simple
structure. Consider

: J(1,4,(1..20)')
         1    2    3    4
     +---------------------+
   1 |   1    1    1    1  |
   2 |   2    2    2    2  |
   3 |   3    3    3    3  |
   4 |   4    4    4    4  |
   5 |   5    5    5    5  |
   6 |   6    6    6    6  |
   7 |   7    7    7    7  |
   8 |   8    8    8    8  |
   9 |   9    9    9    9  |
  10 |  10   10   10   10  |
  11 |  11   11   11   11  |
  12 |  12   12   12   12  |
  13 |  13   13   13   13  |
  14 |  14   14   14   14  |
  15 |  15   15   15   15  |
  16 |  16   16   16   16  |
  17 |  17   17   17   17  |
  18 |  18   18   18   18  |
  19 |  19   19   19   19  |
  20 |  20   20   20   20  |
     +---------------------+

which can be generalised for "any value of 20" (or 4 for that matter).
On the other hand, this behaviour of J() was not in the very first
release of Mata

SJ-8-3  pr0043  . . . . . Stata tip 67: J() now has greater replicating powers
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q3/08   SJ 8(3):450--451                                 (no commands)
        tip detailing Mata J() function recent enhancements

and so may not be old-fashioned enough for Sergiy. But there are other
ways to do it. Even the pedestrian

(1..20)',(1..20)',(1..20)',(1..20)'

looks a better solution to me. What am I missing?

Nick

On Tue, Jan 18, 2011 at 3:44 PM, Sergiy Radyakin <[email protected]> wrote:
> Hello Kit,
>
> On Tue, Jan 18, 2011 at 9:23 AM, Christopher Baum <[email protected]> wrote:
>> <>
>> On Jan 18, 2011, at 2:33 AM, Sergiy wrote:
>>
>>> What is the best way to define, e.g. 100000x1 matrix in the Mata code?
>>> (Another software is writing the Mata program, so I am not concerned
>>> about the amount of labor).
>>
>> Why not just define the matrix (or the vec() of the matrix) as a Stata variable and view it in Mata?
>
>
> Because it goes against the encapsulation paradigm ("a language
> mechanism for restricting access
> to some of the object's components" -- Wikipedia).
>
> My two other observations are:
> 1) if I try to input a matrix with 1,1,1,1\2,2,2,2\3,3,3,3.... it hits
> the limit as well with a different error
> message, but still pretty soon to be practical.
>
> 2) if I run the original commands without wrapping them into a
> function - everything works well
> (presumably because the literals are not stored, but rather executed
> right away).
>
>
> I have found by now the response of David Drukker from 2007 regarding
> the problem:
> http://www.stata.com/statalist/archive/2007-08/msg00149.html
> Since I need the program to be compatible with Stata 9, further
> updates will not be applicable.
>
> Thank you, Sergiy
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index