X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Fmatrix.hh;h=a6c13f837cf81c12b465718a4417979f83b403c3;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=6706c58878a2f9d94660c93accf514d2be931eea;hpb=38d7d319eabc906e82fb42002678c6d42a23b6f7;p=lilypond.git diff --git a/flower/include/matrix.hh b/flower/include/matrix.hh index 6706c58878..a6c13f837c 100644 --- a/flower/include/matrix.hh +++ b/flower/include/matrix.hh @@ -1,9 +1,20 @@ /* - matrix.hh -- declare and implement 2d arrays + This file is part of LilyPond, the GNU music typesetter. - source file of the Flower Library + Copyright (C) 2006--2015 Joe Neeman - (c) 2006--2009 Joe Neeman + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #ifndef MATRIX_HH @@ -11,7 +22,7 @@ #include "std-vector.hh" -template > +template > class Matrix { public: @@ -21,7 +32,7 @@ public: } Matrix (vsize rows, vsize columns, T const &t) - : data_(rows * columns, t) + : data_ (rows *columns, t) { rank_ = rows; } @@ -46,15 +57,15 @@ public: data_.resize (rows * columns, t); else { - vector new_data; - new_data.resize (rows * columns, t); - vsize cur_cols = rank_ ? data_.size () / rank_: 0; - - for (vsize i = 0; i < cur_cols; i++) - for (vsize j = 0; j < rank_; j++) - new_data[i*rows + j] = data_[i*rank_ + j]; - rank_ = rows; - data_ = new_data; + vector new_data; + new_data.resize (rows * columns, t); + vsize cur_cols = rank_ ? data_.size () / rank_ : 0; + + for (vsize i = 0; i < cur_cols; i++) + for (vsize j = 0; j < rank_; j++) + new_data[i * rows + j] = data_[i * rank_ + j]; + rank_ = rows; + data_ = new_data; } }