Hi,
I have found the following piece of Stan code and I’m struggling to understand how the following multiplication can work.
So, here,
-
beta_delta
is arow_vector[p+q]
-
temp_delta
is also arow_vector[p+q]
and -
sigma_delta
is amatrix[N,N]
sigma_delta[i, j] = beta_delta .* temp_delta * temp_delta';
How the multiplication of some row_vector can produce a single value to fit in a matrix?
I was looking here but I couldn’t find the way.
The whole loop is below and the code comes from the “Guidelines for the Bayesian calibration of building energy models”
// diagonal elements of sigma_eta
sigma_eta = diag_matrix(rep_vector((1 / lambda_eta), N));
// off-diagonal elements of sigma_eta
for (i in 1:(N-1)) {
for (j in (i+1):N) {
temp_eta = xt[i] - xt[j];
sigma_eta[i, j] = beta_eta .* temp_eta * temp_eta'; // row_vector .* row_vector * row_vector'
sigma_eta[i, j] = exp(-sigma_eta[i, j]) / lambda_eta;
sigma_eta[j, i] = sigma_eta[i, j];
}
}
Thanks