]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/choleski.cc
release: 1.0.1
[lilypond.git] / flower / choleski.cc
index 989a042603ec9f7baf65951435e2b5e888cd5e50..8fa18c67f52433881da099ae157871c8cc633701 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the Flower Library
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "choleski.hh"
@@ -81,7 +81,7 @@ Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs) const
 void
 Choleski_decomposition::solve (Vector &x, Vector const &rhs) const
 {
-  if (L.band_b()
+  if (band_b_
     {
       band_matrix_solve (x,rhs);
     }
@@ -145,8 +145,8 @@ Choleski_decomposition::band_matrix_decompose (Matrix const &P)
       Real d = P(i,i) - sum;
       D(i) = d;
     }
-  L.try_set_band();
-  assert (L.band_i() == P.band_i ());
+  L.set_band();
+  band_b_ = true;
 }
 
 
@@ -162,11 +162,14 @@ Choleski_decomposition::Choleski_decomposition (Matrix const & P)
 #ifdef PARANOID
   assert ((P-P.transposed()).norm ()/P.norm () < EPS);
 #endif
-  if  (P.band_b()) 
+  band_b_ = false;
+
+  int b = P.calc_band_i ();
+
+  if (b <= P.dim ()/2)  
     band_matrix_decompose (P);
   else
     full_matrix_decompose (P);
 
 #ifdef PARANOID
   assert ((original()-P).norm () / P.norm () < EPS);