File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,19 +124,17 @@ function duplication_matrix(nobs)
124124 return D
125125end
126126
127- function elimination_matrix (nobs)
128- nobs = Int (nobs)
129- n1 = Int (nobs * (nobs + 1 ) * 0.5 )
130- n2 = Int (nobs^ 2 )
131- L = zeros (n1, n2)
132-
133- for j in 1 : nobs
134- for i in j: nobs
135- u = zeros (n1)
136- u[Int ((j - 1 ) * nobs + i - 0.5 * j * (j - 1 ))] = 1
137- T = zeros (nobs, nobs)
138- T[i, j] = 1
139- L += u * transpose (vec (T))
127+ # (n(n+1)/2)×n² matrix to transform a
128+ # vectorized form of a n×n symmetric matrix
129+ # into vector of its lower triangular entries,
130+ # opposite of duplication_matrix()
131+ function elimination_matrix (n:: Integer )
132+ ntri = div (n * (n + 1 ), 2 )
133+ L = zeros (ntri, n^ 2 )
134+ for j in 1 : n
135+ for i in j: n
136+ tri_ix = (j - 1 ) * n + i - div (j * (j - 1 ), 2 )
137+ L[tri_ix, i+ n* (j- 1 )] = 1
140138 end
141139 end
142140 return L
You can’t perform that action at this time.
0 commit comments