]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.21
authorfred <fred>
Sun, 24 Mar 2002 19:56:32 +0000 (19:56 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:56:32 +0000 (19:56 +0000)
lily/include/idealspacing.hh
lily/include/spring-spacer.hh
lily/spring-spacer.cc

index 068ec5836cf6defd292de401a7484e82b9a1b563..198b7e000b5f59f78df0de2b1561165dc58cd76f 100644 (file)
 /// ideal spacing between two columns
 struct Idealspacing {
 
-    /// the ideal distance
-    Real space_f_;
+  /// the ideal distance
+  Real space_f_;
 
-    /// Hooke's constant: how strong are the "springs" attached to columns
-    Real hooke_f_;
+  /// Hooke's constant: how strong are the "springs" attached to columns
+  Real hooke_f_;
 
-    /// the two columns
-    int left_i_;
-    int right_i_;
+  /// the two columns
+  int left_i_;
+  int right_i_;
     
-    void print() const;
-    void OK() const ;
-    Idealspacing();
+  Real energy_f (Real x) const;
+  void print() const;
+  void OK() const ;
+  Idealspacing();
 };
 
 
index 22c4d9634e3ac232f7bcc6a8acd62bbe2abf8c2f..f5a40b63da6db4c5f45c9fa79b3d4650cd359b59 100644 (file)
@@ -87,6 +87,7 @@ class Spring_spacer : public Line_spacer {
   Score_column* scol_l (int);
   void connect (int i,int j, Real,Real);
   Line_of_cols error_pcol_l_arr() const;
+  Real calculate_energy_f (Vector) const;
 public:
   static Line_spacer *constructor();
 
index 4a366304e6bb79f981749806d46ed0253391c85e..d1fb487b0050a6cc7ce2acf89e4f4e7c0bc41fd7 100644 (file)
@@ -283,6 +283,18 @@ Spring_spacer::make_constraints (Mixed_qp& lp) const
     }
 }
 
+
+Real
+Spring_spacer::calculate_energy_f (Vector solution) const
+{
+  Real e = 0.0;
+  for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok(); i++)  
+    {
+      e += i->energy_f(solution(i->right_i_) - solution(i->left_i_));
+    }
+  
+  return e;
+}
 void
 Spring_spacer::lower_bound_solution (Col_hpositions*positions) const
 {
@@ -294,7 +306,7 @@ Spring_spacer::lower_bound_solution (Col_hpositions*positions) const
   start.fill (0.0);
   Vector solution_vec (lp.solve (start));
 
-  positions->energy_f_ = lp.eval (solution_vec);
+  positions->energy_f_ = calculate_energy_f (solution_vec);
   positions->config = solution_vec;
   positions->satisfies_constraints_b_ = check_constraints (solution_vec);
 }
@@ -318,7 +330,7 @@ Spring_spacer::solve (Col_hpositions*positions) const
       WARN << "solution doesn't satisfy constraints.\n" ;
     }
   position_loose_cols (solution_vec); 
-  positions->energy_f_ = lp.eval (solution_vec);
+  positions->energy_f_ = calculate_energy_f (solution_vec);
   positions->config = solution_vec;
   positions->error_col_l_arr_ = error_pcol_l_arr();