X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fconstrained-breaking.cc;fp=lily%2Fconstrained-breaking.cc;h=714f8ce6eed9dc5332489d3513918fe03f591121;hb=3f8485925e8c879fe4c9ae86acef9804126c3b91;hp=33426c0b3f3b0ca5bcd24bd5f38263431b9013fe;hpb=9a42b64734dac35b2bdc5170bb2343f2d090a757;p=lilypond.git diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index 33426c0b3f..714f8ce6ee 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -19,20 +19,20 @@ #include "warn.hh" /* - We use the following optimal substructure. Let W(A) be our weight function. + We use the following optimal substructure. Let W (A) be our weight function. - Let A_{k,n} = (a_{k,n,1}, ... a_{k,n,k}) be the optimal set of line breaks - for k systems and n potential breakpoints. a_{k,n,k} = n (it is the end of + Let A_{k, n} = (a_{k, n,1}, ... a_{k, n, k}) be the optimal set of line breaks + for k systems and n potential breakpoints. a_{k, n, k} = n (it is the end of the piece) Then A_{k+1, m} is contructed from - min_ {k < j < m} ( W(A_{k,j} :: m) ) + min_ {k < j < m} ( W (A_{k, j} :: m) ) where by A::m we denote appending m to the list A Indices in the code: The above algorithm makes it easy to end at a point before the end of the - score (just find A_{k,m} for some m < breaks_.size () - 1). However, we must + score (just find A_{k, m} for some m < breaks_.size () - 1). However, we must add information for starting at a point after the beginning. One constructor allows the specification of a list of starting columns, start_. We then have start_.size () different solution arrays. state_[i] is the array for the @@ -48,12 +48,12 @@ . . . . . . . . where the X's mark invalid solutions (can't have more systems than - breakpoints). Note that each value is of the form a_{x,n,x}. This is because - a breakpoint of the form a_{x,n,x-1} will also be called a_{x-1,m,x-1} for + breakpoints). Note that each value is of the form a_{x, n, x}. This is because + a breakpoint of the form a_{x, n, x-1} will also be called a_{x-1, m, x-1} for some m < n. Each cell in the array stores the value of its m (ie. the ending breakpoint of the previous line) as "prev_". - For finding A_{sys, brk}, let "me" be the (sys_count,brk) cell in our + For finding A_{sys, brk}, let "me" be the (sys_count, brk) cell in our solution array (state_[start][sys * rank + brk]). Then A_{sys, brk} = A_{sys - 1, me.prev_} :: me @@ -109,6 +109,7 @@ Constrained_breaking::calc_subproblem (vsize start, vsize sys, vsize brk) return found_something; } + Column_x_positions Constrained_breaking::space_line (vsize i, vsize j) { @@ -117,7 +118,7 @@ Constrained_breaking::space_line (vsize i, vsize j) Column_x_positions col; vector line (all_.begin () + breaks_[i], - all_.begin() + breaks_[j] + 1); + all_.begin () + breaks_[j] + 1); Interval line_dims = line_dimensions_int (pscore_->layout (), i); bool last = j == breaks_.size () - 1; bool ragged = ragged_right || (last && ragged_last);