I am not sure if you mean what you say, as
B appears on both sides here. However,
assuming by Statalist convention that
you are using Stata 9.1, in Mata the
following code, given a matrix A, may help:
B = A
for(i = 1; i <= rows(A) ; i++) {
for(j = 1; j <= cols(A); j++) {
B[i,j] = A[i,i] + A[j,j] - 2 * A[i,j]
}
}
Note how close is it to your algebra.
Nick
[email protected]
U.A.QU.AP (a.k.a. AbdelRahmen)
> I have a square matrix A (100x100). I'd to create a matrix B
> such that
> B[i,j]=A[i,i]+B[j,j]-2*A[i,j]
*
* 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/