The code is similar as such:
Code
var GetNewestSD(var currentSD)
{
   var NewSD = currentSD;
   int i;
   for(i = 0; i < N; i++)
   {	
      mat TrackingErrorMatrix = matrix(N,1);
      mat TransposeTrackingErrorMatrix = matTrans(matrix(TrackingErrorMatrix->cols,TrackingErrorMatrix->rows), TrackingErrorMatrix); 
   }

   if (Round == 20) return NewSD;
   else return NewSD/2;
}

function run()
{
 int Round = 1;	
 var CurrentSD = 100;
 var ProposedSD = 100;

 do
 {
    CurrentSD = ProposedSD;
    printf("#\n///// Round: %i //////", Round);
    ProposedSD = GetNewestSD(CurrentSD);
    Round++;
 } while (CurrentSD > ProposedSD);
}