Cleaned up the code for the krls object.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402291
This commit is contained in:
Davis King 2008-06-02 02:16:03 +00:00
parent 57c2482aa0
commit e8aa99b018

View File

@ -115,40 +115,24 @@ namespace dlib
// update K_inv by computing the new one in the temp matrix (equation 3.14)
matrix<scalar_type,0,0,mem_manager_type> temp(K_inv.nr()+1, K_inv.nc()+1);
for (long r = 0; r < K_inv.nr(); ++r)
{
for (long c = 0; c < K_inv.nc(); ++c)
{
temp(r,c) = (K_inv + a*trans(a)/delta)(r,c);
}
}
// update the middle part of the matrix
set_subm(temp, get_rect(K_inv)) = K_inv + a*trans(a)/delta;
// update the right column of the matrix
set_subm(temp, 0, K_inv.nr(),K_inv.nr(),1) = -a/delta;
// update the bottom row of the matrix
set_subm(temp, K_inv.nr(), 0, 1, K_inv.nr()) = trans(-a/delta);
// update the bottom right corner of the matrix
temp(K_inv.nr(), K_inv.nc()) = 1/delta;
// update the new sides of K_inv
for (long i = 0; i < K_inv.nr(); ++i)
{
temp(K_inv.nr(),i) = -a(i)/delta;
temp(i,K_inv.nr()) = -a(i)/delta;
}
// put temp into K_inv
temp.swap(K_inv);
// Now update the P matrix (equation 3.15)
temp.set_size(P.nr()+1, P.nc()+1);
for (long r = 0; r < P.nr(); ++r)
{
for (long c = 0; c < P.nc(); ++c)
{
temp(r,c) = P(r,c);
}
}
set_subm(temp, get_rect(P)) = P;
// initialize the new sides of P
for (long i = 0; i < P.nr(); ++i)
{
temp(P.nr(),i) = 0;
temp(i,P.nc()) = 0;
}
set_rowm(temp,P.nr()) = 0;
set_colm(temp,P.nr()) = 0;
temp(P.nr(), P.nc()) = 1;
temp.swap(P);