From ecbe428bd77d3d641789af11d5fb518ea5eb7f19 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx,de>
Date: Wed, 29 Oct 2014 20:05:57 +0100
Subject: [PATCH] Fix computation of objective function in OSR if covariances
 are specified

Due to the preprocessor adding entries for all variable combination into i_var, variables contained in covariances obtained a wrong weighting. By only selecting the unique entries, this cannot happen anymore. Moreover, the computation intensity of the objective does not increase quadratically in the objective anymore.
---
 matlab/osr1.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/matlab/osr1.m b/matlab/osr1.m
index 6f2b08daf..f964871e1 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -77,6 +77,8 @@ H0 = 1e-4*eye(np);
 crit=options_.osr.tolf;
 nit=options_.osr.maxit;
 
+%extract unique entries of covariance
+i_var=unique(i_var);
 %% do initial checks
 [loss,vx,info,exit_flag]=osr_obj(t0,i_params,inv_order_var(i_var),weights(i_var,i_var));
 if info~=0
-- 
GitLab