toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN Cholesky.h


From: Tom Drummond
Subject: [Toon-members] TooN Cholesky.h
Date: Wed, 08 Apr 2009 00:46:12 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/04/08 00:46:12

Modified files:
        .              : Cholesky.h 

Log message:
        replaced division with multiplication for efficiency

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/Cholesky.h?cvsroot=toon&r1=1.21&r2=1.22

Patches:
Index: Cholesky.h
===================================================================
RCS file: /cvsroot/toon/TooN/Cholesky.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Cholesky.h  7 Apr 2009 07:00:30 -0000       1.21
+++ Cholesky.h  8 Apr 2009 00:46:12 -0000       1.22
@@ -56,18 +56,19 @@
                my_cholesky=m;
                int size=my_cholesky.num_rows();
                for(int col=0; col<size; col++){
+                       Precision inv_diag=1/my_cholesky(col,col);
                        for(int row=col; row < size; row++){
                                // correct for the parts of cholesky already 
computed
                                Precision val = my_cholesky(row,col);
                                for(int col2=0; col2<col; col2++){
                                        
val-=my_cholesky(col,col2)*my_cholesky(row,col2)*my_cholesky(col2,col2);
                                }
-                               if(row>col){
-                                       // and divide my the diagonal element
-                                       
my_cholesky(row,col)=val/my_cholesky(col,col);
-                               } else {
-                                       // don't divide for the diagonal element
+                               if(row==col){
+                                       // this is the diagonal element so 
don't divide
                                        my_cholesky(row,col)=val;
+                               } else {
+                                       // divide my the diagonal element for 
all others
+                                       my_cholesky(row,col)=val*inv_diag;
                                }
                        }
                }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]