You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is slightly OT&and quite negligible thing, but when taking a look how Stan validate symmetric noticed that there is a possibility for small optimization in the code.
In the current fuction validate_symmetric the loop is written as
for (int i = 0; i < x.rows(); ++i) {
for (int j = 0; j < x.cols(); ++j) {
if (x(i,j) != x(j,i)) {
So it's basically checking everything twice. This can simply avoided if the code would be changed to:
for (int i = 0; i < x.rows(); ++i) {
for (int j = i; j < x.cols(); ++j) {
if (x(i,j) != x(j,i)) {
[Editor: that second for-loop can be initialized with int j = i + 1.]
The text was updated successfully, but these errors were encountered:
Function in cholesky_decompose.hpp seems to be using validate_symmetric() function which doesn't have the tolerance parameter in the equality check.
But then there is another function check_symmetric.hpp which have the 1e-8 tolerance parameter and even the loop is correct. Could this be the cause for those problems (see for example: https://groups.google.com/forum/?fromgroups#!topic/stan-users/UC3etWwSKLI) with symmetric matrices&multivariate Gaussians?
I found that the check_symmetric in src/stan/math/error_handling/matrix is coded the correct way. Instead of fixing this directly, I've created an issue to consolidate error handling. #655. I'll close this issue.
Herra Huu suggested on stan-users:
This is slightly OT&and quite negligible thing, but when taking a look how Stan validate symmetric noticed that there is a possibility for small optimization in the code.
In the current fuction validate_symmetric the loop is written as
So it's basically checking everything twice. This can simply avoided if the code would be changed to:
[Editor: that second for-loop can be initialized with
int j = i + 1
.]The text was updated successfully, but these errors were encountered: