From: fred Date: Sun, 24 Mar 2002 19:56:32 +0000 (+0000) Subject: lilypond-0.1.21 X-Git-Tag: release/1.5.59~3957 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=58408bb09595cb29144d150994bbedeb7c2611cf;p=lilypond.git lilypond-0.1.21 --- diff --git a/lily/include/idealspacing.hh b/lily/include/idealspacing.hh index 068ec5836c..198b7e000b 100644 --- a/lily/include/idealspacing.hh +++ b/lily/include/idealspacing.hh @@ -11,19 +11,20 @@ /// 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(); }; diff --git a/lily/include/spring-spacer.hh b/lily/include/spring-spacer.hh index 22c4d9634e..f5a40b63da 100644 --- a/lily/include/spring-spacer.hh +++ b/lily/include/spring-spacer.hh @@ -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(); diff --git a/lily/spring-spacer.cc b/lily/spring-spacer.cc index 4a366304e6..d1fb487b00 100644 --- a/lily/spring-spacer.cc +++ b/lily/spring-spacer.cc @@ -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 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();