Bookmark and Share

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

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

st: Mata pointers for three dimensional matrices

From   Garrett Harmon <>
Subject   st: Mata pointers for three dimensional matrices
Date   Wed, 19 Feb 2014 11:37:36 -0500


In order to create a three dimensional matrix, I have a vector of
pointers that point to a working matrix, and I need each pointer to
store a different state of that matrix. However, since they are
pointers, they just point to the last transformation done to the
working matrix. Here's a simple example:

for (a=1; a <= 2; a++)
  for (i=1; i<=5; i++)

I want *pointers[1,1] to equal [1 1 1 1 1] and *pointers[1,2] to equal
[2 2 2 2 2], but after the loop ends they both point to [2 2 2 2 2]
which is the final state of the calculation matrix. Any thoughts on
how I should be doing it differently?

*   For searches and help try:

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