Statalist


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

st: RE: mata: Colon operators result in matrix output to screen?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: mata: Colon operators result in matrix output to screen?
Date   Mon, 3 Dec 2007 17:38:34 -0000

Something like 

a :<= b 

is an expression, which Mata will evaluate. Perhaps you want  
an assignment on the LHS, e.g. 

c = a :<= b 

Thomas Masterson

A mata question: when I use the function affinity() [code below] I get
the results I expect, but the colon comparison operations result in the
resulting matrix being written to the Stata results window [quite a
nuisance for logging purposes]. Any thoughts why this happens?

Thanks!
Tom

real colvector affinity(real rowvector ai, real matrix aj, real
rowvector sd) {
   real matrix aij, upper, lower

   aij = J(rows(aj), 1, 0)
   upper = J(rows(aj), cols(aj), 0)
   lower = J(rows(aj), cols(aj), 0)

   upper = aj
   printf("upper has %4.0g columns and %9.0g rows\n", cols(upper),
rows(upper))

   lower = aj

   // These two operations print out the entire resulting matrix to the
screen
   upper:<= ai+sqrt(sd)
   lower:>= ai-sqrt(sd)

   upper:& lower

   aij = rowsum(upper)
   printf("aij has %4.0g columns and %9.0g rows\n", cols(aij),
rows(aij))
   return(aij)
}


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index