//#define PARANOID
void
-Choleski_decomposition::full_matrix_solve(Vector &out, Vector const &rhs)const
+Choleski_decomposition::full_matrix_solve (Vector &out, Vector const &rhs)const
{
int n= rhs.dim();
- assert(n == L.dim());
+ assert (n == L.dim());
Vector y;
- y.set_dim( n);
- out.set_dim(n);
+ y.set_dim (n);
+ out.set_dim (n);
// forward substitution
for (int i=0; i < n; i++) {
- Real sum(0.0);
+ Real sum (0.0);
for (int j=0; j < i; j++)
- sum += y(j) * L(i,j);
- y(i) = (rhs(i) - sum)/L(i,i);
+ sum += y (j) * L(i,j);
+ y (i) = (rhs (i) - sum)/L(i,i);
}
for (int i=0; i < n; i++)
- y(i) /= D(i);
+ y (i) /= D(i);
// backward subst
- Vector &x(out); // using input as return val.
+ Vector &x (out); // using input as return val.
for (int i=n-1; i >= 0; i--) {
- Real sum(0.0);
+ Real sum (0.0);
for (int j=i+1; j < n; j++)
- sum += L(j,i)*x(j);
- x(i) = (y(i) - sum)/L(i,i);
+ sum += L(j,i)*x (j);
+ x (i) = (y (i) - sum)/L(i,i);
}
}
void
-Choleski_decomposition::band_matrix_solve(Vector &out, Vector const &rhs)const
+Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs)const
{
int n= rhs.dim();
int b = L.band_i();
- assert(n == L.dim());
+ assert (n == L.dim());
- out.set_dim(n);
+ out.set_dim (n);
Vector y;
- y.set_dim(n);
+ y.set_dim (n);
// forward substitution
for (int i=0; i < n; i++) {
- Real sum(0.0);
+ Real sum (0.0);
for (int j= 0 >? i - b; j < i; j++)
- sum += y(j) * L(i,j);
- y(i) = (rhs(i) - sum)/L(i,i);
+ sum += y (j) * L(i,j);
+ y (i) = (rhs (i) - sum)/L(i,i);
}
for (int i=0; i < n; i++)
- y(i) /= D(i);
+ y (i) /= D(i);
// backward subst
- Vector &x(out); // using input as return val.
+ Vector &x (out); // using input as return val.
for (int i=n-1; i >= 0; i--) {
- Real sum(0.0);
+ Real sum (0.0);
for (int j=i+1; j <= i + b&&j < n ; j++)
- sum += L(j,i)*x(j);
- x(i) = (y(i) - sum)/L(i,i);
+ sum += L(j,i)*x (j);
+ x (i) = (y (i) - sum)/L(i,i);
}
}
void
-Choleski_decomposition::solve(Vector &x, Vector const &rhs)const
+Choleski_decomposition::solve (Vector &x, Vector const &rhs)const
{
if (L.band_b()) {
- band_matrix_solve(x,rhs);
+ band_matrix_solve (x,rhs);
} else
- full_matrix_solve(x,rhs);
+ full_matrix_solve (x,rhs);
}
Vector
-Choleski_decomposition::solve(Vector rhs)const
+Choleski_decomposition::solve (Vector rhs)const
{
Vector r;
- solve(r, rhs);
+ solve (r, rhs);
return r;
}
void
-Choleski_decomposition::full_matrix_decompose(Matrix const & P)
+Choleski_decomposition::full_matrix_decompose (Matrix const & P)
{
int n = P.dim();
L.unit();
for (int k= 0; k < n; k++) {
for (int j = 0; j < k; j++){
- Real sum(0.0);
+ Real sum (0.0);
for (int l=0; l < j; l++)
sum += L(k,l)*L(j,l)*D(l);
L(k,j) = (P(k,j) - sum)/D(j);
Real sum=0.0;
for (int l=0; l < k; l++)
- sum += sqr(L(k,l))*D(l);
+ sum += sqr (L(k,l))*D(l);
Real d = P(k,k) - sum;
D(k) = d;
}
}
void
-Choleski_decomposition::band_matrix_decompose(Matrix const &P)
+Choleski_decomposition::band_matrix_decompose (Matrix const &P)
{
int n = P.dim();
int b = P.band_i();
for (int i= 0; i < n; i++) {
for (int j = 0 >? i - b; j < i; j++){
- Real sum(0.0);
+ Real sum (0.0);
for (int l=0 >? i - b; l < j; l++)
sum += L(i,l)*L(j,l)*D(l);
L(i,j) = (P(i,j) - sum)/D(j);
Real sum=0.0;
for (int l=0 >? i - b; l < i; l++)
- sum += sqr(L(i,l))*D(l);
+ sum += sqr (L(i,l))*D(l);
Real d = P(i,i) - sum;
D(i) = d;
}
L.try_set_band();
- assert ( L.band_i() == P.band_i());
+ assert ( L.band_i() == P.band_i ());
}
Standard matrix algorithm.
*/
-Choleski_decomposition::Choleski_decomposition(Matrix const & P)
- : L(P.dim()), D(P.dim())
+Choleski_decomposition::Choleski_decomposition (Matrix const & P)
+ : L(P.dim()), D(P.dim ())
{
#ifdef PARANOID
- assert((P-P.transposed()).norm()/P.norm() < EPS);
+ assert ((P-P.transposed()).norm ()/P.norm () < EPS);
#endif
if (P.band_b())
- band_matrix_decompose(P);
+ band_matrix_decompose (P);
else
- full_matrix_decompose(P);
+ full_matrix_decompose (P);
#ifdef PARANOID
- assert((original()-P).norm() / P.norm() < EPS);
+ assert ((original()-P).norm () / P.norm () < EPS);
#endif
}
Choleski_decomposition::original() const
{
Matrix T(L.dim());
- T.set_diag(D);
+ T.set_diag (D);
return L*T*L.transposed();
}
Choleski_decomposition::inverse() const
{
int n=L.dim();
- Matrix invm(n);
- Vector e_i(n);
- Vector inv(n);
+ Matrix invm (n);
+ Vector e_i (n);
+ Vector inv (n);
for (int i = 0; i < n; i++) {
- e_i.set_unit(i);
- solve(inv, e_i);
+ e_i.set_unit (i);
+ solve (inv, e_i);
for (int j = 0 ; j<n; j++)
- invm(i,j) = inv(j);
+ invm (i,j) = inv (j);
}
#ifdef PARANOID
Matrix I1(n), I2(original());
I1.unit();
- assert((I1-I2*invm).norm()/I2.norm() < EPS);
+ assert ((I1-I2*invm).norm()/I2.norm () < EPS);
#endif
return invm;
if (eof())
break;
- data_unget(c);
+ data_unget (c);
}
String
{
char c = data_get();
- if (isspace(c) || eof())
+ if (isspace (c) || eof())
{
- data_unget(c);
+ data_unget (c);
break;
}
while ((c = data_get()) != '\"')
if (eof())
- error("EOF in a string");
+ error ("EOF in a string");
else
s += c;
char c = get();
if (!rawmode && c == '#') // gobble comment
{
- while ((c = get()) != '\n' && !eof())
+ while ((c = get()) != '\n' && !eof ())
;
return '\n';
}
char c;
String s;
- while ((c = data_get()) != '\n' && !eof())
+ while ((c = data_get()) != '\n' && !eof ())
s += c;
return s;
}
// eat blank lines.
while (!eof()) {
char c = data_get();
- if (!isspace(c)) {
- data_unget(c);
+ if (!isspace (c)) {
+ data_unget (c);
break;
}
}
}
void
-Diagonal_storage::set_band_size(int s)
+Diagonal_storage::set_band_size (int s)
{
- assert( s>=0);
- Full_storage f(dim(), 2*s+1);
+ assert (s>=0);
+ Full_storage f (dim(), 2*s+1);
for (int i=0; i < dim(); i++) {
int k=-s;
for ( ; k < -band_size_i(); k++)
- f.elem(i,k + s) = 0.0;
+ f.elem (i,k + s) = 0.0;
for ( ; k <= band_size_i()&& k<=s ; k++)
- f.elem(i, k + s) = band_.elem(i,k+ band_size_i());
- for( ; k <= s; k++)
- f.elem(i, k + s) =0.0;
+ f.elem (i, k + s) = band_.elem (i,k+ band_size_i());
+ for (; k <= s; k++)
+ f.elem (i, k + s) =0.0;
}
band_ = f;
any takers?
*/
void
-Diagonal_storage::insert_row(int )
+Diagonal_storage::insert_row (int)
{
- assert(false);
+ assert (false);
}
void
-Diagonal_storage::delete_row(int )
+Diagonal_storage::delete_row (int)
{
- assert(false);
+ assert (false);
}
void
-Diagonal_storage::resize(int,int)
+Diagonal_storage::resize (int,int)
{
}
void
-Diagonal_storage::resize(int)
+Diagonal_storage::resize (int)
{
}
void
-Diagonal_storage::delete_column(int )
+Diagonal_storage::delete_column (int)
{
- assert(false);
+ assert (false);
}
Diagonal_storage::~Diagonal_storage()
bool
-Diagonal_storage::band_elt_b(int i,int j)const
+Diagonal_storage::band_elt_b (int i,int j)const
{
- return abs(i-j) <= band_size_i();
+ return abs (i-j) <= band_size_i();
}
void
-Diagonal_storage::assert_valid(int i,int j )const
+Diagonal_storage::assert_valid (int i,int j)const
{
- assert( band_elt_b(i,j) );
- assert( i >=0 && j >=0 && i < dim() && j < dim());
+ assert (band_elt_b (i,j));
+ assert (i >=0 && j >=0 && i < dim() && j < dim ());
}
void
-Diagonal_storage::resize_dim(int d)
+Diagonal_storage::resize_dim (int d)
{
- Full_storage f(d, 2*band_size_i()+1);
+ Full_storage f (d, 2*band_size_i()+1);
for (int i=0; i < d && i < dim(); i++) {
for ( int k=0; k < 2*band_size_i(); k++)
- f.elem(i,k) = elem(i,k);
+ f.elem (i,k) = elem (i,k);
}
band_ = f;
bool
-Diagonal_storage::mult_ok(int i,int )const
+Diagonal_storage::mult_ok (int i,int)const
{
return i < dim();
}
void
-Diagonal_storage::mult_next(int &i, int &j)const
+Diagonal_storage::mult_next (int &i, int &j)const
{
j++;
- if ( j < i - band_size_i() )
+ if ( j < i - band_size_i())
j = i- band_size_i();
- if ( j > i + band_size_i() || j >= dim() ) {
+ if ( j > i + band_size_i() || j >= dim ()) {
i++;
j = 0 >? i - band_size_i();
}
}
bool
-Diagonal_storage::trans_ok(int ,int j)const
+Diagonal_storage::trans_ok (int ,int j)const
{
return j < dim();
}
void
-Diagonal_storage::trans_next(int &i, int& j)const
+Diagonal_storage::trans_next (int &i, int& j)const
{
i++;
if ( i < j - band_size_i())
i = j-band_size_i();
- if ( i >= dim() || i > j + band_size_i() ) {
+ if ( i >= dim() || i > j + band_size_i ()) {
j++;
i = 0 >? j - band_size_i();
}
static Real nul_entry=0.0;
Real
-Diagonal_storage::elem(int i, int j)const
+Diagonal_storage::elem (int i, int j)const
{
- if (abs ( i-j ) > band_size_i())
+ if (abs ( i-j) > band_size_i())
return 0;
else
- return band_.elem(i, j - i +band_size_i());
+ return band_.elem (i, j - i +band_size_i());
}
Real &
-Diagonal_storage::elem(int i, int j)
+Diagonal_storage::elem (int i, int j)
{
/*
if this fails, the previous call fucked up
*/
- assert(!nul_entry);
+ assert (!nul_entry);
- if (abs ( i-j ) > band_size_i())
+ if (abs ( i-j) > band_size_i())
return nul_entry;
else
- return band_.elem(i, j - i + band_size_i());
+ return band_.elem (i, j - i + band_size_i());
}
/*
*/
bool
-Diagonal_storage::try_right_multiply(Matrix_storage*dest,
+Diagonal_storage::try_right_multiply (Matrix_storage*dest,
const Matrix_storage*right)const
{
- if ( right->name() != Diagonal_storage::static_name() )
+ if ( right->name() != Diagonal_storage::static_name ())
return false;
const Diagonal_storage* right_diag = (Diagonal_storage const*)right;
int relk = startk + band_size_i() -i;
Real sum =0.0;
for ( int k = startk; k <= stopk; k++)
- sum += band_.elem(i, relk++) * right_diag->elem(k, j);
- dest->elem(i, j) = sum;
+ sum += band_.elem (i, relk++) * right_diag->elem (k, j);
+ dest->elem (i, j) = sum;
}
}
IMPLEMENT_IS_TYPE_B1(Diagonal_storage, Matrix_storage);
-Diagonal_storage::Diagonal_storage(Matrix_storage*stor_l, int band_i)
+Diagonal_storage::Diagonal_storage (Matrix_storage*stor_l, int band_i)
{
- set_band_size(band_i);
- resize_dim(stor_l->dim());
+ set_band_size (band_i);
+ resize_dim (stor_l->dim());
- for ( int i=0,j=0; mult_ok(i,j); mult_next(i,j))
- band_.elem(i, j + band_i -i ) = stor_l->elem(i,j);
+ for ( int i=0,j=0; mult_ok (i,j); mult_next (i,j))
+ band_.elem (i, j + band_i -i) = stor_l->elem (i,j);
}
void
/**
Should not copy deps automatically
*/
-Directed_graph_node::Directed_graph_node(Directed_graph_node const&)
+Directed_graph_node::Directed_graph_node (Directed_graph_node const&)
{
}
void
-Directed_graph_node::copy_edges_out(Directed_graph_node const &s)
+Directed_graph_node::copy_edges_out (Directed_graph_node const &s)
{
- for(int i=0; i < s.edge_out_l_arr_.size(); i++)
- add(s.edge_out_l_arr_[i]);
+ for (int i=0; i < s.edge_out_l_arr_.size(); i++)
+ add (s.edge_out_l_arr_[i]);
}
void
{
#ifndef NDEBUG
for (int i=0; i < edge_out_l_arr_.size(); i++) {
- assert(edge_out_l_arr_[i]->
- edge_in_l_arr_.find_l(this));
+ assert (edge_out_l_arr_[i]->
+ edge_in_l_arr_.find_l (this));
}
for (int i=0; i < edge_in_l_arr_.size(); i++)
- assert(edge_in_l_arr_[i]->contains_b( this));
+ assert (edge_in_l_arr_[i]->contains_b (this));
#endif
}
bool
-Directed_graph_node::contains_b(const Directed_graph_node *d)const
+Directed_graph_node::contains_b (const Directed_graph_node *d)const
{
- return edge_out_l_arr_.find_l((Directed_graph_node*)d);
+ return edge_out_l_arr_.find_l ((Directed_graph_node*)d);
}
void
-Directed_graph_node::remove_edge_out_idx(int i)
+Directed_graph_node::remove_edge_out_idx (int i)
{
PARANOID_OK();
- Directed_graph_node * d_l = edge_out_l_arr_.get(i);
+ Directed_graph_node * d_l = edge_out_l_arr_.get (i);
- int j = d_l->edge_in_l_arr_.find_i(this);
- assert(j>=0);
- d_l->edge_in_l_arr_.unordered_del(j);
+ int j = d_l->edge_in_l_arr_.find_i (this);
+ assert (j>=0);
+ d_l->edge_in_l_arr_.unordered_del (j);
PARANOID_OK();
}
void
-Directed_graph_node::remove_edge_in(Directed_graph_node *d_l)
+Directed_graph_node::remove_edge_in (Directed_graph_node *d_l)
{
PARANOID_OK();
- d_l->remove_edge_out(this);
+ d_l->remove_edge_out (this);
PARANOID_OK();
}
Directed_graph_node::remove_edge_out (Directed_graph_node *d_l)
{
PARANOID_OK();
- for (int i=0; i < edge_out_l_arr_.size(); ) {
+ for (int i=0; i < edge_out_l_arr_.size();) {
if (edge_out_l_arr_[i]== d_l)
- remove_edge_out_idx(i);
+ remove_edge_out_idx (i);
else
i++;
}
bool
Directed_graph_node::linked_b()const
{
- return edge_out_l_arr_.size() || edge_in_l_arr_.size();
+ return edge_out_l_arr_.size() || edge_in_l_arr_.size ();
}
void
Directed_graph_node::junk_links()
{
- edge_in_l_arr_.set_size(0);
- edge_out_l_arr_.set_size(0);
+ edge_in_l_arr_.set_size (0);
+ edge_out_l_arr_.set_size (0);
}
PARANOID_OK();
Link_array<Directed_graph_node> t = edge_out_l_arr_;
- t.concat(edge_in_l_arr_);
+ t.concat (edge_in_l_arr_);
#endif
- while ( edge_out_l_arr_.size() )
- remove_edge_out_idx(0);
+ while ( edge_out_l_arr_.size())
+ remove_edge_out_idx (0);
- while (edge_in_l_arr_.size() )
- remove_edge_in(edge_in_l_arr_[0]);
+ while (edge_in_l_arr_.size())
+ remove_edge_in (edge_in_l_arr_[0]);
#ifdef PARANOID
for (int i =0; i < t.size(); i++)
Directed_graph_node::~Directed_graph_node()
{
- assert(!linked_b());
+ assert (!linked_b());
}
void
-Directed_graph_node::add(Directed_graph_node* dep_l)
+Directed_graph_node::add (Directed_graph_node* dep_l)
{
PARANOID_OK();
if (!dep_l)
return ;
- dep_l->edge_in_l_arr_.push(this);
- edge_out_l_arr_.push(dep_l);
+ dep_l->edge_in_l_arr_.push (this);
+ edge_out_l_arr_.push (dep_l);
PARANOID_OK();
}
should use Regexp library.
*/
static String
-strip_pretty(String pretty_str)
+strip_pretty (String pretty_str)
{
- int i = pretty_str.index_i('(');
+ int i = pretty_str.index_i ('(');
if (i>=0)
- pretty_str = pretty_str.left_str(i);
+ pretty_str = pretty_str.left_str (i);
- int l = pretty_str.index_last_i(' '); // strip until last ' '
+ int l = pretty_str.index_last_i (' '); // strip until last ' '
if (l>=0)
- pretty_str = pretty_str.nomid_str(0,l+1);
+ pretty_str = pretty_str.nomid_str (0,l+1);
return pretty_str;
}
static String
-strip_member(String pret)
+strip_member (String pret)
{
- int l=pret.index_last_i(':')-1;
+ int l=pret.index_last_i (':')-1;
if (l>=0)
- pret = pret.left_str(l );
+ pret = pret.left_str (l);
return pret;
}
Dstream&
-Dstream::identify_as(String name)
+Dstream::identify_as (String name)
{
if (!os_l_)
return *this;
- String mem(strip_pretty(name));
- String cl(strip_member(mem));
+ String mem (strip_pretty (name));
+ String cl (strip_member (mem));
String idx = cl;
- if (silent_assoc_p_->elt_b(mem))
+ if (silent_assoc_p_->elt_b (mem))
idx = mem;
- else if (silent_assoc_p_->elt_b(cl))
+ else if (silent_assoc_p_->elt_b (cl))
idx = cl;
else {
(*silent_assoc_p_)[idx] = false;
}
bool
-Dstream::silence(String s)
+Dstream::silence (String s)
{
- if (!silent_assoc_p_->elt_b(s))
+ if (!silent_assoc_p_->elt_b (s))
return false;
return (*silent_assoc_p_)[s];
}
Dstream &
Dstream::operator<<(String s)
{
- output(s);
+ output (s);
return *this;
}
Dstream &
Dstream::operator<<(void const *v_l)
{
- output(String_convert::pointer_str(v_l));
+ output (String_convert::pointer_str (v_l));
return *this;
}
Dstream &
Dstream::operator<<(char const *ch_l)
{
- output(ch_l);
+ output (ch_l);
return *this;
}
void
-Dstream::output(String s)
+Dstream::output (String s)
{
if (local_silence_b_|| !os_l_)
return ;
for (char const *cp = s ; *cp; cp++)
- switch(*cp) {
+ switch (*cp) {
case '{':
case '[':
case '(': indent_level_i_ += INDTAB;
}
-Dstream::Dstream(ostream *r, char const * cfg_nm )
+Dstream::Dstream (ostream *r, char const * cfg_nm)
{
os_l_ = r;
silent_assoc_p_ = new Assoc<String,bool>;
char const * fn =cfg_nm ? cfg_nm : ".dstreamrc";
{
- ifstream ifs(fn); // can't open
+ ifstream ifs (fn); // can't open
if (!ifs)
return;
}
- Text_db cfg(fn);
+ Text_db cfg (fn);
while (! cfg.eof()){
- Text_record r( cfg++);
+ Text_record r (cfg++);
if (r.size() != 2) {
- r.message("not enough fields in Dstream init.");
+ r.message ("not enough fields in Dstream init.");
continue;
}
- (*silent_assoc_p_)[r[0]] = (bool)(int)(Scalar(r[1]));
+ (*silent_assoc_p_)[r[0]] = (bool)(int)(Scalar (r[1]));
}
}
Dstream::~Dstream()
{
delete silent_assoc_p_;
- assert(!indent_level_i_) ;
+ assert (!indent_level_i_) ;
}
void
Dstream::clear_silence()
{
- for (Assoc_iter<String, bool> i(*silent_assoc_p_); i.ok(); i++) {
+ for (Assoc_iter<String, bool> i (*silent_assoc_p_); i.ok(); i++) {
i.val() = 0;
}
}
flower_version_sz()
{
static char v[1024];
- sprintf(v, s, build);
+ sprintf (v, s, build);
return v;
}
void
Full_storage::operator=(Full_storage const &fs)
{
- resize(fs.height_i_, fs.width_i_);
+ resize (fs.height_i_, fs.width_i_);
OK();
fs.OK();
for (int i=0; i<height_i_; i++)
{
#ifndef NDEBUG
- assert(max_height_i_ >= height_i_ && max_width_i_ >= width_i_);
- assert(height_i_ >= 0 && width_i_ >= 0);
- assert(els_p_p_||!max_height_i_);
+ assert (max_height_i_ >= height_i_ && max_width_i_ >= width_i_);
+ assert (height_i_ >= 0 && width_i_ >= 0);
+ assert (els_p_p_||!max_height_i_);
#endif
}
void
-Full_storage::resize(int rows, int cols)
+Full_storage::resize (int rows, int cols)
{
OK();
- resize_cols(rows);
- resize_rows(cols);
+ resize_cols (rows);
+ resize_rows (cols);
}
bool
-Full_storage::mult_ok(int i, int ) const
+Full_storage::mult_ok (int i, int) const
{
return i < height_i_;
}
bool
-Full_storage::trans_ok(int , int j) const
+Full_storage::trans_ok (int , int j) const
{
return j < width_i_;
}
void
-Full_storage::trans_next(int &i, int &j) const
+Full_storage::trans_next (int &i, int &j) const
{
- assert(trans_ok(i,j));
+ assert (trans_ok (i,j));
i++;
if (i >= height_i_) {
i=0;
void
-Full_storage::mult_next(int &i, int &j) const
+Full_storage::mult_next (int &i, int &j) const
{
- assert(mult_ok(i,j));
+ assert (mult_ok (i,j));
j++;
if (j >= width_i_) {
j=0;
void
-Full_storage::delete_column(int k)
+Full_storage::delete_column (int k)
{
- assert(0 <= k &&k<width_i_);
+ assert (0 <= k &&k<width_i_);
for (int i=0; i< height_i_ ; i++)
for (int j=k+1; j <width_i_; j++)
els_p_p_[i][j-1]=els_p_p_[i][j];
void
-Full_storage::delete_row(int k)
+Full_storage::delete_row (int k)
{
- assert(0 <= k &&k<height_i_);
+ assert (0 <= k &&k<height_i_);
for (int i=k+1; i < height_i_ ; i++)
for (int j=0; j < width_i_; j++)
els_p_p_[i-1][j]=els_p_p_[i][j];
void
-Full_storage::insert_row(int k)
+Full_storage::insert_row (int k)
{
- assert(0 <= k&& k <=height_i_);
- resize_cols(height_i_+1);
+ assert (0 <= k&& k <=height_i_);
+ resize_cols (height_i_+1);
for (int i=height_i_-1; i > k ; i--)
for (int j=0; j <width_i_; j++)
els_p_p_[i][j]=els_p_p_[i-1][j];
}
bool
-Full_storage::try_right_multiply(Matrix_storage * dest, Matrix_storage const * right)const
+Full_storage::try_right_multiply (Matrix_storage * dest, Matrix_storage const * right)const
{
- if (dest->name() != Full_storage::static_name() ||
- right->name() != Full_storage::static_name())
+ if (dest->name() != Full_storage::static_name () ||
+ right->name() != Full_storage::static_name ())
return false;
Full_storage *d_l = (Full_storage*)dest;
Full_storage *r_l = (Full_storage*)right;
- d_l->set_size(height_i_, r_l->width_i_);
+ d_l->set_size (height_i_, r_l->width_i_);
for (int i=0; i < d_l->height_i_; i++)
for (int j = 0; j < d_l->width_i_; j++) {
- Real &r(d_l->els_p_p_[i][j]);
+ Real &r (d_l->els_p_p_[i][j]);
r=0.0;
for (int k = 0; k < width_i_; k++)
r += els_p_p_[i][k] * r_l->els_p_p_[k][j];
}
IMPLEMENT_IS_TYPE_B1(Full_storage,Matrix_storage);
void
-Full_storage::resize_cols(int newh)
+Full_storage::resize_cols (int newh)
{
if (newh <= max_height_i_) {
height_i_=newh;
-Full_storage::Full_storage(Matrix_storage*m)
+Full_storage::Full_storage (Matrix_storage*m)
{
- set_size(m->rows(), m->cols());
+ set_size (m->rows(), m->cols ());
if ( !m->is_type_b ( Full_storage::static_name()))
for (int i=0; i<height_i_; i++)
for (int j=0; j<width_i_; j++)
els_p_p_[i][j]=0.0;
- for (int i,j=0; m->mult_ok(i,j); m->mult_next(i,j))
- els_p_p_[i][j] = m->elem(i,j);
+ for (int i,j=0; m->mult_ok (i,j); m->mult_next (i,j))
+ els_p_p_[i][j] = m->elem (i,j);
}
void
-Full_storage::resize_rows(int neww)
+Full_storage::resize_rows (int neww)
{
if (neww <= max_width_i_) {
width_i_=neww;
int idx_;
Array<T> &arr_;
public:
- ACursor(ACursor const& s)
+ ACursor (ACursor const& s)
:arr_(s.arr_)
{
idx_ = s.idx_;
}
- ACursor(Array<T> const &arr)
+ ACursor (Array<T> const &arr)
arr_((Array<T>&)arr)
{
idx_ =0;
idx_ ++;
return t;
}
- bool ok() { return idx_ >=0 && idx_ < arr_.size(); }
+ bool ok() { return idx_ >=0 && idx_ < arr_.size (); }
};
class PACursor : public ACursor<T*>
{
public:
- PACursor(Link_array<T> l)
- : ACursor(l)
+ PACursor (Link_array<T> l)
+ : ACursor (l)
{
}
T* ptr() { return arr_[idx_]; }
int i;
Assoc<K,V> &assoc_;
/// we don't want to be bothered by const correctness
- Assoc_iter(const Assoc<K,V> &a) :
+ Assoc_iter (const Assoc<K,V> &a) :
assoc_((Assoc<K,V> &)a)
{
- i= next(0);
+ i= next (0);
}
- int next(int j) {
+ int next (int j) {
while (j < assoc_.arr.size() && assoc_.arr[j].free)
j++;
return j;
return i < assoc_.arr.size();
}
void OK()const {
- assert(!ok() || !assoc_.arr[i].free);
+ assert (!ok() || !assoc_.arr[i].free);
}
- void operator++(int) { i++; i = next(i); }
+ void operator++(int) { i++; i = next (i); }
K key() { return assoc_.arr[i].key; }
V &val() { return assoc_.arr[i].val; }
};
/* ************** */
- int find(K key) const {
+ int find (K key) const {
for (int i = 0; i < arr.size(); i++) {
if (!arr[i].free && key == arr[i].key)
return i;
}
return -1;
}
- int find_creat(K key) {
+ int find_creat (K key) {
int free = -1;
for (int i = 0; i < arr.size(); i++) {
if (key == arr[i].key) {
return i;
- } else if (arr[i].free ) {
+ } else if (arr[i].free) {
free = i;
}
}
Assoc_ent_<K,V> ae;
ae.free = false;
ae.key = key;
- arr.push(ae);
+ arr.push (ae);
return arr.size() -1;
}
public:
- bool elt_b(K key) const {
- return find(key) >= 0;
+ bool elt_b (K key) const {
+ return find (key) >= 0;
}
- void del(K key) {
- assert(elt_b(key));
- int i= find(key);
+ void del (K key) {
+ assert (elt_b (key));
+ int i= find (key);
arr[i].free = true;
}
void
- add(K key, V val) {
- int i = find_creat(key);
+ add (K key, V val) {
+ int i = find_creat (key);
arr[i].val = val;
}
- V& elem(K key) {
- return arr[find_creat(key)].val;
+ V& elem (K key) {
+ return arr[find_creat (key)].val;
}
V& operator[](K key) {
- return elem(key);
+ return elem (key);
}
V const & operator[](K key) const {
- return elem(key);
+ return elem (key);
}
- V const & elem(K key) const {
- assert(elt_b(key));
- return arr[find(key)].val;
+ V const & elem (K key) const {
+ assert (elt_b (key));
+ return arr[find (key)].val;
}
};
#P# is split into
- LD transpose(L)
+ LD transpose (L)
*/
struct Choleski_decomposition {
P needs to be symmetric positive definite
*/
- Choleski_decomposition(Matrix const &P);
+ Choleski_decomposition (Matrix const &P);
/**
solve Px = rhs
*/
- Vector solve(Vector rhs) const;
+ Vector solve (Vector rhs) const;
void solve (Vector &dest, Vector const &rhs)const;
Vector operator * (Vector rhs) const { return solve (rhs); }
/**
*/
Matrix original() const;
private:
- void full_matrix_solve(Vector &,Vector const&)const;
- void band_matrix_solve(Vector &, Vector const&)const;
- void full_matrix_decompose(Matrix const & P);
- void band_matrix_decompose(Matrix const &P);
+ void full_matrix_solve (Vector &,Vector const&)const;
+ void band_matrix_solve (Vector &, Vector const&)const;
+ void full_matrix_decompose (Matrix const & P);
+ void band_matrix_decompose (Matrix const &P);
};
#endif
#ifndef COMPARE_HH
#define COMPARE_HH
-#define one_operator(type, function, op) \
+#define ONE_OPERATOR(type, function, op) \
inline bool \
operator op (type t1, type t2) {\
- return function(t1, t2) op 0;\
+ return function (t1, t2) op 0;\
}\
-#define gpp_minmax_operator(type, op, opp) \
+#define GPP_MINMAX_OPERATOR(type, op, opp) \
inline type \
-operator op(type t1, type t2)\
+operator op (type t1, type t2)\
{\
return (t1 opp t2) ? t1 : t2;\
}\
#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-#define gpp_minmax(type, prefix)\
- prefix gpp_minmax_operator(type, <?, <)\
- prefix gpp_minmax_operator(type, >?, >)
+#define GPP_MINMAX(type, prefix)\
+ prefix GPP_MINMAX_OPERATOR(type, <?, <)\
+ prefix GPP_MINMAX_OPERATOR(type, >?, >)
#else
-#define gpp_minmax(type, prefix)
+#define GPP_MINMAX(type, prefix)
#endif
/** handy notations for a signed comparison.
make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
Please fill a & in the type argument if necessary.
*/
-#define template_instantiate_compare(type, function, prefix) \
-prefix one_operator(type, function, >)\
-prefix one_operator(type, function, >=)\
-prefix one_operator(type, function, ==)\
-prefix one_operator(type, function, !=)\
-prefix one_operator(type, function, <)\
-prefix one_operator(type, function, <=)\
-gpp_minmax(type, prefix)\
-prefix inline type max(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\
-prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\
+#define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \
+prefix ONE_OPERATOR(type, function, >)\
+prefix ONE_OPERATOR(type, function, >=)\
+prefix ONE_OPERATOR(type, function, ==)\
+prefix ONE_OPERATOR(type, function, !=)\
+prefix ONE_OPERATOR(type, function, <)\
+prefix ONE_OPERATOR(type, function, <=)\
+GPP_MINMAX(type, prefix)\
+prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; }\
+prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; }\
\
prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */
-#define instantiate_compare(type, func) template_instantiate_compare(type,func, )
+#define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE(type,func,)
public:
/** create cursor, set at top. The const part isn't true, actually, #list#
surely isn't const, but I get tired of the warning messages. */
- Cursor( const List<T>& list, Link<T>* pointer = 0 );
+ Cursor (const List<T>& list, Link<T>* pointer = 0);
/**
Create an invalid cursor (pointing to nothing, associated with no list.)
*/
Cursor();
- Cursor( const Cursor<T>& cursor );
+ Cursor (const Cursor<T>& cursor);
T& thing();
/// return current T
T& operator *() { return thing(); }
operator T() { return thing(); }
- Cursor<T> operator =( const Cursor<T>& c );
+ Cursor<T> operator =( const Cursor<T>& c);
/// make cursor with #no# items back
Cursor<T> operator -( int no) const;
/// move one up.
void previous();
/// return current and move one down
- Cursor<T> operator ++( int );
+ Cursor<T> operator ++( int);
/// return current and move one up
- Cursor<T> operator --( int );
+ Cursor<T> operator --( int);
/// point to link?
bool ok()const;
cursor points to same object, cursor.next() is newly added
object.
*/
- void add( T const & thing );
+ void add (T const & thing);
/** put (copy) before me in List.
analogously to editor. ok() interpreted as at begin of
is newly inserted object.
*/
- void insert( T const & thing );
+ void insert (T const & thing);
///
void backspace();
/// access the list this came from
List<T>& list() const ;
Link<T>* pointer();
- static int compare(Cursor<T> a,Cursor<T>b) { return a-b; }
+ static int compare (Cursor<T> a,Cursor<T>b) { return a-b; }
private:
List<T>& list_;
Link<T>* pointer_;
#include "compare.hh"
-template_instantiate_compare(Cursor<T>, Cursor<T>::compare, template<class T>);
+TEMPLATE_INSTANTIATE_COMPARE(Cursor<T>, Cursor<T>::compare, template<class T>);
#include "pcursor.hh"
#include "list.hh"
// untested
template<class T>
inline
-Cursor<T>::Cursor( )
+Cursor<T>::Cursor()
: list_(*(List<T> *)0) // ugh
{
pointer_ = 0;
template<class T>
inline
-Cursor<T>::Cursor( const List<T>& list, Link<T>* pointer ) :
- list_((List<T>&) list )
+Cursor<T>::Cursor (const List<T>& list, Link<T>* pointer) :
+ list_((List<T>&) list)
{
- if ( list.size() )
+ if ( list.size())
pointer_ = pointer ? pointer : list.top_;
else
pointer_ = pointer;
template<class T>
inline
-Cursor<T>::Cursor( const Cursor<T>& cursor ) :
- list_( cursor.list_ )
+Cursor<T>::Cursor (const Cursor<T>& cursor) :
+ list_( cursor.list_)
{
pointer_ = cursor.pointer_;
}
inline T&
Cursor<T>::thing()
{
- assert( pointer_ );
+ assert (pointer_);
return pointer_->thing();
}
template<class T>
Cursor<T>
-Cursor<T>::operator =( const Cursor<T>& c )
+Cursor<T>::operator =( const Cursor<T>& c)
{
- assert( &list_ == &c.list_ );
+ assert (&list_ == &c.list_);
pointer_ = c.pointer_;
return *this;
}
template<class T>
inline void
-Cursor<T>::add( const T& th )
+Cursor<T>::add (const T& th)
{
- list_.add( th, *this );
+ list_.add (th, *this);
}
template<class T>
inline void
-Cursor<T>::insert( const T& th )
+Cursor<T>::insert (const T& th)
{
- list_.insert( th, *this );
+ list_.insert (th, *this);
}
template<class T>
inline bool
Cursor<T>::backward()const
{
- return ( pointer_ != 0 );
+ return ( pointer_ != 0);
}
template<class T>
inline bool
Cursor<T>::forward()const
{
- return ( pointer_ != 0 );
+ return ( pointer_ != 0);
}
template<class T>
inline bool
Cursor<T>::ok()const
{
- return ( pointer_ != 0 );
+ return ( pointer_ != 0);
}
template<class T>
inline void
Cursor<T>::next()
{
- assert( pointer_ );
+ assert (pointer_);
pointer_ = pointer_->next();
}
template<class T>
inline Cursor<T>
-Cursor<T>::operator ++( int )
+Cursor<T>::operator ++( int)
{
Cursor<T> r (*this);
next();
inline void
Cursor<T>::previous()
{
- assert( pointer_ );
+ assert (pointer_);
pointer_ = pointer_->previous();
}
template<class T>
inline Cursor<T>
-Cursor<T>::operator --( int )
+Cursor<T>::operator --( int)
{
Cursor<T> r (*this);
previous();
void
Cursor<T>::backspace()
{
- Cursor<T> c(*this);
- if ( c.ok() )
+ Cursor<T> c (*this);
+ if ( c.ok())
c--;
- list_.remove( *this );
+ list_.remove (*this);
}
template<class T>
void
Cursor<T>::del()
{
- Cursor<T> c(*this);
- if ( c.ok() )
+ Cursor<T> c (*this);
+ if ( c.ok())
c++;
- list_.remove( *this );
+ list_.remove (*this);
*this = c;
}
template<class T>
Cursor<T>
-Cursor<T>::operator -=( int j )
+Cursor<T>::operator -=( int j)
{
while (j--)
(*this)--;
}
template<class T>
Cursor<T>
-Cursor<T>::operator +=( int j )
+Cursor<T>::operator +=( int j)
{
while (j++)
(*this)++;
template<class T>
Cursor<T>
-Cursor<T>::operator +( int i ) const
+Cursor<T>::operator +( int i) const
{
Cursor<T> r = *this;
template<class T>
Cursor<T>
-Cursor<T>::operator -( int i ) const
+Cursor<T>::operator -( int i) const
{
Cursor<T> r = *this;
if (i<0)
int
Cursor<T>::operator-(Cursor<T> rhs) const
{
- assert(rhs.list == list);
+ assert (rhs.list == list);
int dif = 0;
// search from *this on further up (positive difference)
- Cursor<T> c(*this);
+ Cursor<T> c (*this);
while (c.ok() && c.pointer_ != rhs.pointer_) {
c--;
dif++;
dif --;
c++;
}
- assert(c.ok());
+ assert (c.ok());
gotcha:
- assert((*this - dif).pointer_ == c.pointer_);
+ assert ((*this - dif).pointer_ == c.pointer_);
return dif;
}
Text_stream::get_name;
char data_get();
- void data_unget(char c) {
- unget(c);
+ void data_unget (char c) {
+ unget (c);
}
/// read line, eat #\n#
/// gobble empty stuff before first field.
void gobble_leading_white();
- Data_file(String s) : Text_stream(s) {
+ Data_file (String s) : Text_stream (s) {
//*mlog << "(" << s << flush;
rawmode= false;
}
// *mlog << ")"<<flush;
}
- warning(String s) {
- message("warning: " + s);
+ warning (String s) {
+ message ("warning: " + s);
}
- error(String s){
- message(s);
- exit(1);
+ error (String s){
+ message (s);
+ exit (1);
}
};
#endif // DATAFILE_HH
@invariant
- Diagonal_storage(i,j) == band_(i, j-i + band_size_i())
+ Diagonal_storage (i,j) == band_(i, j-i + band_size_i())
- band_.cols() == 2 * band_size_i() + 1
+ band_.cols() == 2 * band_size_i () + 1
*/
class Diagonal_storage : public Matrix_storage {
Full_storage band_;
public:
- void set_band_size(int b);
+ void set_band_size (int b);
int band_size_i()const;
- void assert_valid(int i, int j) const;
- bool band_elt_b(int,int )const;
- void resize_dim(int);
+ void assert_valid (int i, int j) const;
+ bool band_elt_b (int,int)const;
+ void resize_dim (int);
- virtual void resize_rows(int d) { resize_dim (d); }
- virtual void resize_cols(int d) { resize_dim(d); }
+ virtual void resize_rows (int d) { resize_dim (d); }
+ virtual void resize_cols (int d) { resize_dim (d); }
virtual int dim() const;
virtual int rows() const ;
virtual int cols() const ;
- virtual void resize(int i, int j);
- virtual void resize(int i);
+ virtual void resize (int i, int j);
+ virtual void resize (int i);
- virtual Real& elem(int i,int j);
- virtual Real elem(int i, int j) const;
- Diagonal_storage(Matrix_storage* , int band_i);
+ virtual Real& elem (int i,int j);
+ virtual Real elem (int i, int j) const;
+ Diagonal_storage (Matrix_storage* , int band_i);
Diagonal_storage();
void OK() const;
- virtual void insert_row(int k);
- virtual void delete_row(int k);
- virtual void delete_column(int k);
+ virtual void insert_row (int k);
+ virtual void delete_row (int k);
+ virtual void delete_column (int k);
~Diagonal_storage();
- virtual bool mult_ok(int i, int j)const;
- virtual void mult_next(int &i, int &j) const ;
- virtual bool trans_ok(int i, int j) const;
- virtual void trans_next(int &i, int &j) const;
+ virtual bool mult_ok (int i, int j)const;
+ virtual void mult_next (int &i, int &j) const ;
+ virtual bool trans_ok (int i, int j) const;
+ virtual void trans_next (int &i, int &j) const;
DECLARE_VIRTUAL_COPY_CONS(Diagonal_storage, Matrix_storage);
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual bool try_right_multiply(Matrix_storage * dest, Matrix_storage const *)const;
+ virtual bool try_right_multiply (Matrix_storage * dest, Matrix_storage const *)const;
};
#endif // DIAGONAL_STORAGE_HH
/** remove i-th edge_out (and exactly one ref to me in the edge_out)
*/
- void remove_edge_out_idx(int i);
- void copy_edges_out(Directed_graph_node const&);
+ void remove_edge_out_idx (int i);
+ void copy_edges_out (Directed_graph_node const&);
bool linked_b() const;
void unlink();
void junk_links();
- void add(Directed_graph_node*);
- void remove_edge_in(Directed_graph_node *);
- void remove_edge_out(Directed_graph_node*);
- bool contains_b(Directed_graph_node const*) const;
+ void add (Directed_graph_node*);
+ void remove_edge_in (Directed_graph_node *);
+ void remove_edge_out (Directed_graph_node*);
+ bool contains_b (Directed_graph_node const*) const;
- Directed_graph_node(Directed_graph_node const &);
+ Directed_graph_node (Directed_graph_node const &);
void OK()const;
Directed_graph_node();
One can turn on and off specific messages using the Assoc silent.
This can be done automatically:
- #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__)
+ #define DEBUG dstream_.identify_as (__PRETTY_FUNCTION__)
DEBUG << "a message\n";
int indent_level_i_;
bool local_silence_b_;
String current_classname_str_;
- void output(String s);
+ void output (String s);
Assoc<String, bool> *silent_assoc_p_;
public:
void clear_silence();
- bool silence(String);
+ bool silence (String);
/**
if rcfile == 0, then do not read any rc file.
*/
- Dstream(ostream *r, char const * rcfile);
+ Dstream (ostream *r, char const * rcfile);
virtual ~Dstream();
- Dstream &identify_as(String s);
+ Dstream &identify_as (String s);
/** Output a string via the Dstream. This is the only output
interface. It delegates all conversion to String class. */
extern Dstream *flower_dstream;
extern bool flower_check_debug;
#ifdef NPRINT
-#define fdebug if ( 0 ) *flower_dstream
+#define fdebug if ( 0) *flower_dstream
#else
#define fdebug if (flower_check_debug) \
- flower_dstream->identify_as(__PRETTY_FUNCTION__)
+ flower_dstream->identify_as (__PRETTY_FUNCTION__)
#endif
-void set_flower_debug(Dstream&ds, bool);
+void set_flower_debug (Dstream&ds, bool);
#endif // FLOWER_DEBUG_HH
void
init() ;
- bool valid(int i, int j) const ;
+ bool valid (int i, int j) const ;
- void resize_rows(int);
- void resize_cols(int);
+ void resize_rows (int);
+ void resize_cols (int);
public:
virtual int rows() const;
virtual int cols() const ;
- virtual void resize(int i, int j);
- virtual void resize(int i);
- virtual Real& elem(int i,int j);
- virtual Real elem(int i, int j)const ;
+ virtual void resize (int i, int j);
+ virtual void resize (int i);
+ virtual Real& elem (int i,int j);
+ virtual Real elem (int i, int j)const ;
int dim()const;
- Full_storage(Matrix_storage*);
+ Full_storage (Matrix_storage*);
Full_storage();
- Full_storage(int i, int j);
- Full_storage(Full_storage const&);
- Full_storage(int i);
+ Full_storage (int i, int j);
+ Full_storage (Full_storage const&);
+ Full_storage (int i);
void OK() const;
void operator=(Full_storage const &);
- virtual void insert_row(int k);
- virtual void delete_row(int k);
- virtual void delete_column(int k);
+ virtual void insert_row (int k);
+ virtual void delete_row (int k);
+ virtual void delete_column (int k);
~Full_storage();
- virtual bool mult_ok(int i, int j)const;
- virtual void mult_next(int &i, int &j) const ;
- virtual bool trans_ok(int i, int j) const;
- virtual void trans_next(int &i, int &j) const;
+ virtual bool mult_ok (int i, int j)const;
+ virtual void mult_next (int &i, int &j) const ;
+ virtual bool trans_ok (int i, int j) const;
+ virtual void trans_next (int &i, int &j) const;
DECLARE_VIRTUAL_COPY_CONS(Full_storage,Matrix_storage);
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual bool try_right_multiply(Matrix_storage * dest, Matrix_storage const * )const;
+ virtual bool try_right_multiply (Matrix_storage * dest, Matrix_storage const *)const;
};
#endif // FULL_STORAGE_HH
height_i_=width_i_=max_height_i_=max_width_i_=0;
}
INLINE bool
-Full_storage::valid(int i, int j)const
+Full_storage::valid (int i, int j)const
{
return (i>=0 && i < height_i_)
&& (j < width_i_ && j >=0);
INLINE
-Full_storage::Full_storage(Full_storage const&s)
+Full_storage::Full_storage (Full_storage const&s)
{
init();
(*this) = s;
}
INLINE Real&
-Full_storage::elem(int i,int j)
+Full_storage::elem (int i,int j)
{
- assert(valid(i,j));
+ assert (valid (i,j));
return els_p_p_[i][j];
}
INLINE Real
-Full_storage::elem(int i, int j) const {
- assert(valid(i,j));
+Full_storage::elem (int i, int j) const {
+ assert (valid (i,j));
return els_p_p_[i][j];
}
INLINE int
Full_storage::dim()const
{
- assert (rows()==cols());
+ assert (rows()==cols ());
return rows();
}
INLINE void
-Full_storage::resize(int i)
+Full_storage::resize (int i)
{
- resize(i,i);
+ resize (i,i);
}
INLINE
-Full_storage::Full_storage(int i,int j)
+Full_storage::Full_storage (int i,int j)
{
init();
- set_size(i,j);
+ set_size (i,j);
}
INLINE
-Full_storage::Full_storage(int i)
+Full_storage::Full_storage (int i)
{
init();
- set_size(i);
+ set_size (i);
}
INLINE
refs = 0;
}
/// point to new object.
- void up(T *t, int *r) {
+ void up (T *t, int *r) {
if (!r) {
refs = new int;
*refs = 1;
}
/// POST: *refs == 1
void copy() {
- if(*refs != 1){
- T * newobj = new T(*obj );
+ if (*refs != 1){
+ T * newobj = new T(*obj);
down();
- up(newobj);
+ up (newobj);
}
}
- Handle(Handle const &src) {
- up(src.obj, src.refs);
+ Handle (Handle const &src) {
+ up (src.obj, src.refs);
}
- Handle(T & o) {
+ Handle (T & o) {
up (&o);
}
void operator=(Handle const& src) {
if (this == &src)
return;
down();
- up(src.o, src.refs);
+ up (src.o, src.refs);
}
operator T const &() {
return *obj;
(it does save quite some disk space, though)
*/
-#define iterator(set) typeof((set).top())
-#define iterator_bot(set) typeof((set).bottom())
+#define iterator(set) typeof ((set).top())
+#define iterator_bot(set) typeof ((set).bottom())
-#define iter(init, var) typeof(init) var(init)
+#define iter(init, var) typeof (init) var (init)
// should use top()
-#define iter_top(set,var) iterator(set) var(set)
-#define iter_bot(set,var) iterator(set) var(set.bottom())
+#define iter_top(set,var) iterator (set) var (set)
+#define iter_bot(set,var) iterator (set) var (set.bottom())
#endif // ITERATE_HH
char const * longname;
char shortname;
- void printon(ostream &errorout)const ;
+ void printon (ostream &errorout)const ;
};
bool ok() const;
/// report an error and abort
- void report(Errorcod c);
+ void report (Errorcod c);
/// return an integer (with err. detect)
if #os# is null, then do not report nor abort, just set #error#
*/
- void seterror(ostream *os);
+ void seterror (ostream *os);
/// construct: pass arguments and option info.
- Getopt_long(int c, char **v, Long_option_init *lo);
+ Getopt_long (int c, char **v, Long_option_init *lo);
/** get the next option.
@return pointer to next option found.
#include "fproto.hh"
#include "config.hh"
-char* strnlwr( char* start_l ,int n);
-char* strnupr( char* start_l, int n);
+char* strnlwr (char* start_l ,int n);
+char* strnupr (char* start_l, int n);
#if !HAVE_MEMMEM // GNU extension.
-char *memmem(Byte const * haystack, int haystack_len,
+char *memmem (Byte const * haystack, int haystack_len,
Byte const *needle, int needle_len);
#endif HAVE_MEMMEM
#if !HAVE_SNPRINTF // GNU extension.
int snprintf (char *str, size_t n,
- char const *format, ... );
+ char const *format, ...);
#endif
-Byte *memrchr(Byte const * p, int n, char c);
-Byte *strrev( Byte* byte_l, int length_i );
+Byte *memrchr (Byte const * p, int n, char c);
+Byte *strrev (Byte* byte_l, int length_i);
#endif // LIBC_EXTENSION_HH
{
// friend class Cursor<T>;
public:
- Link( T const & thing );
+ Link (T const & thing);
Link<T>* previous();
Link<T>* next();
/// put new Link item after me in list
- void add( T const & thing );
+ void add (T const & thing);
/// put new Link item before me in list
- void insert( T const & thing );
- void remove(List<T> &l);
+ void insert (T const & thing);
+ void remove (List<T> &l);
T& thing();
void OK() const;
private:
- Link( Link<T>* previous, Link<T>* next, T const & thing );
+ Link (Link<T>* previous, Link<T>* next, T const & thing);
T thing_;
Link<T>* previous_;
{
#ifndef NDEBUG
if (previous_) {
- assert(previous_->next_ == this);
+ assert (previous_->next_ == this);
}
if (next_) {
- assert(next_->previous_ == this);
+ assert (next_->previous_ == this);
}
#endif
}
template<class T>
inline
-Link<T>::Link( const T& thing ) :
- thing_( thing )
+Link<T>::Link (const T& thing) :
+ thing_( thing)
{
previous_ = next_ = 0;
}
template<class T>
inline
-Link<T>::Link( Link<T>* previous, Link<T>* next, const T& thing ) :
- thing_( thing )
+Link<T>::Link (Link<T>* previous, Link<T>* next, const T& thing) :
+ thing_( thing)
{
previous_ = previous;
next_ = next;
template<class T>
inline
void
-Link<T>::add( const T& thing )
+Link<T>::add (const T& thing)
{
- Link<T>* l = new Link<T>( this, next_, thing );
- if ( next_ )
+ Link<T>* l = new Link<T>( this, next_, thing);
+ if ( next_)
next_->previous_ = l;
next_ = l;
}
template<class T>
inline void
-Link<T>::insert( const T& thing )
+Link<T>::insert (const T& thing)
{
- // Link<T>* l = new Link<T>( next_, this, thing );
+ // Link<T>* l = new Link<T>( next_, this, thing);
// bugfix hwn 16/9/96
- Link<T>* l = new Link<T>( previous_, this, thing );
- if ( previous_ )
+ Link<T>* l = new Link<T>( previous_, this, thing);
+ if ( previous_)
previous_->next_ = l;
previous_ = l;
}
*/
template<class T>
inline void
-Link<T>::remove(List<T> &l)
+Link<T>::remove (List<T> &l)
{
- if ( previous_ )
+ if ( previous_)
previous_->next_ = next_;
else
l.top_ = next_;
- if ( next_ )
+ if ( next_)
next_->previous_ = previous_;
else
l.bottom_ = previous_;
{\bf note:}
retrieving "invalid" cursors, i.e.
- #top()/bottom()# from empty list, #find()# without success,
- results in a nonvalid Cursor ( #!ok()# )
+ #top()/bottom ()# from empty list, #find ()# without success,
+ results in a nonvalid Cursor ( #!ok()#)
INVARIANTEN!
class List
{
public:
- List(List const&src);
+ List (List const&src);
/// construct empty list
List();
friend class Cursor<T>;
friend class Link<T>;
- void concatenate(List<T> const &s);
+ void concatenate (List<T> const &s);
/** make *this empty.
*/
void set_empty();
- void add( T const & thing, Cursor<T> &after_me );
+ void add (T const & thing, Cursor<T> &after_me);
/// put thing before #before_me#
- void insert( T const & thing, Cursor<T> &before_me );
+ void insert (T const & thing, Cursor<T> &before_me);
/** Remove link pointed to by me. Destructor of contents called
(nop for pointers)
WARNING: do not use #me# after calling
*/
- void remove( Cursor<T> me );
+ void remove (Cursor<T> me);
/* ************** */
template<class T>
inline void
-List<T>::remove( Cursor<T> me )
+List<T>::remove (Cursor<T> me)
{
- if ( me.ok() ){
+ if ( me.ok()){
Link<T> *lp = me.pointer();
- lp->remove(*this);
+ lp->remove (*this);
delete lp;
size_--;
}
inline Cursor<T>
List<T>::top()const
{
- return Cursor<T>( *this, top_ );
+ return Cursor<T>( *this, top_);
}
inline Cursor<T>
List<T>::bottom()const
{
- return Cursor<T>( *this, bottom_ );
+ return Cursor<T>( *this, bottom_);
}
PRE
i >=0, j>=0
*/
- virtual void set_size(int rows, int cols) ;
+ virtual void set_size (int rows, int cols) ;
/**set the size to square dimen. contents lost
PRE
i>=0
*/
- virtual void set_size(int i) ;
+ virtual void set_size (int i) ;
/**set the size to i.
keep contents. If enlarged contents unspecified
i>=0, j>=0
*/
- virtual void resize(int rows, int cols ) = 0;
+ virtual void resize (int rows, int cols) = 0;
/**
set the size to square dimen. contents kept
PRE
i>=0
*/
- virtual void resize(int i) = 0;
+ virtual void resize (int i) = 0;
/**
in the 0-part of a sparse matrix.
*/
- virtual Real& elem(int i,int j) = 0;
+ virtual Real& elem (int i,int j) = 0;
/// access a element, no modify
- virtual Real elem(int i, int j) const = 0;
+ virtual Real elem (int i, int j) const = 0;
- virtual Array<Real> row(int i) const ;
- virtual Array<Real> column(int j) const;
+ virtual Array<Real> row (int i) const ;
+ virtual Array<Real> column (int j) const;
/**
0 <= k <= rows()
*/
- virtual void insert_row(int k)=0;
+ virtual void insert_row (int k)=0;
/**
PRE
0 <= k < rows();
*/
- virtual void delete_row(int k)=0;
- virtual void delete_column(int k)=0;
+ virtual void delete_row (int k)=0;
+ virtual void delete_column (int k)=0;
virtual ~Matrix_storage() { }
virtual Matrix_storage *clone()const=0;
/**
at end of matrix?. when doing loop
- for(i=0; i<h; i++)
- for(j=0; j<w; j++)
+ for (i=0; i<h; i++)
+ for (j=0; j<w; j++)
..
*/
- virtual bool mult_ok(int i, int j) const=0;
+ virtual bool mult_ok (int i, int j) const=0;
/**
walk through matrix (regular multiply).
this will make sparse matrix implementation easy.
PRE
- mult_ok(i,j)
+ mult_ok (i,j)
*/
- virtual void mult_next(int &i, int &j) const = 0;
+ virtual void mult_next (int &i, int &j) const = 0;
/**
valid matrix entry. return false if at end of row
*/
- virtual bool trans_ok(int i, int j) const=0;
+ virtual bool trans_ok (int i, int j) const=0;
/**
walk through matrix (transposed multiply).
Get next i (for column j)
PRE
- ver_ok(i,j)
+ ver_ok (i,j)
*/
- virtual void trans_next(int &i, int &j) const = 0;
+ virtual void trans_next (int &i, int &j) const = 0;
/// generate a "Full_storage" matrix
- static Matrix_storage *get_full(int n, int m);
- static void set_band(Matrix_storage*&, int band);
- static void set_full(Matrix_storage*&);
- virtual bool try_right_multiply(Matrix_storage *dest,
+ static Matrix_storage *get_full (int n, int m);
+ static void set_band (Matrix_storage*&, int band);
+ static void set_full (Matrix_storage*&);
+ virtual bool try_right_multiply (Matrix_storage *dest,
const Matrix_storage *fact)const ;
/**
RTTI.
DECLARE_MY_RUNTIME_TYPEINFO;
- static Matrix_storage* get_product_result(Matrix_storage *left,
+ static Matrix_storage* get_product_result (Matrix_storage *left,
Matrix_storage *right);
- static void set_addition_result(
+ static void set_addition_result (
Matrix_storage *&dat, Matrix_storage *right);
- static void set_product_result(
+ static void set_product_result (
Matrix_storage*&dest, Matrix_storage*left, Matrix_storage*right);
};
protected:
Matrix_storage *dat;
- void set(Matrix_storage*);
- Matrix(Matrix_storage*);
+ void set (Matrix_storage*);
+ Matrix (Matrix_storage*);
public:
void OK() const { dat->OK(); }
- int cols() const { return dat->cols(); }
- int rows() const { return dat->rows(); }
+ int cols() const { return dat->cols (); }
+ int rows() const { return dat->rows (); }
/** return the size of a matrix.
PRE
~Matrix() { delete dat; }
/// set entries to r
- void fill(Real r);
+ void fill (Real r);
/// set diagonal to d
- void set_diag(Real d);
+ void set_diag (Real d);
- void set_diag(Vector d);
+ void set_diag (Vector d);
/// set unit matrix
- void unit() { set_diag(1.0); }
+ void unit() { set_diag (1.0); }
void operator+=(Matrix const &m);
void operator-=(Matrix const &m);
add a row to the matrix before row k
PRE
- v.dim() == cols()
+ v.dim() == cols ()
0 <= k <= rows()
*/
- void insert_row(Vector v,int k);
+ void insert_row (Vector v,int k);
/** .
delete a row from this matrix.
PRE
0 <= k < rows();
*/
- void delete_row(int k) { dat->delete_row(k); }
- void delete_column(int k) { dat->delete_column(k); }
+ void delete_row (int k) { dat->delete_row (k); }
+ void delete_column (int k) { dat->delete_column (k); }
/**
square n matrix, initialised to null
*/
- Matrix(int n);
+ Matrix (int n);
/**
n x m matrix, init to 0
*/
- Matrix(int n, int m);
- Matrix(Matrix const &m);
+ Matrix (int n, int m);
+ Matrix (Matrix const &m);
/// dyadic product: v * w.transpose
- Matrix(Vector v, Vector w);
+ Matrix (Vector v, Vector w);
void operator=(Matrix const &m);
/// access an element
- Real operator()(int i,int j) const { return dat->elem(i,j); }
+ Real operator()(int i,int j) const { return dat->elem (i,j); }
/// access an element
- Real &operator()(int i, int j) { return dat->elem(i,j); }
+ Real &operator()(int i, int j) { return dat->elem (i,j); }
/// Matrix multiply with vec (from right)
Vector operator *(Vector const &v) const;
/// set this to m1*m2.
- void set_product(Matrix const &m1, Matrix const &m2);
+ void set_product (Matrix const &m1, Matrix const &m2);
- Vector left_multiply(Vector const &) const;
+ Vector left_multiply (Vector const &) const;
Matrix operator-() const;
PRE
0 <= c1,c2 < cols()
*/
- void swap_columns(int c1, int c2);
+ void swap_columns (int c1, int c2);
/** swap.
PRE
0 <= c1,c2 < rows()
*/
- void swap_rows(int c1, int c2);
+ void swap_rows (int c1, int c2);
- Vector row(int ) const;
- Vector col(int) const;
+ Vector row (int) const;
+ Vector col (int) const;
operator String() const;
void print() const;
};
inline Vector
-operator *(Vector &v, Matrix const & m) { return m.left_multiply(v); }
+operator *(Vector &v, Matrix const & m) { return m.left_multiply (v); }
Matrix operator *(Matrix const & m1,Matrix const &m2);
Matrix operator /(Matrix const &m1,Real a);
inline Matrix operator -(Matrix m1,const Matrix m2)
template<class T>
class Link_array : public Array<T*>
{
- static default_compare(T *const& p1, T *const&p2) {
+ static default_compare (T *const& p1, T *const&p2) {
/* can't do p1 -p2, since T might be an incomplete type */
if (p1 < p2)
return -1 ;
return 0;
}
public:
- void substitute(T *old, T*new_l)
+ void substitute (T *old, T*new_l)
{
int i;
- while ((i = find_i(old)) >=0)
+ while ((i = find_i (old)) >=0)
if (new_l)
- elem(i) =new_l;
+ elem (i) =new_l;
else
- del(i);
+ del (i);
}
- void unordered_substitute(T* old, T * new_l)
+ void unordered_substitute (T* old, T * new_l)
{
int i;
- while ((i = find_i(old)) >=0)
+ while ((i = find_i (old)) >=0)
if (new_l)
- elem(i) =new_l;
+ elem (i) =new_l;
else {
- unordered_del( i );
+ unordered_del (i);
}
}
void default_sort() {
- sort(default_compare);
+ sort (default_compare);
}
void uniq() {
Link_array<T> l_arr;
for (int i=0; i < size(); i++)
- if (!i || elem(i-1) != elem(i))
- l_arr.push(elem(i));
+ if (!i || elem (i-1) != elem (i))
+ l_arr.push (elem (i));
*this = l_arr;
}
int find_i (T const * t) const {
for (int i=0; i < size(); i++)
- if (elem(i) == t)
+ if (elem (i) == t)
return i;
return -1;
}
- T *find_l(T const *t)const
+ T *find_l (T const *t)const
{
- int i = find_i(t);
+ int i = find_i (t);
if (i >= 0)
- return elem(i);
+ return elem (i);
else
return 0;
}
{
public:
/// locate a file in the search path
- String find(String nm)const;
+ String find (String nm)const;
/// add to end of path.
Array<String>::push;
- void add(String str) { push(str); }
+ void add (String str) { push (str); }
};
/** split a path into its components.
@return
String &drive, String &dirs, String &filebase, String &extension
*/
-void split_path(String path, String &drive, String &dirs, String &filebase, String &extension);
+void split_path (String path, String &drive, String &dirs, String &filebase, String &extension);
#endif
return p;
}
T remove_prev_p() {
- assert( ok() );
+ assert (ok());
(*this)--;
return remove_p();
}
- Link_list<T> &list() { return (Link_list<T>&)Cursor<void*>::list(); }
+ Link_list<T> &list() { return (Link_list<T>&)Cursor<void*>::list (); }
PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);}
PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); }
PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);}
PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); }
PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);}
int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);}
- PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);} PCursor(const Link_list<T> & l) : Cursor<void*> (l) {}
+ PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);} PCursor (const Link_list<T> & l) : Cursor<void*> (l) {}
PCursor() : Cursor<void*> () {}
- PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
+ PCursor (const Cursor<void*>& cursor) : Cursor<void*>(cursor) { }
void* vptr() const { return *((Cursor<void*> &) *this); }
// should return T& ?
- T ptr() const { return (T) vptr(); }
+ T ptr() const { return (T) vptr (); }
T operator ->() const { return ptr(); }
operator T() { return ptr(); }
T operator *() { return ptr(); }
- void add(T const & p ) { Cursor<void*>::add((void*) p); }
- void insert(T const & p ) { Cursor<void*>::insert((void*) p);}
- static int compare(PCursor<T> a,PCursor<T>b) {
- return Cursor<void*>::compare(a,b);
+ void add (T const & p) { Cursor<void*>::add ((void*) p); }
+ void insert (T const & p) { Cursor<void*>::insert ((void*) p);}
+ static int compare (PCursor<T> a,PCursor<T>b) {
+ return Cursor<void*>::compare (a,b);
}
};
#include "compare.hh"
-template_instantiate_compare(PCursor<T>, PCursor<T>::compare, template<class T>);
+TEMPLATE_INSTANTIATE_COMPARE(PCursor<T>, PCursor<T>::compare, template<class T>);
#endif
void
PCursor<T>::junk()
{
-#if !defined(NDEBUG) && defined(PARANOID)
+#if !defined (NDEBUG) && defined (PARANOID)
list().OK();
#endif
delete ptr();
-#if !defined(NDEBUG)&&defined(PARANOID)
+#if !defined (NDEBUG)&&defined (PARANOID)
thing() = 0;
list().OK();
#endif
PCursor<T> bottom() const {
return PCursor<T> (List<void*>::bottom());
}
- PCursor<T> find(T) const;
- void concatenate(Link_list<T> const &s) { List<void*>::concatenate(s); }
+ PCursor<T> find (T) const;
+ void concatenate (Link_list<T> const &s) { List<void*>::concatenate (s); }
Link_list() {}
};
public:
void junk();
- Pointer_list(Pointer_list const &) { set_empty(); }
+ Pointer_list (Pointer_list const &) { set_empty(); }
Pointer_list() { }
- ~Pointer_list() { junk(); }
+ ~Pointer_list() { junk (); }
};
#define Pointer_list__copy(T, to, from, op) \
for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
- to.bottom().add(_pc_->op)\
+ to.bottom().add (_pc_->op)\
\
template<class T>
-void PL_copy(Pointer_list<T*> &dst,Pointer_list<T*> const&src);
+void PL_copy (Pointer_list<T*> &dst,Pointer_list<T*> const&src);
template<class T>
void
-PL_copy(Pointer_list<T*> &to, Pointer_list<T*> const&src)
+PL_copy (Pointer_list<T*> &to, Pointer_list<T*> const&src)
{
- for (PCursor<T*> pc(src); pc.ok(); pc++) {
+ for (PCursor<T*> pc (src); pc.ok(); pc++) {
T *q = pc;
T *p=new T(*q) ;
- to.bottom().add(p);
+ to.bottom().add (p);
}
}
/**
Set contents to a copy of #t_l#
*/
- void copy(T const*t_l);
+ void copy (T const*t_l);
T* t_p;
/**
//P(T *p) { t_p = p; }
T *operator ->() { return t_p; }
- operator T * () { return t_p; }
+ operator T *() { return t_p; }
const T *operator ->() const { return t_p ; }
T &operator *() { return *t_p; }
T const &operator *() const { return *t_p; }
template<class T>
inline
void
-P<T>::copy(T const *l_C)
+P<T>::copy (T const *l_C)
{
t_p = l_C ? new T(*l_C) : 0;
}
P<T>::operator =(P const&s)
{
junk();
- copy(s.t_p);
+ copy (s.t_p);
return *this;
}
template<class T>
inline
void
-P<T>::set_p(T * np)
+P<T>::set_p (T * np)
{
if (np == t_p)
return;
template<class T>
inline
void
-P<T>::set_l(T const * l_C)
+P<T>::set_l (T const * l_C)
{
if (t_p == l_C)
return;
junk();
- copy(l_C);
+ copy (l_C);
}
template<class K, class T>
int compare (PQueue_ent<K,T> const &e1 , PQueue_ent<K,T> const &e2) {
- return compare(e1.key , e2.key);
+ return compare (e1.key , e2.key);
}
/**
template<class T>
class PQueue {
Array<T> heap_arr_;
- T &elt(int i) {
+ T &elt (int i) {
return heap_arr_[i-1];
}
- T const&elt(int i) const {
+ T const&elt (int i) const {
return heap_arr_[i-1];
}
public:
{
#ifndef NDEBUG
for (int i =2; i <= size(); i++)
- assert(compare (elt(i/2), elt(i)) <= 0);
+ assert (compare (elt (i/2), elt (i)) <= 0);
#endif
}
- T front () const { return elt(1); }
- int size() const { return heap_arr_.size(); }
- void insert(T v) {
- heap_arr_.push(v);
+ T front() const { return elt (1); }
+ int size() const { return heap_arr_.size (); }
+ void insert (T v) {
+ heap_arr_.push (v);
int i = heap_arr_.size();
int j = i / 2 ;
while (j) {
- if (compare(elt(j), v) > 0) {
- elt(i) = elt(j);
+ if (compare (elt (j), v) > 0) {
+ elt (i) = elt (j);
i = j;
j = i/2;
} else {
break;
}
}
- elt(i) = v;
+ elt (i) = v;
OK();
}
T max() const {
T max_t;
return max_t;
}
- void delmin( ) {
- assert(size());
+ void delmin() {
+ assert (size());
T last = heap_arr_.top();
int mini=2;
int lasti=1;
- while ( mini < size() ) {
- if (compare(elt(mini + 1), elt(mini)) <0)
+ while ( mini < size()) {
+ if (compare (elt (mini + 1), elt (mini)) <0)
mini++;
- if (compare(last,elt(mini) ) < 0)
+ if (compare (last,elt (mini)) < 0)
break;
- elt(lasti) = elt(mini);
+ elt (lasti) = elt (mini);
lasti = mini;
mini *= 2;
}
- elt(lasti) = last;
+ elt (lasti) = last;
heap_arr_.pop();
OK();
}
template<class K>
struct Priorities : Array<K>
{
- void insert(K k)
+ void insert (K k)
{
int i=0;
for (; i < size(); i++) {
- if(elem(i) == k)
+ if (elem (i) == k)
return;
- if (elem(i) > k )
+ if (elem (i) > k)
break;
}
- Array<K>::insert(k, i);
+ Array<K>::insert (k, i);
}
};
#endif // PRIORITIES_HH
#include <Rational.h>
/// print a Rational. To be called from the debugger
-void print_rat(Rational const&);
+void print_rat (Rational const&);
#endif // RATIONAL_HH
const Real infinity_f = HUGE_VAL;
inline Real
-distance(Real x,Real y)
+distance (Real x,Real y)
{
- return abs(x-y);
+ return abs (x-y);
}
#endif
/// Perl -like scalar type.
struct Scalar : public String {
- Scalar(Real r) : String(r) {}
- Scalar(int i) : String(i) {}
- Scalar(char c) : String(c) {}
- Scalar(char const *c) : String(c) {}
- Scalar(String s ):String(s) {}
- Scalar(Rational );
+ Scalar (Real r) : String (r) {}
+ Scalar (int i) : String (i) {}
+ Scalar (char c) : String (c) {}
+ Scalar (char const *c) : String (c) {}
+ Scalar (String s):String (s) {}
+ Scalar (Rational);
operator Rational();
Scalar() {}
bool isnum();
String_data();
/// init from src. Conservative allocation.
- String_data(String_data const &src);
+ String_data (String_data const &src);
~String_data();
@param j, maximum stringlength_i_.
contents thrown away.
*/
- void setmax(int j);
+ void setmax (int j);
/** POST: maxlen >= j.
@param j, maximum stringlength_i_.
contents are kept if it grows.
*/
- void remax(int j);
+ void remax (int j);
/// check if writeable.
void OKW();
void tighten();
// assignment.
- void set( Byte const* byte_C, int length_i );
+ void set (Byte const* byte_C, int length_i);
- void set( char const* ch_C );
+ void set (char const* ch_C);
/// concatenation.
- void append( Byte const* byte_C, int length_i );
+ void append (Byte const* byte_C, int length_i);
- void operator += ( char const* ch_C );
+ void operator += ( char const* ch_C);
char const* ch_C() const;
// idem, non const
Byte* byte_l();
- void trunc(int j);
+ void trunc (int j);
/** access element. not really safe. Can alter length_i_ without
#String_data# knowing it. */
INLINE void
String_data::OK()
{
- assert(maxlen >= length_i_);
- assert(bool(data_byte_p_));
- assert(references >= 1);
+ assert (maxlen >= length_i_);
+ assert (bool (data_byte_p_));
+ assert (references >= 1);
}
}
INLINE
-String_data::String_data(String_data const &src)
+String_data::String_data (String_data const &src)
{
references=0;
maxlen = length_i_ = src.length_i_;
data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead.
- memcpy( data_byte_p_, src.data_byte_p_, length_i_ + 1 );
+ memcpy (data_byte_p_, src.data_byte_p_, length_i_ + 1);
}
INLINE
String_data::~String_data()
{
- assert(references == 0);
+ assert (references == 0);
delete[] data_byte_p_;
}
INLINE void
-String_data::setmax(int j)
+String_data::setmax (int j)
{
OKW();
if (j > maxlen) {
define change authority
*/
INLINE void
-String_data::remax(int j)
+String_data::remax (int j)
{
OKW();
if (j > maxlen) {
Byte *p = new Byte[j + 1];
- memcpy( p, data_byte_p_, ( maxlen <? length_i_ ) + 1 );
+ memcpy (p, data_byte_p_, ( maxlen <? length_i_) + 1 );
maxlen = j;
delete[] data_byte_p_;
data_byte_p_ = p;
{ // should be dec'd const
maxlen = length_i_;
Byte *p = new Byte[maxlen + 1];
- memcpy( p, data_byte_p_, length_i_ + 1 );
+ memcpy (p, data_byte_p_, length_i_ + 1);
delete[] data_byte_p_;
data_byte_p_ = p;
}
// assignment.
INLINE void
-String_data::set( Byte const* byte_C, int length_i )
+String_data::set (Byte const* byte_C, int length_i)
{
OKW();
- assert( byte_C && byte_C != data_byte_p_);
+ assert (byte_C && byte_C != data_byte_p_);
length_i_ = length_i;
- remax( length_i_ ); // copies too
- memcpy( data_byte_p_, byte_C, length_i_ );
+ remax (length_i_); // copies too
+ memcpy (data_byte_p_, byte_C, length_i_);
data_byte_p_[ length_i_ ] = 0;
}
INLINE
void
-String_data::set( char const* ch_C )
+String_data::set (char const* ch_C)
{
- set( (Byte const*)ch_C, strlen( ch_C ) );
+ set ((Byte const*)ch_C, strlen (ch_C) );
}
/// concatenation.
INLINE void
-String_data::append( Byte const* byte_C, int length_i )
+String_data::append (Byte const* byte_C, int length_i)
{
OK();
OKW();
int old_i = length_i_;
length_i_ += length_i;
- remax( length_i_ );
- memcpy( data_byte_p_ + old_i, byte_C, length_i );
+ remax (length_i_);
+ memcpy (data_byte_p_ + old_i, byte_C, length_i);
data_byte_p_[ length_i_ ] = 0;
}
INLINE
void
-String_data::operator += ( char const* ch_C )
+String_data::operator += ( char const* ch_C)
{
- append( (Byte const*)ch_C, strlen( ch_C ) );
+ append ((Byte const*)ch_C, strlen (ch_C) );
}
INLINE
void
-String_data::trunc(int j)
+String_data::trunc (int j)
{
OKW();
- assert(j >= 0 && j <= length_i_);
+ assert (j >= 0 && j <= length_i_);
data_byte_p_[j] = 0;
length_i_ = j;
}
INLINE bool
String_data::is_binary_bo()const
{
-// return !memchr(data_byte_p_, length_i_, 0);
- return ( (int)strlen( (char const*)data_byte_p_ ) != length_i_ );
+// return !memchr (data_byte_p_, length_i_, 0);
+ return ( (int)strlen ((char const*)data_byte_p_) != length_i_ );
}
INLINE Byte&
String_data::operator [](int j)
{
- assert(j >= 0 && j <= length_i_);
+ assert (j >= 0 && j <= length_i_);
return data_byte_p_[j] ;
}
INLINE Byte
String_data::operator [](int j) const
{
- assert(j >= 0 && j <= length_i_);
+ assert (j >= 0 && j <= length_i_);
return data_byte_p_[j];
}
void down();
/// increase ref count
- void up(String_data *d);
+ void up (String_data *d);
/** make sure data has only one reference.
POST: data->references == 1
public:
String_handle();
~String_handle();
- String_handle(String_handle const & src);
+ String_handle (String_handle const & src);
Byte const* byte_C() const;
char const* ch_C() const;
don't use this for loops. Use byte_C()
*/
Byte &operator[](int j);
- void append( Byte const* byte_C, int length_i );
- void set( Byte const* byte_C, int length_i );
+ void append (Byte const* byte_C, int length_i);
+ void set (Byte const* byte_C, int length_i);
void operator = (char const *p);
- void trunc(int j);
+ void trunc (int j);
int length_i() const;
};
/// increase ref count
INLINE void
-String_handle::up(String_data *d)
+String_handle::up (String_data *d)
{
data=d; data->references ++;
}
String_handle::copy()
{
if (data->references !=1){
- String_data *newdata = new String_data(*data);
+ String_data *newdata = new String_data (*data);
down();
- up(newdata);
+ up (newdata);
}
}
INLINE
String_handle::String_handle()
{
- up(new String_data);
+ up (new String_data);
}
INLINE
}
INLINE
-String_handle::String_handle(String_handle const & src)
+String_handle::String_handle (String_handle const & src)
{
- up(src.data);
+ up (src.data);
}
INLINE Byte*
if (this == &src)
return;
down();
- up(src.data);
+ up (src.data);
}
INLINE void
}
INLINE void
-String_handle::append( Byte const* byte_C, int length_i )
+String_handle::append (Byte const* byte_C, int length_i)
{
copy();
- data->append( byte_C, length_i );
+ data->append (byte_C, length_i);
}
INLINE void
-String_handle::set( Byte const* byte_C, int length_i )
+String_handle::set (Byte const* byte_C, int length_i)
{
copy();
- data->set( byte_C, length_i );
+ data->set (byte_C, length_i);
}
INLINE void
String_handle::operator = (char const *p)
{
copy();
- data->set( p );
+ data->set (p);
}
INLINE void
-String_handle::trunc(int j)
+String_handle::trunc (int j)
{
- copy(); data->trunc(j);
+ copy(); data->trunc (j);
}
INLINE int
/** init to empty string. This is needed because other
constructors are provided.*/
String() { }
- String(Rational);
+ String (Rational);
/// String s = "abc";
- String( char const* source );
- String( Byte const* byte_C, int length_i );
+ String (char const* source);
+ String (Byte const* byte_C, int length_i);
/// "ccccc"
- String( char c, int n = 1 );
+ String (char c, int n = 1);
- String( int i , char const *fmt=0);
+ String (int i , char const *fmt=0);
String ( double f , char const* fmt =0);
/// 'true' or 'false'
- String(bool );
+ String (bool);
/// return a "new"-ed copy of contents
Byte* copy_byte_p() const; // return a "new"-ed copy of contents
Byte* byte_l();
/// deprecated; use ch_C()
- operator char const* () const { return ch_C(); }
+ operator char const*() const { return ch_C(); }
- String &operator =( String const & source );
+ String &operator =( String const & source);
/// concatenate s
void operator += (char const* s) { strh_ += s; }
void operator += (String s);
- void append(String);
- void prepend(String);
+ void append (String);
+ void prepend (String);
- char operator []( int n ) const { return strh_[n]; }
+ char operator []( int n) const { return strh_[n]; }
/// return n leftmost chars
- String left_str( int n ) const;
+ String left_str (int n) const;
/// return n rightmost chars
- String right_str( int n ) const;
+ String right_str (int n) const;
/// return uppercase of *this
String upper_str() const;
/// return a piece starting at index_i (first char = index_i 0), length n
- String mid_str(int index_i, int n ) const;
+ String mid_str (int index_i, int n) const;
/// cut out a middle piece, return remainder
- String nomid_str(int index_i, int n ) const;
+ String nomid_str (int index_i, int n) const;
/// signed comparison, analogous to memcmp;
- static int compare_i(String const & s1,const String& s2);
+ static int compare_i (String const & s1,const String& s2);
/// index of rightmost c
- int index_last_i( char c) const;
+ int index_last_i (char c) const;
/// index of rightmost element of string
- int index_last_i( char const* string ) const;
+ int index_last_i (char const* string) const;
- int index_i(char c ) const;
- int index_i(String ) const;
- int index_any_i(String ) const;
+ int index_i (char c) const;
+ int index_i (String) const;
+ int index_any_i (String) const;
void to_upper();
void to_lower();
/// provide Stream output
- void print_on(ostream& os) const;
+ void print_on (ostream& os) const;
/// the length of the string
int length_i() const;
#include "compare.hh"
-instantiate_compare(String const &, String::compare_i);
+INSTANTIATE_COMPARE(String const &, String::compare_i);
// because char const* also has an operator ==, this is for safety:
inline bool operator==(String s1, char const* s2){
- return s1 == String(s2);
+ return s1 == String (s2);
}
inline bool operator==(char const* s1, String s2)
{
- return String(s1)==s2;
+ return String (s1)==s2;
}
-inline bool operator!=(String s1, char const* s2 ) {
- return s1!=String(s2);
+inline bool operator!=(String s1, char const* s2 ) {
+ return s1!=String (s2);
}
inline bool operator!=(char const* s1,String s2) {
- return String(s2) !=s1;
+ return String (s2) !=s1;
}
}
inline ostream &
-operator << ( ostream& os, String d )
+operator << ( ostream& os, String d)
{
- d.print_on(os);
+ d.print_on (os);
return os;
}
-
-// String quoteString(String message, String quote);
-
#endif
Text_record() { } // needed because of other ctor
/// report an error in this line.
- message(String s) {
+ message (String s) {
cerr << '\n'<< filename << ": "<< line_no << s << "\n";
}
String operator[](int j) {
return Array<String>::operator[](j);
}
- Text_record(Array<String> s, String fn, int j) : Array<String>(s) {
+ Text_record (Array<String> s, String fn, int j) : Array<String>(s) {
filename = fn; line_no = j;
}
Array<String>::size;
/// get a line with records
Text_record get_record();
- Text_db(String fn):Data_file(fn) { }
+ Text_db (String fn):Data_file (fn) { }
Data_file::error;
bool eof();
String name;
public:
- Text_stream(String fn);
+ Text_stream (String fn);
String get_name() { return name; }
bool eof() {
- return feof(f);
+ return feof (f);
}
bool eol() {
return (peek() == '\n');
}
char peek() {
char c = get();
- unget(c);
+ unget (c);
return c;
}
int line(){
char c;
if (pushback.empty())
- c = getc(f);
+ c = getc (f);
else
c = pushback.pop();
line_no++;
return c;
}
- void unget(char c) {
+ void unget (char c) {
if (c =='\n')
line_no--;
- pushback.push(c);
+ pushback.push (c);
}
- ~Text_stream (){
+ ~Text_stream(){
if (!eof())
cerr <<__FUNCTION__<< ": closing unended file";
- fclose(f);
+ fclose (f);
}
/// GNU format message.
- void message(String s);
+ void message (String s);
};
#endif
Union find, a standard algorithm:
Union_find represents an undirected graph of N points. You can
- connect two points using #connect()#. #find(i)# finds a uniquely
+ connect two points using #connect()#. #find (i)# finds a uniquely
determined representant of the equivalence class of points
connected to #i#.
*/
struct Union_find {
- void connect(int i, int j);
- int find(int i);
- bool equiv(int i, int j) { return find(i) == find(j); }
- Union_find(int sz);
+ void connect (int i, int j);
+ int find (int i);
+ bool equiv (int i, int j) { return find (i) == find (j); }
+ Union_find (int sz);
private:
Array<int> classes;
/// copy a bare (C-)array from #src# to #dest# sized #count#
template<class T>
-inline void arrcpy(T*dest, T*src, int count) {
+inline void arrcpy (T*dest, T*src, int count) {
for (int i=0; i < count ; i++)
*dest++ = *src++;
}
T *thearray;
/// stretch or shrink array.
- void remax(int newmax) {
+ void remax (int newmax) {
T* newarr = new T[newmax];
size_ = (newmax < size_) ? newmax : size_;
- arrcpy(newarr, thearray, size_);
+ arrcpy (newarr, thearray, size_);
delete[] thearray;
thearray = newarr;
public:
/// check invariants
void OK() const {
- assert(max >= size_ && size_ >=0);
- if (max) assert(thearray);
+ assert (max >= size_ && size_ >=0);
+ if (max) assert (thearray);
}
/** report the size_.
@see {setsize_}
/** set the size_ to #s#.
POST: size() == s.
Warning: contents are unspecified */
- void set_size(int s) {
- if (s >= max) remax(s);
+ void set_size (int s) {
+ if (s >= max) remax (s);
size_ = s;
}
/// return a "new"ed copy of array
T* copy_array() const {
T* Tarray = new T[size_];
- arrcpy(Tarray, thearray, size_);
+ arrcpy (Tarray, thearray, size_);
return Tarray;
}
// depracated
- operator T* () const {
+ operator T*() const {
return copy_array();
}
void operator=(Array const & src) {
set_size (src.size_);
- arrcpy(thearray,src.thearray, size_);
+ arrcpy (thearray,src.thearray, size_);
}
- Array(Array const & src) {
+ Array (Array const & src) {
thearray = src.copy_array();
max = size_ = src.size_;
}
/// tighten array size_.
- void precompute () { remax(size_); }
+ void precompute() { remax (size_); }
/// access element
T &operator[] (int i) {
- return elem(i);
+ return elem (i);
}
/// access element
T const & operator[] (int i) const {
- return elem(i);
+ return elem (i);
}
/// access element
- T &elem( int i) const {
- assert(i >=0&&i<size_);
+ T &elem (int i) const {
+ assert (i >=0&&i<size_);
return ((T*)thearray)[i];
}
/// add to the end of array
- void push(T x) {
+ void push (T x) {
if (size_ == max)
- remax(2*max + 1);
+ remax (2*max + 1);
// T::operator=(T &) is called here. Safe to use with automatic
// vars
}
/// remove and return last entry
T pop() {
- assert(!empty());
- T l = top(0);
- set_size(size()-1);
+ assert (!empty());
+ T l = top (0);
+ set_size (size()-1);
return l;
}
/// access last entry
- T& top(int j=0) {
+ T& top (int j=0) {
return (*this)[size_-j-1];
}
/// return last entry
void swap (int i,int j) {
- T t((*this)[i]);
+ T t ((*this)[i]);
(*this)[i]=(*this)[j];
(*this)[j]=t;
}
bool empty() const { return !size_; }
- void insert(T k, int j) {
- assert(j >=0 && j<= size_);
- set_size(size_+1);
+ void insert (T k, int j) {
+ assert (j >=0 && j<= size_);
+ set_size (size_+1);
for (int i=size_-1; i > j; i--)
thearray[i] = thearray[i-1];
thearray[j] = k;
/**
remove i-th element, and return it.
*/
- T get(int i) {
- T t = elem(i);
+ T get (int i) {
+ T t = elem (i);
del (i);
return t;
}
- void unordered_del(int i)
+ void unordered_del (int i)
{
- elem(i) = top();
- set_size(size() -1);
+ elem (i) = top();
+ set_size (size() -1);
}
- void del(int i) {
- assert(i >=0&& i < size_);
- arrcpy(thearray+i, thearray+i+1, size_-i-1);
+ void del (int i) {
+ assert (i >=0&& i < size_);
+ arrcpy (thearray+i, thearray+i+1, size_-i-1);
size_--;
}
// quicksort.
void sort (int (*compare)( T const&,T const&),
- int lower = -1, int upper = -1 ) {
+ int lower = -1, int upper = -1) {
if (lower < 0) {
lower = 0 ;
upper = size()-1;
}
if (lower >= upper)
return;
- swap(lower, (lower+upper)/2);
+ swap (lower, (lower+upper)/2);
int last = lower;
for (int i= lower +1; i <= upper; i++)
- if (compare(thearray[i], thearray[lower]) < 0 )
- swap( ++last,i);
- swap(lower, last);
- sort(compare, lower, last-1);
- sort(compare, last+1, upper);
+ if (compare (thearray[i], thearray[lower]) < 0)
+ swap (++last,i);
+ swap (lower, last);
+ sort (compare, lower, last-1);
+ sort (compare, last+1, upper);
}
- void concat(Array<T> const &src) {
+ void concat (Array<T> const &src) {
int s = size_;
- set_size(size_ + src.size_);
- arrcpy(thearray+s,src.thearray, src.size_);
+ set_size (size_ + src.size_);
+ arrcpy (thearray+s,src.thearray, src.size_);
}
- Array<T> slice(int lower, int upper) {
- assert(lower >= 0 && lower <=upper&& upper <= size_);
+ Array<T> slice (int lower, int upper) {
+ assert (lower >= 0 && lower <=upper&& upper <= size_);
Array<T> r;
int s =upper-lower;
- r.set_size(s);
- arrcpy(r.thearray, thearray + lower, s);
+ r.set_size (s);
+ arrcpy (r.thearray, thearray + lower, s);
return r;
}
void reverse() {
int h = size_/2;
for (int i =0,j = size_-1; i < h; i++,j--)
- swap(i,j);
+ swap (i,j);
}
};
Array<Real> dat;
public:
void OK() const { dat.OK();}
- int dim() const { return dat.size(); }
+ int dim() const { return dat.size (); }
Vector() { }
- Vector(Array<Real> d );
- Vector(Vector const &n);
- Vector(int n) {
- dat.set_size(n);
- fill(0);
+ Vector (Array<Real> d);
+ Vector (Vector const &n);
+ Vector (int n) {
+ dat.set_size (n);
+ fill (0);
}
- void set_dim(int i)
+ void set_dim (int i)
{
- dat.set_size(i);
+ dat.set_size (i);
}
- void insert(Real v, int i) {
- dat.insert(v,i);
+ void insert (Real v, int i) {
+ dat.insert (v,i);
}
- void del(int i) { dat.del(i); }
+ void del (int i) { dat.del (i); }
operator String() const;
- void fill(Real r) {
+ void fill (Real r) {
for (int i=0; i < dim(); i++)
dat[i] =r;
}
void operator +=(Vector v) {
- assert(v.dim() == dim());
+ assert (v.dim() == dim ());
for (int i=0; i < dim(); i++)
dat[i] += v.dat[i];
}
}
void operator -=(Vector v) {
- assert(v.dim() == dim());
+ assert (v.dim() == dim ());
for (int i=0; i < dim(); i++)
- dat[i] -= v(i);
+ dat[i] -= v (i);
}
Real &operator()(int i) { return dat[i]; }
Real operator()(int i) const { return dat[i]; }
- Real elem(int i) { return dat[i]; }
+ Real elem (int i) { return dat[i]; }
Real operator *(Vector v) const {
Real ip=0;
- assert(v.dim() == dim());
+ assert (v.dim() == dim ());
for (int i=0; i < dim(); i++)
- ip += dat[i] *v(i);
+ ip += dat[i] *v (i);
return ip;
}
Vector operator-() const;
Real norm() {
- return sqrt(norm_sq() );
+ return sqrt (norm_sq());
}
Real norm_sq() {
return ((*this) * (*this));
}
- operator Array<Real> () { return dat; }
+ operator Array<Real>() { return dat; }
void print() const;
/// set to j-th element of unit-base
- void set_unit(int j) ;
+ void set_unit (int j) ;
};
inline Vector
/** a macro to declare the classes name as a static and virtual function.
The static_name() can *not* be inlined (this might have the effect that
- s->name() != S::static_name(). Overlapping strings need not be merged in C++
+ s->name() != S::static_name (). Overlapping strings need not be merged in C++
*/
#define DECLARE_MY_RUNTIME_TYPEINFO \
static char const *static_name();\
-static bool static_is_type_b(const char*s);\
-virtual bool is_type_b(const char *s)const { return static_is_type_b(s); } \
-virtual char const *name() const{ return static_name(); } \
+static bool static_is_type_b (const char*s);\
+virtual bool is_type_b (const char *s)const { return static_is_type_b (s); } \
+virtual char const *name() const{ return static_name (); } \
int a_stupid_nonexistent_function_to_allow_the_semicolon_come_out()
#define IMPLEMENT_STATIC_NAME(c)\
#define IMPLEMENT_IS_TYPE_B(D) \
IMPLEMENT_STATIC_NAME(D)\
- bool D::static_is_type_b(const char *s) \
+ bool D::static_is_type_b (const char *s) \
{ \
return s == static_name(); \
}
#define IMPLEMENT_IS_TYPE_B1(D,B) \
IMPLEMENT_STATIC_NAME(D)\
- bool D::static_is_type_b(const char *s) \
+ bool D::static_is_type_b (const char *s) \
{ \
- return s == static_name() || B::static_is_type_b(s); \
+ return s == static_name() || B::static_is_type_b (s); \
}
#define IMPLEMENT_IS_TYPE_B2(D, BA, BB) \
IMPLEMENT_STATIC_NAME(D)\
- bool D::static_is_type_b(const char *s) \
+ bool D::static_is_type_b (const char *s) \
{ \
- return s == static_name() || BA::static_is_type_b(s) || BB::static_is_type_b(s); \
+ return s == static_name() || BA::static_is_type_b (s) || BB::static_is_type_b (s); \
}
#endif
{
long l;
if (!optional_argument_ch_C_
- || sscanf(optional_argument_ch_C_, "%ld", &l) != 1)
- report(E_ILLEGALARG);
+ || sscanf (optional_argument_ch_C_, "%ld", &l) != 1)
+ report (E_ILLEGALARG);
return l;
}
Getopt_long::parselong()
{
char const *optnm = arg_value_ch_a_a_[array_index_i_] + 2 ;
- assert(*optnm);
+ assert (*optnm);
- char const *endopt = strchr(optnm, '=');
- int searchlen = (endopt) ? endopt - optnm : strlen(optnm);
+ char const *endopt = strchr (optnm, '=');
+ int searchlen = (endopt) ? endopt - optnm : strlen (optnm);
found_option_l_=0;
for (int i=0; i< table_len_i_; i++) {
char const *ln = option_a_[i].longname;
- if (ln && !strncmp(ln, optnm, searchlen)) {
+ if (ln && !strncmp (ln, optnm, searchlen)) {
found_option_l_ = option_a_+i;
break;
}
}
if (!found_option_l_) {
- report(E_UNKNOWNOPTION);
+ report (E_UNKNOWNOPTION);
return 0;
}
array_index_i_++;
array_index_i_++;
}
if (!optional_argument_ch_C_)
- report(E_ARGEXPECT);
+ report (E_ARGEXPECT);
} else {
optional_argument_ch_C_ = 0;
if (endopt)
- report(E_NOARGEXPECT);
+ report (E_NOARGEXPECT);
}
return found_option_l_;
void
-Long_option_init::printon(ostream &errorout)const
+Long_option_init::printon (ostream &errorout)const
{
if (shortname)
errorout <<"-" << shortname;
// report an error, GNU style.
void
-Getopt_long::report(Errorcod c)
+Getopt_long::report (Errorcod c)
{
error_ = c;
if (!error_ostream_l_)
switch (c) {
case E_ARGEXPECT:
*error_ostream_l_<< "option ";
- found_option_l_->printon(*error_ostream_l_);
+ found_option_l_->printon (*error_ostream_l_);
*error_ostream_l_ << "requires an argument"<<endl;
break;
case E_NOARGEXPECT:
break;
case E_ILLEGALARG:
*error_ostream_l_ << "illegal argument `" << optional_argument_ch_C_ << "\'to option ";
- found_option_l_->printon(*error_ostream_l_);
+ found_option_l_->printon (*error_ostream_l_);
*error_ostream_l_ << '\n';
default:
- assert(false);
+ assert (false);
}
- exit(2);
+ exit (2);
}
const Long_option_init *
{
char c=arg_value_ch_a_a_[array_index_i_][argument_index_i_];
found_option_l_=0;
- assert(c);
+ assert (c);
for (int i=0; i < table_len_i_; i++)
if (option_a_[i].shortname == c) {
}
if (!found_option_l_){
- report(E_UNKNOWNOPTION);
+ report (E_UNKNOWNOPTION);
return 0;
}
array_index_i_ ++;
}
if (!optional_argument_ch_C_) {
- report(E_ARGEXPECT);
+ report (E_ARGEXPECT);
}
return found_option_l_;
return 0;
if (argument_C[1] == '-') {// what to do with "command -- bla"
- if ( argument_C[2] )
+ if ( argument_C[2])
return parselong();
else
return 0;
}
}
-Getopt_long::Getopt_long(int c, char **v, Long_option_init *lo)
+Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo)
{
option_a_ = lo;
error_ostream_l_ = &cerr;
char*
-strnlwr( char* start_l ,int n)
+strnlwr (char* start_l ,int n)
{
char * p = start_l + n;
while ( --p >= start_l) {
- *p = tolower( *p ); /* a macro on some compilers */
+ *p = tolower (*p); /* a macro on some compilers */
}
return start_l;
}
char*
-strnupr( char* start_l, int n)
+strnupr (char* start_l, int n)
{
char * p = start_l + n;
while ( --p >= start_l) {
- *p = toupper( *p ); /* a macro on some compilers */
+ *p = toupper (*p); /* a macro on some compilers */
}
return start_l;
}
*/
char *
-memmem(Byte const * haystack, int haystack_len,
+memmem (Byte const * haystack, int haystack_len,
Byte const *needle,int needle_len)
{
Byte const * end_haystack = haystack + haystack_len - needle_len;
#endif
Byte *
-memrchr(Byte const * p, int n, char c)
+memrchr (Byte const * p, int n, char c)
{
const Byte * q = p+n;
while (q > p) {
template<class T>
inline void
-my_swap(T &t1, T &t2, T &tmp)
+my_swap (T &t1, T &t2, T &tmp)
{
tmp = t1;
t1 = t2;
}
Byte*
-strrev( Byte* byte_l, int length_i )
+strrev (Byte* byte_l, int length_i)
{
Byte tmp_byte;
Byte* left_l = byte_l;
Byte* right_l = byte_l + length_i;
- while ( right_l > left_l ) {
- my_swap(*right_l-- , *left_l++ , tmp_byte);
+ while ( right_l > left_l) {
+ my_swap (*right_l-- , *left_l++ , tmp_byte);
}
return byte_l;
}
#if ! HAVE_SNPRINTF
int snprintf ( char *str, size_t,
- char const *format, ... )
+ char const *format, ...)
{
va_list ap;
- va_start(ap, format);
- int i = vsprintf(str, format, ap);
- va_end(ap);
+ va_start (ap, format);
+ int i = vsprintf (str, format, ap);
+ va_end (ap);
return i;
}
#endif
String s;
#ifndef NPRINT
Matrix_storage const * stor_c_l = dat;
- s=String("matrix { (") + dat->name() + ")\n";
+ s=String ("matrix { (") + dat->name() + ")\n";
for (int i=0; i< rows(); i++){
for (int j = 0; j < cols(); j++) {
- s+= String(stor_c_l->elem(i,j), "%6f ");
+ s+= String (stor_c_l->elem (i,j), "%6f ");
}
s+="\n";
}
#ifndef NPRINT
s="vector [";
for (int i=0; i < dim(); i++) {
- s += String(dat[i], "%6f") + String(' ');
+ s += String (dat[i], "%6f") + String (' ');
}
s+="]";
#endif
#include "diagonal-storage.hh"
void
-Matrix_storage::set_addition_result(Matrix_storage *&dat, Matrix_storage *right)
+Matrix_storage::set_addition_result (Matrix_storage *&dat, Matrix_storage *right)
{
- if (dat && dat->name() == Diagonal_storage::static_name()
- && right->name() == Diagonal_storage::static_name()) {
+ if (dat && dat->name() == Diagonal_storage::static_name ()
+ && right->name() == Diagonal_storage::static_name ()) {
Diagonal_storage *L = (Diagonal_storage*)dat;
Diagonal_storage* R = (Diagonal_storage*) right;
- if ( R->band_size_i() > L->band_size_i()) {
- L->set_band_size(R->band_size_i());
+ if ( R->band_size_i() > L->band_size_i ()) {
+ L->set_band_size (R->band_size_i());
}
return ;
}
- if (!dat || !dat->is_type_b(Full_storage::static_name() )) {
+ if (!dat || !dat->is_type_b (Full_storage::static_name())) {
- Matrix_storage *new_stor = (dat)? new Full_storage(dat) :
- new Full_storage( right->rows(), right->cols());
+ Matrix_storage *new_stor = (dat)? new Full_storage (dat) :
+ new Full_storage (right->rows(), right->cols ());
delete dat;
dat = new_stor;
}
}
Matrix_storage*
-Matrix_storage::get_product_result(Matrix_storage*left, Matrix_storage*right)
+Matrix_storage::get_product_result (Matrix_storage*left, Matrix_storage*right)
{
Matrix_storage* dest =0;
- set_product_result(dest, left,right);
+ set_product_result (dest, left,right);
return dest;
}
hairy
*/
void
-Matrix_storage::set_product_result(Matrix_storage*&dest,
+Matrix_storage::set_product_result (Matrix_storage*&dest,
Matrix_storage*left, Matrix_storage*right)
{
- if ( left->name() == Diagonal_storage::static_name()
- && right->name() == Diagonal_storage::static_name()) {
+ if ( left->name() == Diagonal_storage::static_name ()
+ && right->name() == Diagonal_storage::static_name ()) {
Diagonal_storage *L = (Diagonal_storage*)left;
Diagonal_storage* R = (Diagonal_storage*) right;
- if (L->band_size_i() + R->band_size_i() < L->dim()/2 ) {
- if (dest ->name() != Diagonal_storage::static_name()){
+ if (L->band_size_i() + R->band_size_i () < L->dim ()/2) {
+ if (dest ->name() != Diagonal_storage::static_name ()){
delete dest;
dest = new Diagonal_storage;
}
- dest->set_size(L->dim());
+ dest->set_size (L->dim());
return;
}
}
- if ( dest && dest->name() == Full_storage::static_name()) {
- dest->set_size(left->rows(), right->cols());
+ if ( dest && dest->name() == Full_storage::static_name ()) {
+ dest->set_size (left->rows(), right->cols ());
} else {
delete dest;
- dest = new Full_storage( left->rows(), right->cols());
+ dest = new Full_storage (left->rows(), right->cols ());
}
}
IMPLEMENT_IS_TYPE_B(Matrix_storage);
Matrix_storage *
-Matrix_storage::get_full(int n, int m)
+Matrix_storage::get_full (int n, int m)
{
- return new Full_storage(n,m);
+ return new Full_storage (n,m);
}
bool
-Matrix_storage::try_right_multiply(Matrix_storage *,
+Matrix_storage::try_right_multiply (Matrix_storage *,
const Matrix_storage *)const
{
return false;
}
Array<Real>
-Matrix_storage::row(int n) const
+Matrix_storage::row (int n) const
{
Array<Real> r;
for (int j = 0; j < cols(); j++)
- r.push(elem(n,j));
+ r.push (elem (n,j));
return r;
}
Array<Real>
-Matrix_storage::column(int n) const
+Matrix_storage::column (int n) const
{
Array<Real> r;
for (int i = 0; i < rows(); i++)
- r.push(elem(i,n));
+ r.push (elem (i,n));
return r;
}
void
-Matrix_storage::set_size(int rows, int cols)
+Matrix_storage::set_size (int rows, int cols)
{
- resize(rows,cols);
+ resize (rows,cols);
}
void
-Matrix_storage::set_size(int rows)
+Matrix_storage::set_size (int rows)
{
- resize(rows);
+ resize (rows);
}
void
-Matrix_storage::set_band(Matrix_storage *&mat, int b)
+Matrix_storage::set_band (Matrix_storage *&mat, int b)
{
- Matrix_storage* ns = new Diagonal_storage(mat, b);
+ Matrix_storage* ns = new Diagonal_storage (mat, b);
delete mat;
mat=ns;
}
void
-Matrix_storage::set_full(Matrix_storage *&mat)
+Matrix_storage::set_full (Matrix_storage *&mat)
{
- Matrix_storage* ns = new Full_storage(mat);
+ Matrix_storage* ns = new Full_storage (mat);
delete mat;
mat=ns;
}
bool
Matrix::band_b()const
{
- return dat->is_type_b( Diagonal_storage::static_name());
+ return dat->is_type_b (Diagonal_storage::static_name());
}
void
Matrix::set_full() const
{
- if ( dat->name() != Full_storage::static_name()) {
- Matrix_storage::set_full( ((Matrix*)this)->dat );
+ if ( dat->name() != Full_storage::static_name ()) {
+ Matrix_storage::set_full (((Matrix*)this)->dat);
}
}
return;
// it only looks constant
Matrix*self = (Matrix*)this;
- Matrix_storage::set_band(self->dat,b);
+ Matrix_storage::set_band (self->dat,b);
}
Real
Matrix::norm() const
{
Real r =0.0;
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- r += sqr(dat->elem(i,j));
- return sqrt(r);
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ r += sqr (dat->elem (i,j));
+ return sqrt (r);
}
void
-Matrix::fill(Real r)
+Matrix::fill (Real r)
{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=r;
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j)=r;
}
void
-Matrix::set_diag(Real r)
+Matrix::set_diag (Real r)
{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=(i==j) ? r: 0.0;
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j)=(i==j) ? r: 0.0;
}
void
-Matrix::set_diag(Vector d)
+Matrix::set_diag (Vector d)
{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=(i==j) ? d(i): 0.0;
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j)=(i==j) ? d (i): 0.0;
}
void
Matrix::operator+=(Matrix const &m)
{
- Matrix_storage::set_addition_result(dat, m.dat);
- assert(m.cols() == cols());
- assert(m.rows() == rows());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) += m(i,j);
+ Matrix_storage::set_addition_result (dat, m.dat);
+ assert (m.cols() == cols ());
+ assert (m.rows() == rows ());
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j) += m (i,j);
}
void
Matrix::operator-=(Matrix const &m)
{
- Matrix_storage::set_addition_result(dat, m.dat);
- assert(m.cols() == cols());
- assert(m.rows() == rows());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) -= m(i,j);
+ Matrix_storage::set_addition_result (dat, m.dat);
+ assert (m.cols() == cols ());
+ assert (m.rows() == rows ());
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j) -= m (i,j);
}
void
Matrix::operator*=(Real a)
{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) *= a;
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j) *= a;
}
void
int
Matrix::band_i()const
{
- if ( band_b() ) {
+ if ( band_b()) {
Diagonal_storage const * diag = (Diagonal_storage*) dat;
return diag->band_size_i();
}
int starty = dim();
- while (starty >= 0 ) {
- for ( int i = starty, j = 0; i < dim(); i++, j++ )
- if (dat->elem( i,j ))
+ while (starty >= 0) {
+ for ( int i = starty, j = 0; i < dim(); i++, j++)
+ if (dat->elem (i,j))
goto gotcha;
for ( int i=0, j = starty; j < dim(); i++,j++)
- if (dat->elem(i,j))
+ if (dat->elem (i,j))
goto gotcha;
starty --;
}
return starty;
}
-Matrix::Matrix(Matrix const &m)
+Matrix::Matrix (Matrix const &m)
{
m.OK();
}
-Matrix::Matrix(int n, int m)
+Matrix::Matrix (int n, int m)
{
- dat = Matrix_storage::get_full(n,m);
- fill(0);
+ dat = Matrix_storage::get_full (n,m);
+ fill (0);
}
-Matrix::Matrix(Matrix_storage*stor_p)
+Matrix::Matrix (Matrix_storage*stor_p)
{
dat = stor_p;
}
-Matrix::Matrix(int n)
+Matrix::Matrix (int n)
{
- dat = Matrix_storage::get_full(n,n);
- fill(0);
+ dat = Matrix_storage::get_full (n,n);
+ fill (0);
}
-Matrix::Matrix(Vector v, Vector w)
+Matrix::Matrix (Vector v, Vector w)
{
- dat = Matrix_storage::get_full(v.dim(), w.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=v(i)*w(j);
+ dat = Matrix_storage::get_full (v.dim(), w.dim ());
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dat->elem (i,j)=v (i)*w (j);
}
Vector
-Matrix::row(int k) const
+Matrix::row (int k) const
{
int n=cols();
- Vector v(n);
- for(int i=0; i < n; i++)
- v(i)=dat->elem(k,i);
+ Vector v (n);
+ for (int i=0; i < n; i++)
+ v (i)=dat->elem (k,i);
return v;
}
Vector
-Matrix::col(int k) const
+Matrix::col (int k) const
{
int n=rows();
- Vector v(n);
- for(int i=0; i < n; i++)
- v(i)=dat->elem(i,k);
+ Vector v (n);
+ for (int i=0; i < n; i++)
+ v (i)=dat->elem (i,k);
return v;
}
Vector
-Matrix::left_multiply(Vector const & v) const
+Matrix::left_multiply (Vector const & v) const
{
- Vector dest(v.dim());
- assert(dat->cols()==v.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dest(i)+= dat->elem(j,i)*v(j);
+ Vector dest (v.dim());
+ assert (dat->cols()==v.dim ());
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dest (i)+= dat->elem (j,i)*v (j);
return dest;
}
Vector
Matrix::operator *(Vector const & v) const
{
- Vector dest(rows());
- assert(dat->cols()==v.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dest(i)+= dat->elem(i,j)*v(j);
+ Vector dest (rows());
+ assert (dat->cols()==v.dim ());
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j))
+ dest (i)+= dat->elem (i,j)*v (j);
return dest;
}
Matrix
operator /(Matrix const& m1,Real a)
{
- Matrix m(m1);
+ Matrix m (m1);
m /= a;
return m;
}
Matrix::transpose() // delegate to storage?
{
#if 1
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) {
+ for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) {
if (i >= j)
continue;
- Real r=dat->elem(i,j);
- dat->elem(i,j) = dat->elem(j,i);
- dat->elem(j,i)=r;
+ Real r=dat->elem (i,j);
+ dat->elem (i,j) = dat->elem (j,i);
+ dat->elem (j,i)=r;
}
#endif
}
Matrix::operator-() const
{
OK();
- Matrix m(*this);
+ Matrix m (*this);
m*=-1.0;
return m;
}
Matrix
Matrix::transposed() const
{
- Matrix m(*this);
+ Matrix m (*this);
m.transpose();
return m;
}
Matrix
operator *(Matrix const &m1, Matrix const &m2)
{
- Matrix result(Matrix_storage::get_product_result(m1.dat, m2.dat));
+ Matrix result (Matrix_storage::get_product_result (m1.dat, m2.dat));
- result.set_product(m1,m2);
+ result.set_product (m1,m2);
return result;
}
void
-Matrix::set_product(Matrix const &m1, Matrix const &m2)
+Matrix::set_product (Matrix const &m1, Matrix const &m2)
{
- assert(m1.cols()==m2.rows());
- assert(cols()==m2.cols() && rows()==m1.rows());
+ assert (m1.cols()==m2.rows ());
+ assert (cols()==m2.cols () && rows ()==m1.rows ());
- if (m1.dat->try_right_multiply(dat, m2.dat))
+ if (m1.dat->try_right_multiply (dat, m2.dat))
return;
- for (int i=0, j=0; dat->mult_ok(i,j);
- dat->mult_next(i,j)) {
+ for (int i=0, j=0; dat->mult_ok (i,j);
+ dat->mult_next (i,j)) {
Real r=0.0;
for (int k = 0; k < m1.cols(); k++)
r += m1(i,k)*m2(k,j);
- dat->elem(i,j)=r;
+ dat->elem (i,j)=r;
}
}
void
-Matrix::insert_row(Vector v, int k)
+Matrix::insert_row (Vector v, int k)
{
int c = cols();
- assert(v.dim()==cols());
- dat->insert_row(k);
+ assert (v.dim()==cols ());
+ dat->insert_row (k);
for (int j=0; j < c; j++)
- dat->elem(k,j)=v(j);
+ dat->elem (k,j)=v (j);
}
void
-Matrix::swap_columns(int c1, int c2)
+Matrix::swap_columns (int c1, int c2)
{
- assert(c1>=0&& c1 < cols()&&c2 < cols() && c2 >=0);
+ assert (c1>=0&& c1 < cols()&&c2 < cols () && c2 >=0);
int r = rows();
for (int i=0; i< r; i++) {
- Real r=dat->elem(i,c1);
- dat->elem(i,c1) = dat->elem(i,c2);
- dat->elem(i,c2)=r;
+ Real r=dat->elem (i,c1);
+ dat->elem (i,c1) = dat->elem (i,c2);
+ dat->elem (i,c2)=r;
}
}
void
-Matrix::swap_rows(int c1, int c2)
+Matrix::swap_rows (int c1, int c2)
{
- assert(c1>=0&& c1 < rows()&&c2 < rows() && c2 >=0);
+ assert (c1>=0&& c1 < rows()&&c2 < rows () && c2 >=0);
int c = cols();
for (int i=0; i< c; i++) {
- Real r=dat->elem(c1,i);
- dat->elem(c1,i) = dat->elem(c2,i);
- dat->elem(c2,i)=r;
+ Real r=dat->elem (c1,i);
+ dat->elem (c1,i) = dat->elem (c2,i);
+ dat->elem (c2,i)=r;
}
}
int
Matrix::dim() const
{
- assert(cols() == rows());
+ assert (cols() == rows ());
return rows();
}
#include "string.hh"
void
-print_rat(Rational const &m)
+print_rat (Rational const &m)
{
- cout << String(m) << flush;
+ cout << String (m) << flush;
}
#include <stdio.h>
#include "scalar.hh"
-Scalar::Scalar(Rational r)
- :String(r)
+Scalar::Scalar (Rational r)
+ :String (r)
{
}
Scalar::operator Rational()
{
- int p = index_i('/');
+ int p = index_i ('/');
if (p == -1)
- return int(*this);
+ return int (*this);
- String s2 = right_str(len()-p-1);
- String s1 = left_str(p);
+ String s2 = right_str (len()-p-1);
+ String s1 = left_str (p);
- return Rational(s1.value_i(), s2.value_i());
+ return Rational (s1.value_i(), s2.value_i ());
}
bool
int conv = false;
if (len()) {
long l =0;
- conv = sscanf(strh_.ch_C(), "%ld", &l);
+ conv = sscanf (strh_.ch_C(), "%ld", &l);
}
return len() && conv;
}
static const int STRING_BUFFER_LEN=1024;
String
-String_convert::bin2hex_str( String bin_str )
+String_convert::bin2hex_str (String bin_str)
{
String str;
Byte const* byte_C = bin_str.byte_C();
- for ( int i = 0; i < bin_str.length_i(); i++ ) {
- str += (char)nibble2hex_byte( *byte_C >> 4 );
- str += (char)nibble2hex_byte( *byte_C++ );
+ for ( int i = 0; i < bin_str.length_i(); i++) {
+ str += (char)nibble2hex_byte (*byte_C >> 4);
+ str += (char)nibble2hex_byte (*byte_C++);
}
return str;
}
int
-String_convert::bin2_i( String bin_str )
+String_convert::bin2_i (String bin_str)
{
- assert( bin_str.length_i() <= 4 );
+ assert (bin_str.length_i() <= 4);
int result_i = 0;
- for ( int i = 0; i < bin_str.length_i(); i++ ) {
+ for ( int i = 0; i < bin_str.length_i(); i++) {
result_i <<= 8;
result_i += (Byte)bin_str[ i ];
}
// breendet imp from String
int
-String_convert::dec2_i( String dec_str )
+String_convert::dec2_i (String dec_str)
{
- if ( !dec_str.length_i() )
+ if ( !dec_str.length_i())
return 0;
long l = 0;
- int conv = sscanf( dec_str.ch_C(), "%ld", &l );
- assert( conv );
+ int conv = sscanf (dec_str.ch_C(), "%ld", &l);
+ assert (conv);
return (int)l;
}
String
-String_convert::i64_str( I64 i64, char const* fmt)
+String_convert::i64_str (I64 i64, char const* fmt)
{
char buffer[STRING_BUFFER_LEN];
- snprintf(buffer, STRING_BUFFER_LEN,
- (fmt ? fmt : "%Ld"), i64 ); // assume radix 10
- return String(buffer);
+ snprintf (buffer, STRING_BUFFER_LEN,
+ (fmt ? fmt : "%Ld"), i64); // assume radix 10
+ return String (buffer);
}
// breendet imp from String
double
-String_convert::dec2_f( String dec_str )
+String_convert::dec2_f (String dec_str)
{
- if ( !dec_str.length_i() )
+ if ( !dec_str.length_i())
return 0;
double d = 0;
- int conv = sscanf( dec_str.ch_C(), "%lf", &d );
- assert( conv );
+ int conv = sscanf (dec_str.ch_C(), "%lf", &d);
+ assert (conv);
return d;
}
int
-String_convert::hex2bin_i( String hex_str, String& bin_str_r )
+String_convert::hex2bin_i (String hex_str, String& bin_str_r)
{
- if ( hex_str.length_i() % 2 )
+ if ( hex_str.length_i() % 2)
hex_str = "0" + hex_str;
bin_str_r = "";
Byte const* byte_C= hex_str.byte_C();
int i = 0;
- while ( i < hex_str.length_i() ) {
- int high_i = hex2nibble_i( *byte_C++ );
- int low_i = hex2nibble_i( *byte_C++ );
- if ( high_i < 0 || low_i < 0 )
+ while ( i < hex_str.length_i()) {
+ int high_i = hex2nibble_i (*byte_C++);
+ int low_i = hex2nibble_i (*byte_C++);
+ if ( high_i < 0 || low_i < 0)
return 1; // illegal char
- bin_str_r += String( (char)( high_i << 4 | low_i ), 1 );
+ bin_str_r += String ((char)( high_i << 4 | low_i), 1 );
i += 2;
}
return 0;
}
String
-String_convert::hex2bin_str( String hex_str )
+String_convert::hex2bin_str (String hex_str)
{
String str;
// silly, asserts should alway be "on"!
-// assert( !hex2bin_i( hex_str, str ) );
- int error_i = hex2bin_i( hex_str, str );
- assert( !error_i );
+// assert (!hex2bin_i (hex_str, str) );
+ int error_i = hex2bin_i (hex_str, str);
+ assert (!error_i);
return str;
}
int
-String_convert::hex2nibble_i( Byte byte )
+String_convert::hex2nibble_i (Byte byte)
{
- if ( byte >= '0' && byte <= '9' )
+ if ( byte >= '0' && byte <= '9')
return byte - '0';
- if ( byte >= 'A' && byte <= 'F' )
+ if ( byte >= 'A' && byte <= 'F')
return byte - 'A' + 10;
if ( byte >= 'a' && byte <= 'f')
return byte - 'a' + 10;
// stupido. Should use int_str()
String
-String_convert::i2dec_str( int i, int length_i, char ch )
+String_convert::i2dec_str (int i, int length_i, char ch)
{
char fill_ch = ch;
if ( fill_ch)
fill_ch = '0';
// ugh
- String dec_str( i );
+ String dec_str (i);
// ugh
- return String( fill_ch, length_i - dec_str.length_i() ) + dec_str;
+ return String (fill_ch, length_i - dec_str.length_i()) + dec_str;
}
// stupido. Should use int_str()
String
-String_convert::u2hex_str( unsigned u, int length_i, char fill_ch )
+String_convert::u2hex_str (unsigned u, int length_i, char fill_ch)
{
String str;
- if ( !u )
+ if ( !u)
str = "0";
#if 1 // both go...
- while ( u ) {
- str = String( (char)( ( u % 16 )["0123456789abcdef"] ) ) + str;
+ while ( u) {
+ str = String ((char)( ( u % 16)["0123456789abcdef"] ) ) + str;
u /= 16;
}
#else
- str += int_str( u, "%x" ); // hmm. %lx vs. %x -> portability?
+ str += int_str (u, "%x"); // hmm. %lx vs. %x -> portability?
#endif
- str = String( fill_ch, length_i - str.length_i() ) + str;
- while ( ( str.length_i() > length_i ) && ( str[ 0 ] == 'f' ) )
- str = str.mid_str( 2, INT_MAX );
+ str = String (fill_ch, length_i - str.length_i()) + str;
+ while ( ( str.length_i() > length_i) && ( str[ 0 ] == 'f' ) )
+ str = str.mid_str (2, INT_MAX);
return str;
}
String
-String_convert::i2hex_str( int i, int length_i, char fill_ch )
+String_convert::i2hex_str (int i, int length_i, char fill_ch)
{
- return u2hex_str( (unsigned)i, length_i, fill_ch );
+ return u2hex_str ((unsigned)i, length_i, fill_ch);
}
Byte
-String_convert::nibble2hex_byte( Byte byte )
+String_convert::nibble2hex_byte (Byte byte)
{
- if ( ( byte & 0x0f ) <= 9 )
- return ( byte & 0x0f ) + '0';
+ if ( ( byte & 0x0f) <= 9 )
+ return ( byte & 0x0f) + '0';
else
- return ( byte & 0x0f ) - 10 + 'a';
+ return ( byte & 0x0f) - 10 + 'a';
}
/**
Convert an integer to a string
#fmt# is a printf style format, default assumes "%d" as format.
*/
String
-String_convert::int_str(int i, char const* fmt)
+String_convert::int_str (int i, char const* fmt)
{
char buffer[STRING_BUFFER_LEN];
- snprintf(buffer, STRING_BUFFER_LEN,
- (fmt ? fmt : "%d"), i ); // assume radix 10
- return String(buffer);
+ snprintf (buffer, STRING_BUFFER_LEN,
+ (fmt ? fmt : "%d"), i); // assume radix 10
+ return String (buffer);
}
/**
@param #fmt# is a printf style format, default assumes "%lf" as format
*/
String
-String_convert::double_str(double f, char const* fmt)
+String_convert::double_str (double f, char const* fmt)
{
char buf[STRING_BUFFER_LEN];
- snprintf(buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f);
- return String(buf);
+ snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f);
+ return String (buf);
}
/**
#n# is a repetition count, default value is 1
*/
String
-String_convert::char_str(char c, int n)
+String_convert::char_str (char c, int n)
{
n = n >= 0 ? n : 0;
char* ch_p = new char[ n ];
- memset( ch_p, c, n );
- String s((Byte*)ch_p, n);
+ memset (ch_p, c, n);
+ String s ((Byte*)ch_p, n);
delete ch_p;
return s;
}
String
-String_convert::rational_str(Rational r)
+String_convert::rational_str (Rational r)
{
- char * n = Itoa(r.numerator()); // LEAK????
+ char * n = Itoa (r.numerator()); // LEAK????
String s = n;
if (r.denominator() != 1) {
- char * d = Itoa(r.denominator());
- s += String( '/' ) + String(d);
+ char * d = Itoa (r.denominator());
+ s += String ('/') + String (d);
//delete d;
}
/* delete n;
}
String
-String_convert::pointer_str(void const *l)
+String_convert::pointer_str (void const *l)
{
char buffer[STRING_BUFFER_LEN];
- snprintf(buffer, STRING_BUFFER_LEN, "%p", l ); // assume radix 10
- return String(buffer);
+ snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10
+ return String (buffer);
}
#include "string-convert.hh"
#ifdef STRING_DEBUG
-void* mymemmove( void* dest, void const* src, size_t n );
+void* mymemmove (void* dest, void const* src, size_t n);
#define memmove mymemmove
#endif
{
Byte const* src = strh_.byte_C();
Byte* dest = new Byte[strh_.length_i() + 1];
- memcpy( dest, src, strh_.length_i() + 1 );
+ memcpy (dest, src, strh_.length_i() + 1);
return dest;
}
void
-String::print_on(ostream& os) const
+String::print_on (ostream& os) const
{
if (!strh_.is_binary_bo())
os << ch_C();
else
- for ( int i = 0; i < length_i(); i++ )
+ for ( int i = 0; i < length_i(); i++)
os << (Byte)(*this)[ i ];
}
\f
copying, constructing.
*/
String&
-String::operator = (String const&source )
+String::operator = (String const&source)
{
strh_ = source.strh_;
return *this;
}
-String::String(Rational r)
+String::String (Rational r)
{
- *this = String_convert::rational_str(r);
+ *this = String_convert::rational_str (r);
}
String::String (double f, char const* fmt)
{
- *this= String_convert::double_str(f,fmt);
+ *this= String_convert::double_str (f,fmt);
}
-String::String( char c, int n )
+String::String (char c, int n)
{
*this = String_convert::char_str (c,n);
}
@see
String_convert::int_str
*/
-String::String(int i, char const * format )
+String::String (int i, char const * format)
{
- *this = String_convert::int_str(i,format);
+ *this = String_convert::int_str (i,format);
}
String::String (bool b)
{
- *this = (char const* ) (b ? "true" : "false");
+ *this = (char const*) (b ? "true" : "false");
}
-String::String( char const* source )
+String::String (char const* source)
{
- assert(source);
+ assert (source);
strh_ = source;
}
-String::String( Byte const* byte_l, int length_i )
+String::String (Byte const* byte_l, int length_i)
{
- strh_.set( byte_l, length_i );
+ strh_.set (byte_l, length_i);
}
\f
void
-String::append(String s)
+String::append (String s)
{
- strh_.append( s.byte_C(), s.length_i() );
+ strh_.append (s.byte_C(), s.length_i());
}
void
String::operator +=(String s)
{
- append(s);
+ append (s);
}
void
-String::prepend(String s)
+String::prepend (String s)
{
s += *this;
*this = s;
Do a signed comparison, analogous to memcmp;
*/
int
-String::compare_i(String const& s1, String const& s2 )
+String::compare_i (String const& s1, String const& s2)
{
Byte const* p1 = s1.byte_C();
Byte const* p2 = s2.byte_C();
- if ( p1 == p2 )
+ if ( p1 == p2)
return 0;
int i1 = s1.length_i();
int i2 = s2.length_i();
- int result= memcmp( p1, p2, i1 <? i2 );
+ int result= memcmp (p1, p2, i1 <? i2);
return result ? result : i1-i2;
}
\f
int
-String::index_last_i( char const c ) const
+String::index_last_i (char const c) const
{
- if ( !length_i() )
+ if ( !length_i())
return -1;
char const* me = strh_.ch_C();
- char const* p = memrchr(me, length_i(), c );
- if ( p )
+ char const* p = memrchr (me, length_i(), c);
+ if ( p)
return p - me;
return -1;
}
int
-String::index_last_i( char const* string ) const // UGK!
+String::index_last_i (char const* string) const // UGK!
{
- assert(false); // broken
- int length = strlen( string ); // ugrh
- if ( !length_i() || !length )
+ assert (false); // broken
+ int length = strlen (string); // ugrh
+ if ( !length_i() || !length)
return -1;
- int next_i = index_i( string );
- if ( next_i == -1 )
+ int next_i = index_i (string);
+ if ( next_i == -1)
return -1;
int index_i = 0;
- while( next_i >= 0 ) {
+ while (next_i >= 0) {
index_i += next_i;
- next_i = right_str( length_i() - index_i - length ).index_i( string );
+ next_i = right_str (length_i() - index_i - length).index_i (string );
}
return index_i;
}
the index of the leftmost character #c# (0 <= return < length_i()),
or -1 if not found.
- ? should return length_i()?, as in string.left_str(index_i(delimiter))
+ ? should return length_i()?, as in string.left_str (index_i (delimiter))
*/
int
-String::index_i(char c ) const
+String::index_i (char c) const
{
char const* me = strh_.ch_C();
- char const* p = (char const *) memchr( me,c, length_i());
- if ( p )
+ char const* p = (char const *) memchr (me,c, length_i());
+ if ( p)
return p - me;
return -1;
}
index of leftmost occurrence of #searchfor#
*/
int
-String::index_i( String searchfor ) const
+String::index_i (String searchfor) const
{
char const* me = strh_.ch_C();
- char const* p = (char const *) memmem(
- me, length_i(), searchfor.ch_C(), searchfor.length_i());
+ char const* p = (char const *) memmem (
+ me, length_i(), searchfor.ch_C(), searchfor.length_i ());
- if ( p )
+ if ( p)
return p - me;
else
return -1;
the index of the leftmost occurance of an element of #set#
*/
int
-String::index_any_i( String set ) const
+String::index_any_i (String set) const
{
int n = length_i();
- if ( !n )
+ if ( !n)
return -1;
void const * me_l = (void const *) strh_.ch_C();
for (int i=0; i < set.length_i(); i++) {
- char * found=(char*) memchr(me_l, set[i], n );
+ char * found=(char*) memchr (me_l, set[i], n );
if (found) {
return found - me_l;
}
}
\f
String
-String::left_str( int n ) const
+String::left_str (int n) const
{
if (n >= length_i())
return *this;
return retval;
retval = *this;
- retval.strh_.trunc(n);
+ retval.strh_.trunc (n);
return retval;
}
String
-String::right_str( int n ) const
+String::right_str (int n) const
{
if (n > length_i())
return *this;
if ( n < 1)
return "";
- return String( strh_.byte_C() + length_i() - n, n );
+ return String (strh_.byte_C() + length_i() - n, n);
}
String
-String::nomid_str( int index_i, int n ) const
+String::nomid_str (int index_i, int n) const
{
- if ( index_i < 0 ) {
+ if ( index_i < 0) {
n += index_i;
index_i = 0;
}
return *this;
return
- left_str( index_i ) +
- right_str( length_i() - index_i - n ) ;
+ left_str (index_i) +
+ right_str (length_i() - index_i - n) ;
}
/*
proposal: change to "cut()"
*/
String
-String::mid_str( int index_i, int n ) const
+String::mid_str (int index_i, int n) const
{
if (index_i <0) {
n += index_i;
index_i=0;
}
- if ( !length_i() || ( index_i < 0 ) || ( index_i >= length_i() ) || ( n < 1 ) )
+ if ( !length_i() || ( index_i < 0) || ( index_i >= length_i () ) || ( n < 1 ) )
return String();
- if ( ( n > length_i() ) || ( index_i + n > length_i() ) )
+ if ( ( n > length_i()) || ( index_i + n > length_i () ) )
n = length_i() - index_i;
- return String( byte_C() + index_i, n );
+ return String (byte_C() + index_i, n);
}
\f
String
String::to_upper()
{
char *s = (char*)strh_.byte_l();
- strnupr( s ,length_i());
+ strnupr (s ,length_i());
}
void
String::to_lower()
{
char* s = strh_.ch_l();
- strnlwr(s,length_i());
+ strnlwr (s,length_i());
}
String::reversed_str() const
{
String str = *this;
- strrev( str.byte_l(), str.length_i() );
+ strrev (str.byte_l(), str.length_i ());
return str;
}
int
String::value_i() const
{
- return String_convert::dec2_i( *this );
+ return String_convert::dec2_i (*this);
}
double
String::value_f() const
{
- return String_convert::dec2_f( *this );
+ return String_convert::dec2_f (*this);
}
{
cout << "constructors"<<endl;
- String str( "hai" );
+ String str ("hai");
String def;
- String fromi(10);
- String fromc('c');
- String fromf(1.32e-2, "%g");
+ String fromi (10);
+ String fromc ('c');
+ String fromf (1.32e-2, "%g");
cout << str << endl;
cout << def << endl;
cmp()
{
Array<String> a;
- a.push("abcd");
- a.push("zxy");
- a.push("abc");
- a.push("");
- a.sort(String::compare_i);
+ a.push ("abcd");
+ a.push ("zxy");
+ a.push ("abc");
+ a.push ("");
+ a.sort (String::compare_i);
cout << "compares: "<<endl;
for (int i=0; i < a.size(); i++)
cout << a[i] << endl;
String cstr =c;
String set = "bar";
cout << "hay = \"" << hay << "\" len="<< hay.length_i()<<endl;
- cout << "index_i('"<< c<<"') " << c << "= " << hay.index_i(c) <<endl;
- cout << "last_index_i('"<< c<<"') " << c << "= " << hay.index_last_i(c) <<endl;
-// cout << "last index of cstr " << c << ": " << hay.index_last_i(cstr) <<endl;
-// cout << "index_last_i(\""<<set<<"\"): " << hay.index_last_i(set) <<endl;
- cout << "index_i(\""<<set<<"\"): " << hay.index_i(set) <<endl;
- cout << "index_any(\"" << set << "\"): " << cstr << ": " << hay.index_any_i(cstr) <<endl;
+ cout << "index_i ('"<< c<<"') " << c << "= " << hay.index_i (c) <<endl;
+ cout << "last_index_i ('"<< c<<"') " << c << "= " << hay.index_last_i (c) <<endl;
+// cout << "last index of cstr " << c << ": " << hay.index_last_i (cstr) <<endl;
+// cout << "index_last_i (\""<<set<<"\"): " << hay.index_last_i (set) <<endl;
+ cout << "index_i (\""<<set<<"\"): " << hay.index_i (set) <<endl;
+ cout << "index_any (\"" << set << "\"): " << cstr << ": " << hay.index_any_i (cstr) <<endl;
void
kutenpeer()
{
- String str( "hai" );
+ String str ("hai");
for (int i=-1; i < str.length_i()+2; i++) {
- cout<<" left_str(" << i<<"): " << str.left_str( i ) << endl;
- cout<<" right_str( "<<i<<"): " << str.right_str( i ) << endl;
+ cout<<" left_str (" << i<<"): " << str.left_str (i) << endl;
+ cout<<" right_str ("<<i<<"): " << str.right_str (i) << endl;
}
str = "blonde haren";
cout << str<<endl;
- cout << "mid(2,6)="<<str.mid_str(2,3)<<endl;
- cout << "nomid(2,6)="<<str.nomid_str(2,3)<<endl;
+ cout << "mid (2,6)="<<str.mid_str (2,3)<<endl;
+ cout << "nomid (2,6)="<<str.nomid_str (2,3)<<endl;
}
int
cmp();
searching();
kutenpeer();
- String str( "hai" );
+ String str ("hai");
cout << str << endl;
cout << "left" << endl;
str += " daar";
cout << str << endl;
- str = String( "Hallo" ) + " daaR" + '!';
+ str = String ("Hallo") + " daaR" + '!';
cout << str << endl;
- cout << "up: " << str.upper_str() << " down: " << str.lower_str()<<endl;
+ cout << "up: " << str.upper_str() << " down: " << str.lower_str ()<<endl;
- if ( str == String( "" ) )
+ if ( str == String ("") )
cout << str << " is empty" << endl;
else
cout << str << " is not empty"<<endl;
String fn = "";
- if ( fn == "" )
+ if ( fn == "")
cout << fn << " is empty" << endl;
else
- assert(false);
+ assert (false);
fn = "";
fn += "";
delete fn.copy_byte_p();
delete str.copy_byte_p();
- cout << String_convert::bin2hex_str( String( (char)0xff ) ) << endl;
+ cout << String_convert::bin2hex_str (String ((char)0xff) ) << endl;
}
#endif STRING_TEST
#include <sys/types.h>
#include <memory.h>
void*
-mymemmove( void* dest, void const* src, size_t n )
+mymemmove (void* dest, void const* src, size_t n)
{
- return memcpy( dest, src, n ); // wohltempererit: 69006
+ return memcpy (dest, src, n); // wohltempererit: 69006
}
#define memmove mymemmove
#endif
while (1) {
String s;
Array<String> fields;
- assert(!eof());
+ assert (!eof());
while ((s = get_word()) != "")
{
- fields.push(s);
+ fields.push (s);
gobble_white();
}
if (get_line() != "")
- assert(false);
+ assert (false);
assert (fields.size());
- return Text_record(fields, get_name(), line());
+ return Text_record (fields, get_name(), line ());
}
}
#include "text-stream.hh"
-Text_stream::Text_stream(String fn)
+Text_stream::Text_stream (String fn)
{
ios::sync_with_stdio();
if (fn == "")
else
{
name = fn;
- f = fopen(fn, "r");
+ f = fopen (fn, "r");
}
if (!f) {
cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n";
- exit(1);
+ exit (1);
}
line_no = 1;
}
void
-Text_stream::message(String s)
+Text_stream::message (String s)
{
- cerr << "\n"<<get_name() << ": " << line()<<": "<<s<<endl;
+ cerr << "\n"<<get_name() << ": " << line ()<<": "<<s<<endl;
}
see a book on data structures
*/
-Union_find::Union_find(int n)
+Union_find::Union_find (int n)
{
- classes.set_size(n);
+ classes.set_size (n);
for (int i=0; i < n; i++) {
classes[i] = i;
}
int
-Union_find::find(int i)
+Union_find::find (int i)
{
int rep = i;
while (classes[rep] != rep)
}
void
-Union_find::connect(int i, int j)
+Union_find::connect (int i, int j)
{
- i = find(i);
- j = find(j);
+ i = find (i);
+ j = find (j);
classes[i] = j;
}
#include "vector.hh"
-Vector::Vector(Array<Real> d)
- : dat(d)
+Vector::Vector (Array<Real> d)
+ : dat (d)
{
}
-Vector::Vector(Vector const &n)
- : dat(n.dat)
+Vector::Vector (Vector const &n)
+ : dat (n.dat)
{
}
Vector
Vector::operator-() const
{
- Vector v(*this);
+ Vector v (*this);
v*=-1;
return v;
}
void
-Vector::set_unit(int j)
+Vector::set_unit (int j)
{
- fill(0.0);
+ fill (0.0);
dat[j] = 1.0;
}
class Audio_column {
public:
- Audio_column( Moment at_mom );
+ Audio_column (Moment at_mom);
- void add( Audio_item* i_l );
+ void add (Audio_item* i_l);
Moment at_mom() const;
void print() const;
Audio_score * audio_score_l_;
private:
- Audio_column( Audio_column const& );
+ Audio_column (Audio_column const&);
Moment at_mom_;
};
virtual CSound_item* score_item_p() = 0;
*/
struct Audio_item : public Audio_element {
- Audio_item( Request* req_l );
+ Audio_item (Request* req_l);
/// Create a midi-item from myself.
virtual Midi_item* midi_item_p() = 0;
DECLARE_MY_RUNTIME_TYPEINFO;
private:
- Audio_item( Audio_item const& );
- Audio_item& operator=( Audio_item const& );
+ Audio_item (Audio_item const&);
+ Audio_item& operator=( Audio_item const&);
};
struct Audio_key : public Audio_item {
- Audio_key( Request* req_l );
+ Audio_key (Request* req_l);
virtual Midi_item* midi_item_p();
};
struct Audio_instrument : public Audio_item {
- Audio_instrument( String instrument_str );
+ Audio_instrument (String instrument_str);
virtual Midi_item* midi_item_p();
String str_;
};
struct Audio_note : public Audio_item {
- Audio_note( Request* req_l );
+ Audio_note (Request* req_l);
virtual Midi_item* midi_item_p();
};
MARKER, CUE_POINT
};
- Audio_text( Audio_text::Type type, String text_str );
+ Audio_text (Audio_text::Type type, String text_str);
virtual Midi_item* midi_item_p();
Type type_;
};
struct Audio_tempo : Audio_item {
- Audio_tempo( int per_minute_4_i );
+ Audio_tempo (int per_minute_4_i);
virtual Midi_item* midi_item_p();
int per_minute_4_i_;
};
struct Audio_meter : Audio_item {
- Audio_meter( Request* req_l );
+ Audio_meter (Request* req_l);
virtual Midi_item* midi_item_p();
};
class Audio_score {
public:
- Audio_score( Score* l );
+ Audio_score (Score* l);
- void add( Audio_column* );
- void add_staff( Audio_staff* l );
- void add(Audio_element*p);
+ void add (Audio_column*);
+ void add_staff (Audio_staff* l);
+ void add (Audio_element*p);
- void output( Midi_stream& midi_stream_r );
- void output_header_track( Midi_stream& midi_stream_r );
+ void output (Midi_stream& midi_stream_r);
+ void output_header_track (Midi_stream& midi_stream_r);
void print() const;
void process();
#include "audio-element.hh"
struct Audio_staff : public Audio_element {
- void add( Audio_item* l);
- void output( Midi_stream& midi_stream_r, int track_i );
+ void add (Audio_item* l);
+ void output (Midi_stream& midi_stream_r, int track_i);
Link_list<Audio_item*> audio_item_l_list_;
DECLARE_MY_RUNTIME_TYPEINFO;
class String;
-String axis_name_str(Axis);
+String axis_name_str (Axis);
#endif // AXES_HH
struct Axis_group_administration {
Link_array<Score_elem> elem_l_arr_;
- Interval extent(Axis)const;
+ Interval extent (Axis)const;
void print() const ;
- Axis_group_administration(Axis_group_administration const&);
+ Axis_group_administration (Axis_group_administration const&);
Axis_group_administration(){}
- void remove_all(Axis a1,Axis a2);
+ void remove_all (Axis a1,Axis a2);
- bool contains_b(Score_elem const *)const;
- void add_element(Score_elem*, Axis_group_element*, Axis a1, Axis a2);
- void remove_element(Score_elem*, Axis a1, Axis a2);
+ bool contains_b (Score_elem const *)const;
+ void add_element (Score_elem*, Axis_group_element*, Axis a1, Axis a2);
+ void remove_element (Score_elem*, Axis a1, Axis a2);
};
/**
public:
virtual void remove_all()=0;
- virtual void add_element(Score_elem*)=0;
- virtual void remove_element(Score_elem*)=0;
- virtual bool contains_b(Score_elem const *)const;
+ virtual void add_element (Score_elem*)=0;
+ virtual void remove_element (Score_elem*)=0;
+ virtual bool contains_b (Score_elem const *)const;
DECLARE_MY_RUNTIME_TYPEINFO;
};
#endif // Axis_group_administration_HH
Bar *bar_l_;
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
public:
public:
Bar_column();
- void set_bar( Bar*);
+ void set_bar (Bar*);
protected:
SCORE_ELEM_CLONE(Bar_column);
- void do_substitute_dependency(Score_elem*,Score_elem*);
+ void do_substitute_dependency (Score_elem*,Score_elem*);
DECLARE_MY_RUNTIME_TYPEINFO;
};
protected:
- virtual bool do_try_request(Request *req_l);
+ virtual bool do_try_request (Request *req_l);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
int number_i_;
protected:
- void acknowledge_element(Score_elem_info);
+ void acknowledge_element (Score_elem_info);
void do_pre_move_processing();
public:
Bar_number_grav();
/* *************** */
DECLARE_MY_RUNTIME_TYPEINFO;
Beam();
- void add(Stem*);
+ void add (Stem*);
- void set_grouping(Rhythmic_grouping def, Rhythmic_grouping current);
+ void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
void set_stemlens();
SCORE_ELEM_CLONE(Beam);
protected:
virtual void set_default_dir();
virtual void do_pre_processing();
virtual void do_post_processing();
- virtual void do_substitute_dependent(Score_elem*, Score_elem*);
+ virtual void do_substitute_dependent (Score_elem*, Score_elem*);
virtual void do_print() const;
private:
- Molecule stem_beams(Stem *here, Stem *next, Stem *prev)const;
+ Molecule stem_beams (Stem *here, Stem *next, Stem *prev)const;
void solve_slope();
Molecule*brew_molecule_p()const;
};
Interval &y(){ return interval_a_[Y_AXIS]; }
Interval x()const{ return interval_a_[X_AXIS]; }
Interval y()const{return interval_a_[Y_AXIS]; }
- Interval operator[](Axis a ) {
+ Interval operator[](Axis a) {
return interval_a_[a];
}
- void translate(Offset o) {
- x().translate(o.x());
- y().translate(o.y());
+ void translate (Offset o) {
+ x().translate (o.x ());
+ y().translate (o.y ());
}
/// smallest box enclosing #b#
- void unite(Box b) {
- x().unite(b.x());
- y().unite(b.y());
+ void unite (Box b) {
+ x().unite (b.x ());
+ y().unite (b.y ());
}
Box();
- Box(Interval ix, Interval iy);
+ Box (Interval ix, Interval iy);
};
int cols_i_;
Col_stats();
- void add(Line_of_cols const&l);
+ void add (Line_of_cols const&l);
String str()const;
};
/// helper: solve for the columns in #curline#.
- void solve_line(Col_hpositions*) const;
+ void solve_line (Col_hpositions*) const;
/// helper: approximate the energyv
- void approximate_solve_line(Col_hpositions*) const;
+ void approximate_solve_line (Col_hpositions*) const;
/// does curline fit on the paper?
- bool feasible(Line_of_cols)const;
+ bool feasible (Line_of_cols)const;
- Line_spacer* generate_spacing_problem(Line_of_cols)const;
+ Line_spacer* generate_spacing_problem (Line_of_cols)const;
virtual Array<Col_hpositions> do_solve()const=0;
void print_stats()const;
Line_spacer* (*get_line_spacer)();
Break_algorithm();
- void set_pscore(Paper_score*);
+ void set_pscore (Paper_score*);
/// check if the spacing/breaking problem is well-stated
void problem_OK()const;
Clef_item *clef_p_;
Clef_change_req * clef_req_l_;
void create_clef();
- void read_req(Clef_change_req*);
- bool set_type(String);
+ void read_req (Clef_change_req*);
+ bool set_type (String);
protected:
virtual void do_process_requests();
- virtual void fill_staff_info(Staff_info&);
+ virtual void fill_staff_info (Staff_info&);
virtual void do_pre_move_processing();
virtual void do_removal_processing();
virtual void do_creation_processing();
virtual void do_post_move_processing();
- virtual bool do_try_request(Request*);
- virtual void acknowledge_element(Score_elem_info);
+ virtual bool do_try_request (Request*);
+ virtual void acknowledge_element (Score_elem_info);
public:
int c0_position_i_;
String clef_type_str_;
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Clef_item);
Clef_item();
- void read(Clef_engraver const&);
- void read(String);
+ void read (Clef_engraver const&);
+ void read (String);
};
#endif // CLEFITEM_HH
bool ugh_b_;
/* *************** */
Colinfo();
- Colinfo(PCol *,Real const *);
+ Colinfo (PCol *,Real const *);
void print() const;
bool fixed() const { return fixpos_p_.get_C();}
constraints. should always work */
void stupid_solution();
Col_hpositions();
- void add( PCol*c);
+ void add (PCol*c);
void print() const;
};
Collision* col_p_;
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
public:
Collision_engraver();
*/
class Collision : public Horizontal_vertical_group_item {
protected:
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void do_pre_processing();
public:
Link_array<Note_column> clash_l_arr_;
Tempo_req();
REQUESTMETHODS(Tempo_req, tempo);
- bool do_equal_b(Request *)const;
+ bool do_equal_b (Request *)const;
};
class Partial_measure_req : public Timing_req {
public:
Moment duration_;
- Partial_measure_req(Moment);
+ Partial_measure_req (Moment);
REQUESTMETHODS(Partial_measure_req, partial);
- bool do_equal_b(Request*)const;
+ bool do_equal_b (Request*)const;
};
/**
int beats_i_, one_beat_i_;
Meter_change_req();
- void set(int,int);
- bool do_equal_b(Request*)const;
+ void set (int,int);
+ bool do_equal_b (Request*)const;
REQUESTMETHODS(Meter_change_req, meterchange);
};
public:
/// turn on?
bool on_b_;
- bool do_equal_b(Request*)const;
- Cadenza_req(bool);
+ bool do_equal_b (Request*)const;
+ Cadenza_req (bool);
REQUESTMETHODS(Cadenza_req,cadenza);
};
/// check if we're at start of a measure.
class Barcheck_req : public Timing_req {
public:
- bool do_equal_b(Request *)const;
+ bool do_equal_b (Request *)const;
REQUESTMETHODS(Barcheck_req,barcheck);
};
public:
Array<int> beat_i_arr_;
Array<Moment> elt_length_arr_;
- bool do_equal_b(Request *)const;
+ bool do_equal_b (Request *)const;
REQUESTMETHODS(Measure_grouping_req, measuregrouping);
};
class Bar_req : public Command_req {
public:
String type_str_;
- Bar_req(String);
- bool do_equal_b(Request*)const;
+ Bar_req (String);
+ bool do_equal_b (Request*)const;
REQUESTMETHODS(Bar_req,bar);
};
/// don't ignore the octaves in #melodic_p_arr_#?
bool multi_octave_b_;
Key_change_req();
- Key_change_req(Key_change_req const&);
+ Key_change_req (Key_change_req const&);
~Key_change_req();
REQUESTMETHODS(Key_change_req, keychange);
/// return number of sharps in key
int sharps_i();
- void transpose(Melodic_req const & d) const;
+ void transpose (Melodic_req const & d) const;
/// is minor key?
int minor_b();
};
class Clef_change_req : public Command_req {
public:
String clef_str_;
- Clef_change_req(String);
+ Clef_change_req (String);
REQUESTMETHODS(Clef_change_req, clefchange);
};
#define CM *CM_TO_PT
#define INCH *INCH_TO_PT
-Real parse_dimen(String);
-String print_dimen(Real);
-Real convert_dimen(Real, String);
+Real parse_dimen (String);
+String print_dimen (Real);
+Real convert_dimen (Real, String);
#endif
~Dynamic_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual void acknowledge_element(Score_elem_info);
- virtual bool do_try_request(Request *req_l);
+ virtual void acknowledge_element (Score_elem_info);
+ virtual bool do_try_request (Request *req_l);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
- virtual void set_feature(Feature);
+ virtual void set_feature (Feature);
};
#endif // DYNAMIC_GRAV_HH
class Horizontal_vertical_group_item : public Axis_group_item, public Horizontal_vertical_group_element {
protected:
virtual void do_print() const;
- virtual void remove_all() { Horizontal_vertical_group_element::remove_all(); }
+ virtual void remove_all() { Horizontal_vertical_group_element::remove_all (); }
public:
- virtual void add_element(Score_elem*e) { Horizontal_vertical_group_element::add_element(e); }
- virtual void remove_element(Score_elem*e) { Horizontal_vertical_group_element::remove_element(e); }
+ virtual void add_element (Score_elem*e) { Horizontal_vertical_group_element::add_element (e); }
+ virtual void remove_element (Score_elem*e) { Horizontal_vertical_group_element::remove_element (e); }
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Horizontal_vertical_group_item);
public:
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual void add_element(Score_elem*);
- virtual void remove_element(Score_elem*);
+ virtual void add_element (Score_elem*);
+ virtual void remove_element (Score_elem*);
};
/**
virtual void remove_all();
public:
- virtual void add_element(Score_elem*);
- virtual void remove_element(Score_elem*);
+ virtual void add_element (Score_elem*);
+ virtual void remove_element (Score_elem*);
DECLARE_MY_RUNTIME_TYPEINFO;
};
protected:
virtual void remove_all();
public:
- virtual void add_element(Score_elem*);
- virtual void remove_element(Score_elem*);
+ virtual void add_element (Score_elem*);
+ virtual void remove_element (Score_elem*);
DECLARE_MY_RUNTIME_TYPEINFO;
};
virtual void do_print()const;
virtual bool removable_b()const;
public:
- Engraver*get_simple_engraver(char const*typeinfo)const;
+ Engraver*get_simple_engraver (char const*typeinfo)const;
virtual void print() const ;
Input_translator * itrans_l_;
Pre:
#grav_l# is in #grav_list_#
*/
- virtual void terminate_engraver(Engraver * grav_l);
+ virtual void terminate_engraver (Engraver * grav_l);
DECLARE_MY_RUNTIME_TYPEINFO;
/**
Remove #grav_l# from the list, and return it.
*/
- virtual Engraver * remove_engraver_p(Engraver*grav_l);
- virtual void set_feature(Feature i);
+ virtual Engraver * remove_engraver_p (Engraver*grav_l);
+ virtual void set_feature (Feature i);
virtual void sync_features();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
virtual void do_removal_processing();
- virtual bool do_try_request(Request*);
- virtual bool try_request(Request*);
+ virtual bool do_try_request (Request*);
+ virtual bool try_request (Request*);
virtual void do_process_requests();
virtual Staff_info get_staff_info()const;
- virtual Engraver_group_engraver * find_engraver_l(String name,String id);
+ virtual Engraver_group_engraver * find_engraver_l (String name,String id);
virtual void do_announces();
- virtual void announce_element(Score_elem_info);
- virtual void add(Engraver* grav_p);
- virtual bool contains_b(Engraver*)const;
+ virtual void announce_element (Score_elem_info);
+ virtual void add (Engraver* grav_p);
+ virtual bool contains_b (Engraver*)const;
- virtual Translator* find_get_translator_l(String name, String id);
+ virtual Translator* find_get_translator_l (String name, String id);
virtual Translator * get_default_interpreter();
/**
Go up in the tree. default: choose next parent
*/
- Translator * ancestor_l(int l=1);
+ Translator * ancestor_l (int l=1);
int depth_i() const;
};
/**
You cannot copy a Engraver
*/
- Engraver(const Engraver&){}
+ Engraver (const Engraver&){}
enum {
VIRGIN,
virtual void do_post_move_processing(){}
- virtual void do_creation_processing () {}
+ virtual void do_creation_processing() {}
virtual void do_removal_processing() {}
/**
Invoke walker method to typeset element. Default: pass on to daddy.
*/
- virtual void typeset_element(Score_elem*elem_p);
+ virtual void typeset_element (Score_elem*elem_p);
/**
take note of item/spanner
Default: ignore the info
*/
- virtual void acknowledge_element(Score_elem_info) {}
+ virtual void acknowledge_element (Score_elem_info) {}
/**
Announce element. Default: pass on to daddy. Utility
*/
- virtual void announce_element(Score_elem_info);
+ virtual void announce_element (Score_elem_info);
/**
- Set Feature of the engraver(s). Default: ignore Feature.
+ Set Feature of the engraver (s). Default: ignore Feature.
*/
- virtual void set_feature(Feature){}
+ virtual void set_feature (Feature){}
/**
ask daddy for a feature
*/
- virtual Scalar get_feature(String type_str);
+ virtual Scalar get_feature (String type_str);
/**
Does this equal or contain a certain engraver?
*/
virtual void sync_features() {}
- virtual bool contains_b(Engraver*grav_l)const;
+ virtual bool contains_b (Engraver*grav_l)const;
/**
Get information on the staff. Default: ask daddy.
*/
virtual Staff_info get_staff_info()const;
- virtual void fill_staff_info(Staff_info&);
+ virtual void fill_staff_info (Staff_info&);
virtual void do_print()const;
@see{try_request}
Default: always return false
*/
- virtual bool do_try_request(Request *req_l);
+ virtual bool do_try_request (Request *req_l);
public:
void pre_move_processing();
void process_requests();
true: request swallowed. Don't try to put the request elsewhere.
*/
- bool try_request(Request*);
+ bool try_request (Request*);
bool is_bottom_engraver() const;
void post_move_processing();
*/
#define ADD_THIS_ENGRAVER(c) \
struct c ## init { \
- static Engraver * globalctor (){ \
+ static Engraver * globalctor(){ \
return new c; \
} \
- c ## init () { \
- add_engraver(c::static_name(), globalctor); \
+ c ## init() { \
+ add_engraver (c::static_name(), globalctor); \
\
} \
} _ ## c ## init;
typedef Engraver*(*Grav_ctor)(void);
-void add_engraver(String s, Grav_ctor f);
+void add_engraver (String s, Grav_ctor f);
#endif // ENGRAVER_HH
virtual int rel_stem_dir_i()const;
virtual int priority_i()const;
virtual bool inside_b()const;
- virtual Atom get_atom(Paper_def* p, int dir_i_)const;
- bool equal_b(General_script_def const&)const;
+ virtual Atom get_atom (Paper_def* p, int dir_i_)const;
+ bool equal_b (General_script_def const&)const;
virtual ~General_script_def() {}
protected:
- virtual bool do_equal_b(General_script_def const *)const;
+ virtual bool do_equal_b (General_script_def const *)const;
virtual void do_print()const;
};
/**
A macro to automate administration of performers
*/
-#define ADD_THIS_PERFORMER( c ) \
+#define ADD_THIS_PERFORMER( c) \
struct c ## init { \
- static Performer* globalctor () \
+ static Performer* globalctor() \
{ \
return new c;\
} \
- c ## init () \
+ c ## init() \
{ \
- add_Performer( c::static_name(), globalctor ); \
+ add_Performer (c::static_name(), globalctor); \
} \
} _ ## c ## init;
// typedef Performer*(*Perf_ctor)(void); c++ ?
typedef Performer*(*Perf_ctor)();
-void add_Performer(String s, Perf_ctor f);
+void add_Performer (String s, Perf_ctor f);
#endif // GLOBAL_PERFORMER_HH
Global_translator();
int moments_left_i()const;
- void modify_next(Moment&);
- void add_moment_to_process(Moment);
+ void modify_next (Moment&);
+ void add_moment_to_process (Moment);
- virtual void set_score(Score*);
- virtual void prepare(Moment);
+ virtual void set_score (Score*);
+ virtual void prepare (Moment);
virtual void process() {}
virtual void finish() {}
virtual void start() {}
virtual Global_translator *global_l() { return this; }
virtual int depth_i() const;
- virtual Translator *ancestor_l(int);
+ virtual Translator *ancestor_l (int);
};
Array<MInterval> intervals();
MInterval interval()const;
Moment length() const;
- void intersect(MInterval);
+ void intersect (MInterval);
void operator=(Rhythmic_grouping const&);
- Rhythmic_grouping(Rhythmic_grouping const&);
- Rhythmic_grouping(MInterval, int n=1);
+ Rhythmic_grouping (Rhythmic_grouping const&);
+ Rhythmic_grouping (MInterval, int n=1);
Rhythmic_grouping();
- Rhythmic_grouping(Array<Rhythmic_grouping*>);
+ Rhythmic_grouping (Array<Rhythmic_grouping*>);
~Rhythmic_grouping();
- void add_child(Moment start, Moment len);
- bool child_fit_b(Moment start);
- void split(Rhythmic_grouping r);
- void split(Array<MInterval>);
- void split(int n);
+ void add_child (Moment start, Moment len);
+ bool child_fit_b (Moment start);
+ void split (Rhythmic_grouping r);
+ void split (Array<MInterval>);
+ void split (int n);
void print() const;
void OK() const;
- Array<int> generate_beams(Array<int>, int&);
+ Array<int> generate_beams (Array<int>, int&);
/** multiply self to span #i#.
In implementation, this isn't really const, but conceptually it is.
*/
- void extend(MInterval i) const;
- void translate(Moment);
+ void extend (MInterval i) const;
+ void translate (Moment);
private:
void init();
void junk();
- void copy(Rhythmic_grouping const&);
+ void copy (Rhythmic_grouping const&);
};
-Rhythmic_grouping parse_grouping(Array<int> beat_i_arr, Array<Moment> elt_length_arr);
+Rhythmic_grouping parse_grouping (Array<int> beat_i_arr, Array<Moment> elt_length_arr);
#endif
int dir_i_;
Stem* stem_l_;
- void add(Note_head*);
- virtual void add(Script*s);
- virtual void set(Stem*);
+ void add (Note_head*);
+ virtual void add (Script*s);
+ virtual void set (Stem*);
Head_column();
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
virtual void do_pre_processing();
virtual void do_print()const;
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
};
#endif // HEAD_COLUMN_HH
Note_head_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual bool do_try_request(Request *req_l) ;
+ virtual bool do_try_request (Request *req_l) ;
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
- TODO: insert(order, elem)
+ TODO: insert (order, elem)
*/
class Horizontal_align_item : public Item {
protected:
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Horizontal_align_item);
- void add(Item*, int p);
+ void add (Item*, int p);
void OK()const;
Horizontal_align_item();
protected:
- virtual void do_substitute_dependency(Score_elem * , Score_elem *);
+ virtual void do_substitute_dependency (Score_elem * , Score_elem *);
/// do calculations before determining horizontal spacing
virtual void do_pre_processing();
virtual void do_print()const;
virtual Interval do_width()const;
- bool contains_b(Item*)const;
+ bool contains_b (Item*)const;
};
#endif // HORIZONTAL_ALIGN_ITEM_HH
class Horizontal_group_item : public Axis_group_item, public Horizontal_group_element {
protected:
- virtual void remove_all() { Horizontal_group_element::remove_all(); }
+ virtual void remove_all() { Horizontal_group_element::remove_all (); }
virtual void do_print() const;
public:
- virtual void add_element(Score_elem*e) { Horizontal_group_element::add_element(e); }
- virtual void remove_element(Score_elem*e) { Horizontal_group_element::remove_element(e); }
+ virtual void add_element (Score_elem*e) { Horizontal_group_element::add_element (e); }
+ virtual void remove_element (Score_elem*e) { Horizontal_group_element::remove_element (e); }
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Horizontal_group_item);
/**
use a KKT method to assert optimality of sol
*/
- void assert_solution(Vector sol) const;
+ void assert_solution (Vector sol) const;
/// solve the problem using a projected gradient method
- Vector constraint_solve(Vector)const;
+ Vector constraint_solve (Vector)const;
/**
Solve it. First try it the easy way.
*/
- Vector solve(Vector start) const;
+ Vector solve (Vector start) const;
/**
@return the number of variables in the problem
c*vars >= r
PRE
- c.dim() == dim();
+ c.dim() == dim ();
*/
- void add_inequality_cons(Vector c, double r);
+ void add_inequality_cons (Vector c, double r);
/** set up matrices to go with the problem. */
- Ineq_constrained_qp(int novars);
+ Ineq_constrained_qp (int novars);
/**
evaluate the quadratic function for input #v#
*/
- Real eval(Vector v);
+ Real eval (Vector v);
- void eliminate_var(int idx, Real value);
+ void eliminate_var (int idx, Real value);
void OK()const;
void print() const;
struct Input_translator_list : public Pointer_list<Input_translator*>
{
- Input_translator_list(Input_translator_list const &);
+ Input_translator_list (Input_translator_list const &);
Input_translator_list(){}
~Input_translator_list(){}
};
String type_str_;
String default_id_str_;
- void add(Input_translator *);
- bool is_name_b(String);
+ void add (Input_translator *);
+ bool is_name_b (String);
bool accept_req_b();
- bool accepts_b(String);
+ bool accepts_b (String);
void print() const;
Engraver_group_engraver * get_group_engraver_p();
Performer_group_performer * get_group_performer_p();
Input_translator * get_default_itrans_l();
- Input_translator * recursive_find(String nm);
- Input_translator * find_itrans_l(String nm);
+ Input_translator * recursive_find (String nm);
+ Input_translator * find_itrans_l (String nm);
};
-Engraver* get_engraver_p(String);
-Performer* get_performer_p(String);
+Engraver* get_engraver_p (String);
+Performer* get_performer_p (String);
#endif // Input_translator_HH
int break_status_i_;
/// nobreak = 0, pre = -1, post = 1
int break_status_i()const;
- Item * find_prebroken_piece(PCol*)const;
- Item * find_prebroken_piece(Line_of_score*)const;
+ Item * find_prebroken_piece (PCol*)const;
+ Item * find_prebroken_piece (Line_of_score*)const;
virtual Item *item() { return this; }
Item();
*/
class Key_engraver : public Engraver {
void create_key();
- void read_req(Key_change_req * r);
+ void read_req (Key_change_req * r);
public:
Key key_;
bool change_key_b_;
protected:
- virtual bool do_try_request(Request *req_l);
+ virtual bool do_try_request (Request *req_l);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
public:
Key_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Key_item);
- Key_item(int cposition);
- void add(int pitch, int acc);
- void read(const Key_engraver&);
- void set_c_position(int);
+ Key_item (int cposition);
+ void add (int pitch, int acc);
+ void read (const Key_engraver&);
+ void set_c_position (int);
protected:
virtual void do_pre_processing();
Molecule* brew_molecule_p()const;
protected:
void do_print() const;
- virtual bool do_try_request( Request* req_l );
+ virtual bool do_try_request (Request* req_l);
virtual void process_requests();
private:
Array<int> accidental_i_arr_;
Octave_key();
- void set(int i, int acc);
- int acc(int i)const { return accidental_i_arr_[i]; }
+ void set (int i, int acc);
+ int acc (int i)const { return accidental_i_arr_[i]; }
};
/// administration of accidentals
public:
bool multi_octave_b_;
- Octave_key&oct(int);
- void set(int name, int acc);
- void set(int oct, int name, int acc);
+ Octave_key&oct (int);
+ void set (int name, int acc);
+ void set (int oct, int name, int acc);
Key();
};
{
Keyword_ent *table;
int maxkey;
- Keyword_table(Keyword_ent *);
- int lookup(char const *s) const;
+ Keyword_table (Keyword_ent *);
+ int lookup (char const *s) const;
};
*/
struct Least_squares {
Array<Offset> input;
- void minimise(Real &coef, Real &offset);
+ void minimise (Real &coef, Real &offset);
void OK() const;
};
#define LILY_PROTO_HH
#include "proto.hh"
-struct My_lily_lexer;
+
struct Absolute_dynamic_req;
+struct Axis_group_element;
+struct Axis_group;
struct Translator;
+struct Audio_element;
+struct Audio_column;
+struct Audio_item;
+struct Audio_key;
+struct Audio_meter;
+struct Audio_note;
+struct Audio_note_off;
+struct Audio_score;
+struct Audio_staff;
+struct Audio_tempo;
struct Atom;
struct Bar;
+struct Bar_column_engraver;
+struct Bar_column;
struct Bar_engraver;
struct Bar_req;
struct Barcheck_req;
struct Clef_change_req;
struct Clef_item;
struct Clef_engraver;
+struct Clef_performer;
struct Col_hpositions;
struct Chord;
struct Colinfo;
struct Cresc_req;
struct Crescendo ;
struct Decresc_req;
+
struct Directional_spanner;
+struct Disallow_break_req;
struct Durational_req;
struct Dynamic;
struct Dynamic_req;
struct Global_translator;
struct Group_change_req;
struct Group_feature_req;
+struct Head_column;
struct Horizontal_align_item;
-struct Horizontal_group;
+struct Horizontal_group_element;
struct Horizontal_group_item;
struct Horizontal_vertical_group;
struct Idealspacing;
struct Identifier;
struct Interpreter;
struct Input_file;
-struct Input_engraver;
struct Input_score;
+struct Input_translator;
struct Item;
struct Key;
struct Key_change_req;
struct Key_item;
struct Key_engraver;
+struct Key_performer;
struct Keyword;
struct Keyword_table;
struct Lily_stream;
struct Line_of_score;
struct Line_of_staff;
+struct Line_spacer;
struct Linestaff;
struct Local_key;
struct Local_key_item;
struct Lookup;
struct Lyric_item;
struct Lyric_req;
+struct My_lily_lexer;
struct Measure_grouping_req;
struct Melodic_req;
struct Meter;
struct Meter_change_req;
struct Meter_engraver;
+struct Meter_performer;
struct Midi_def;
struct Midi_duration;
struct Midi_header;
struct Midi_item;
+struct Midi_key;
+struct Midi_meter;
+struct Midi_note;
+struct Midi_note_event;
+struct Midi_note_off;
struct Midi_output;
-struct Midi_pitch;
struct Midi_score;
struct Midi_stream;
+struct Midi_tempo;
struct Midi_track;
+struct Midi_walker;
struct Mixed_qp;
struct Molecule;
struct Music_general_chord;
struct My_lily_parser;
struct Note_column;
struct Note_column_engraver;
+struct Note_performer;
struct Note_req;
struct Note_head;
struct Note_head_engraver;
struct Notename_table;
struct Offset;
struct Output;
+struct Performer;
struct PCol;
-struct PScore;
+struct Paper_score;
struct Paper_def;
struct Partial_measure_req;
struct Plet;
struct Pulk_voices;
struct Rational;
struct Engraver_group_engraver;
+struct Performer;
+struct Performer_group_performer;
struct Request;
struct Request_column;
struct Engraver;
struct Score_column;
struct Score_elem;
struct Score_elem_info;
+struct Score_performer;
struct Script;
struct Script_column;
struct Script_def;
struct Span_dynamic_req;
struct Span_req;
struct Spanner;
+struct Spring_spacer;
+struct Staff_performer;
struct Staff_side;
struct Staff_symbol;
struct Stem;
struct Symtables;
struct Super_elem;
struct Terminate_voice_req;
+struct Tempo_req;
struct Tex_stream;
struct Text_def;
struct Text_gob;
struct Timing_req;
struct Vertical_brace;
struct Vertical_spanner;
-struct Vertical_group;
+struct Vertical_group_element;
struct Vertical_align_spanner;
struct Vertical_align_engraver;
struct Vertical_align_element;
struct Voice;
-struct Voice_element;
+struct Request_chord;
struct Voice_group_engravers;
+struct Voice_group_performer;
struct Voice_list;
struct Voice_engravers;
struct Voicegroup;
protected:
virtual void do_creation_processing();
virtual void do_removal_processing();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
public:
DECLARE_MY_RUNTIME_TYPEINFO;
/** solve the spacing problem
*/
- virtual void solve(Col_hpositions *) const=0;
+ virtual void solve (Col_hpositions *) const=0;
/**
Approximate the spacing problem:
return a lower bound on the energy
*/
- virtual void lower_bound_solution(Col_hpositions *) const=0;
+ virtual void lower_bound_solution (Col_hpositions *) const=0;
/** add a col to the problem. columns have to be added left to
right. The column contains info on it's minimum width. */
- virtual void add_column(PCol *, bool fixed=false, Real fixpos=0.0)=0;
+ virtual void add_column (PCol *, bool fixed=false, Real fixpos=0.0)=0;
/**
can the posed problem be solved?
prepare() was called
*/
- virtual bool check_constraints(Vector v) const=0;
+ virtual bool check_constraints (Vector v) const=0;
/**
generate a solution which can't fail
Array<Colinfo> loose_col_arr_;
/// mark column #i# as being loose.
- void loosen_column(int i);
+ void loosen_column (int i);
/// the index of #c# in #cols#
- int col_id(PCol const *c) const;
+ int col_id (PCol const *c) const;
/// generate an (nonoptimal) solution
Vector find_initial_solution() const;
bool check_feasible() const;
/// does #this# contain the column #w#?
- bool contains(PCol const *w);
+ bool contains (PCol const *w);
/// make the energy function
- void make_matrices(Matrix &quad, Vector &lin,Real&) const;
+ void make_matrices (Matrix &quad, Vector &lin,Real&) const;
/// generate the LP constraints
- void make_constraints(Mixed_qp& lp) const;
+ void make_constraints (Mixed_qp& lp) const;
void handle_loose_cols();
- void position_loose_cols(Vector &) const;
+ void position_loose_cols (Vector &) const;
/**
add a idealspacing to the problem.
since they can be "summed" if the columns to which #i# refers are
not in this problem, the spacing is ignored.
*/
- void add_ideal(Idealspacing const *i);
- void print_ideal(Idealspacing const *)const;
+ void add_ideal (Idealspacing const *i);
+ void print_ideal (Idealspacing const *)const;
Vector try_initial_solution() const;
void calcideal();
- Score_column* scol_l(int);
- void connect(int i,int j, Real,Real);
+ Score_column* scol_l (int);
+ void connect (int i,int j, Real,Real);
public:
static Line_spacer *constructor() {
return new Line_spacer;
Array<PCol*> error_pcol_l_arr() const;
virtual Array<Real> solve() const;
- virtual void add_column(PCol *, bool fixed=false, Real fixpos=0.0);
+ virtual void add_column (PCol *, bool fixed=false, Real fixpos=0.0);
virtual Vector default_solution() contains {
return try_initial_solution() ;
}
- virtual bool check_constraints(Vector v) const;
+ virtual bool check_constraints (Vector v) const;
virtual void OK() const;
virtual void print() const;
virtual void prepare();
Link_array<Item > tied_l_arr_;
/* *************** */
virtual void do_process_requests();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
Local_key_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
int name_i_;
int accidental_i_;
int octave_i_;
- static int compare(Local_acc&, Local_acc&);
+ static int compare (Local_acc&, Local_acc&);
};
/**
- Local_key_item(int c0position);
- void add_support(Item*);
- void add(int oct, int pitch, int acc);
- void add(Melodic_req*);
+ Local_key_item (int c0position);
+ void add_support (Item*);
+ void add (int oct, int pitch, int acc);
+ void add (Melodic_req*);
protected:
virtual void do_pre_processing();
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual Molecule* brew_molecule_p()const;
};
#endif // LOCALKEYITEM_HH
Symtables *symtables_;
String texsetting;
/* *************** */
- void add(String, Symtable*);
+ void add (String, Symtable*);
void print()const;
- Symbol linestaff(int n, Real w)const;
- Symbol fill(Box b)const;
- Symbol beam_element(int,int,Real=0)const;
+ Symbol linestaff (int n, Real w)const;
+ Symbol fill (Box b)const;
+ Symbol beam_element (int,int,Real=0)const;
/// round slope to closest TeXslope
- Symbol beam(Real&,Real)const;
+ Symbol beam (Real&,Real)const;
/**
pos == 3 : 3 lines above staff (extending below note)
pos == -3: below staff
*/
- Symbol streepjes(int pos)const;
+ Symbol streepjes (int pos)const;
- Symbol vbrace(Real &dy) const;
- Symbol meter(Array<Scalar>)const;
- Symbol stem(Real y1_pos, Real y2_pos)const;
- Symbol rule_symbol(Real height, Real width)const;
- Symbol accidental(int)const;
- Symbol ball(int)const;
- Symbol flag(int)const;
- Symbol rest(int, bool outside)const;
- Symbol clef(String)const;
- Symbol bar(String, Real height)const;
+ Symbol vbrace (Real &dy) const;
+ Symbol meter (Array<Scalar>)const;
+ Symbol stem (Real y1_pos, Real y2_pos)const;
+ Symbol rule_symbol (Real height, Real width)const;
+ Symbol accidental (int)const;
+ Symbol ball (int)const;
+ Symbol flag (int)const;
+ Symbol rest (int, bool outside)const;
+ Symbol clef (String)const;
+ Symbol bar (String, Real height)const;
- Symbol dots(int)const;
- Symbol slur(int dy, Real &dx, int dir)const;
- Symbol half_slur(int dy, Real &dx, int dir, int xpart)const;
- Symbol half_slur_middlepart(Real &dx, int dir)const;
- Symbol big_slur(int dy, Real &dx, int dir)const;
- Symbol text(String style, String text, int align = 1)const;
- Symbol script(String idx)const;
- Symbol hairpin(Real & width, bool decresc)const;
- Symbol dynamic(String)const;
+ Symbol dots (int)const;
+ Symbol slur (int dy, Real &dx, int dir)const;
+ Symbol half_slur (int dy, Real &dx, int dir, int xpart)const;
+ Symbol half_slur_middlepart (Real &dx, int dir)const;
+ Symbol big_slur (int dy, Real &dx, int dir)const;
+ Symbol text (String style, String text, int align = 1)const;
+ Symbol script (String idx)const;
+ Symbol hairpin (Real & width, bool decresc)const;
+ Symbol dynamic (String)const;
Lookup();
- Lookup(Lookup const &);
+ Lookup (Lookup const &);
~Lookup();
};
Text_item *lyric_item_p_;
protected:
virtual void do_pre_move_processing();
- virtual bool do_try_request(Request*);
+ virtual bool do_try_request (Request*);
virtual void do_process_requests();
virtual void do_post_move_processing();
public:
protected:
void do_print() const;
- virtual bool do_try_request( Request* req_l );
+ virtual bool do_try_request (Request* req_l);
virtual void process_requests();
private:
#include "lily-proto.hh"
void debug_init();
-void set_debug(bool);
+void set_debug (bool);
void do_scores();
-void add_score(Score* s);
-void set_default_output(String s);
+void add_score (Score* s);
+void set_default_output (String s);
Input_score* current_iscore_l();
-String find_file(String);
+String find_file (String);
String get_version_str();
extern Sources* source_l_g;
extern bool only_midi;
Meter_change_req * meter_req_l_;
Meter * meter_p_;
- virtual void fill_staff_info(Staff_info&);
- virtual bool do_try_request(Request *req_l);
+ virtual void fill_staff_info (Staff_info&);
+ virtual bool do_try_request (Request *req_l);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_creation_processing();
protected:
void do_print() const;
- virtual bool do_try_request( Request* req_l );
+ virtual bool do_try_request (Request* req_l);
virtual void process_requests();
private:
protected:
Molecule*brew_molecule_p() const;
public:
- Meter(Array<Scalar> args) ;
+ Meter (Array<Scalar> args) ;
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Meter);
};
Real whole_seconds_f_;
Midi_def();
- Midi_def( Midi_def const& midi_c_r );
+ Midi_def (Midi_def const& midi_c_r);
~Midi_def();
- Real duration_to_seconds_f(Moment);
+ Real duration_to_seconds_f (Moment);
Global_translator* get_global_translator_p() const;
- int get_tempo_i( Moment moment );
+ int get_tempo_i (Moment moment);
void print() const;
- void set( Input_translator* itrans_p );
- void set_tempo( Moment moment, int count_per_minute_i );
+ void set (Input_translator* itrans_p);
+ void set_tempo (Moment moment, int count_per_minute_i);
};
#endif // MIDI_DEF_HH
*/
struct Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_item( Audio_item* audio_item_l );
- static String i2varint_str( int i );
- void output( Midi_stream* midi_stream_l ) const;
+ Midi_item (Audio_item* audio_item_l);
+ static String i2varint_str (int i);
+ void output (Midi_stream* midi_stream_l) const;
virtual String str() const = 0;
Audio_item* audio_item_l_;
int channel_i_;
private:
- Midi_item( Midi_item const& );
- Midi_item& operator =( Midi_item const& );
+ Midi_item (Midi_item const&);
+ Midi_item& operator =( Midi_item const&);
};
/**
DECLARE_MY_RUNTIME_TYPEINFO;
Midi_chunk();
- void add( String str );
- void set( String header_str, String data_str, String footer_str );
+ void add (String str);
+ void set (String header_str, String data_str, String footer_str);
virtual String str() const;
private:
struct Midi_duration : public Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_duration( Real seconds_f );
+ Midi_duration (Real seconds_f);
virtual String str() const;
Real seconds_f_;
struct Midi_header : Midi_chunk {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_header( int format_i, int tracks_i, int clocks_per_4_i );
+ Midi_header (int format_i, int tracks_i, int clocks_per_4_i);
};
*/
struct Midi_instrument : public Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_instrument( int channel_i, String instrument_str );
+ Midi_instrument (int channel_i, String instrument_str);
virtual String str() const;
String instrument_str_;
struct Midi_key : public Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_key( Audio_item* audio_item_l );
+ Midi_key (Audio_item* audio_item_l);
virtual String str() const;
};
struct Midi_meter : Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_meter( Audio_item* audio_item_l );
+ Midi_meter (Audio_item* audio_item_l);
virtual String str() const;
int clocks_per_1_i_;
*/
struct Midi_note : public Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_note( Audio_item* audio_item_l );
+ Midi_note (Audio_item* audio_item_l);
Moment duration() const;
int pitch_i() const;
*/
struct Midi_note_off : public Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_note_off( Midi_note* midi_note_l );
+ Midi_note_off (Midi_note* midi_note_l);
int pitch_i() const;
virtual String str() const;
TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
MARKER, CUE_POINT
};
- Midi_text( Midi_text::Type type, String text_str );
- Midi_text( Audio_item* audio_item_l );
+ Midi_text (Midi_text::Type type, String text_str);
+ Midi_text (Audio_item* audio_item_l);
virtual String str() const;
struct Midi_tempo : Midi_item {
DECLARE_MY_RUNTIME_TYPEINFO;
- Midi_tempo( int per_minute_4_i );
- Midi_tempo( Audio_item* audio_item_l );
+ Midi_tempo (int per_minute_4_i);
+ Midi_tempo (Audio_item* audio_item_l);
virtual String str() const;
Midi_track();
- void add( int delta_time_i, String event );
- void add( Moment delta_time_moment, Midi_item* mitem_l );
+ void add (int delta_time_i, String event);
+ void add (Moment delta_time_moment, Midi_item* mitem_l);
};
#endif // MIDI_ITEM_HH
/// Midi outputfile
struct Midi_stream {
- Midi_stream( String filename_str );
+ Midi_stream (String filename_str);
~Midi_stream();
- Midi_stream& operator <<( String str );
- Midi_stream& operator <<( Midi_item const& mitem_c_r );
- Midi_stream& operator <<( int i );
+ Midi_stream& operator <<( String str);
+ Midi_stream& operator <<( Midi_item const& mitem_c_r);
+ Midi_stream& operator <<( int i);
void open();
Midi_note_event();
};
-int compare(Midi_note_event const& left, Midi_note_event const& right );
+int compare (Midi_note_event const& left, Midi_note_event const& right);
/**
walk audio and output midi
class Midi_walker : public PCursor<Audio_item*>
{
public:
- Midi_walker( Audio_staff* audio_staff_l, Midi_track* midi_track_l );
+ Midi_walker (Audio_staff* audio_staff_l, Midi_track* midi_track_l);
~Midi_walker();
void process();
private:
- void do_start_note( Midi_note* note_l );
- void do_stop_notes( Moment now_mom );
- void output_event( Moment now_mom, Midi_item* l );
+ void do_start_note (Midi_note* note_l);
+ void do_stop_notes (Moment now_mom);
+ void output_event (Moment now_mom, Midi_item* l);
Midi_track* track_l_;
PQueue<Midi_note_event> stop_note_queue;
#include "scalar.hh"
#include "grouping.hh"
-Moment wholes(int dur, int dots);
+Moment wholes (int dur, int dots);
double log_2(double x) ;
int intlog2(int d);
inline int
-abs(int i){
+abs (int i){
return (i < 0)?-i:i;
}
inline int
-sign(int i) {
+sign (int i) {
if (i<0) return -1;
else if (i) return 1;
else return 0;
}
-Interval itemlist_width(const Array<Item*> &its);
+Interval itemlist_width (const Array<Item*> &its);
#endif
/* *************** */
Molecule() { }
- Molecule(Atom const &a) { add(a) ;}
+ Molecule (Atom const &a) { add (a) ;}
- void add_right(const Molecule &m);
- void add_left(const Molecule &m);
- void add_top(const Molecule &m);
- void add_bottom(const Molecule &m);
- void add(Molecule const &m);
- void translate(Offset);
- void translate(Real,Axis);
- void add(Atom const & a) ;
+ void add_right (const Molecule &m);
+ void add_left (const Molecule &m);
+ void add_top (const Molecule &m);
+ void add_bottom (const Molecule &m);
+ void add (Molecule const &m);
+ void translate (Offset);
+ void translate (Real,Axis);
+ void add (Atom const & a) ;
/// how big is #this#?
Box extent() const;
String TeX_string() const;
- Molecule(const Molecule&s);
+ Molecule (const Molecule&s);
void print() const;
private:
void operator=(const Molecule&);
class Music_iterator {
Array<Translator *>report_to_l_arr_;
- void push_translator(Translator*);
+ void push_translator (Translator*);
void pop_translator();
protected:
bool first_b_;
virtual void do_print()const;
virtual Translator * get_req_translator_l();
- Music_iterator* get_iterator_p(Music*)const;
- void set_translator(Translator*);
+ Music_iterator* get_iterator_p (Music*)const;
+ void set_translator (Translator*);
Music_iterator *daddy_iter_l_;
public:
Translator *report_to_l()const;
DECLARE_MY_RUNTIME_TYPEINFO;
- static Music_iterator* static_get_iterator_p(Music*,Translator*);
+ static Music_iterator* static_get_iterator_p (Music*,Translator*);
Music_iterator();
- virtual void process_and_next(Moment until);
+ virtual void process_and_next (Moment until);
virtual Moment next_moment()const;
virtual bool ok()const;
virtual ~Music_iterator();
Pointer_list<Music_iterator*> children_p_list_;
public:
~Chord_iterator();
- Chord_iterator(Chord const*);
+ Chord_iterator (Chord const*);
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
virtual void do_print()const;
virtual void construct_children();
- virtual void process_and_next(Moment);
+ virtual void process_and_next (Moment);
virtual Moment next_moment()const;
virtual bool ok()const;
};
Moment elt_duration_;
bool last_b_;
public:
- Request_chord_iterator(Request_chord*);
+ Request_chord_iterator (Request_chord*);
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual void process_and_next(Moment);
+ virtual void process_and_next (Moment);
virtual Moment next_moment()const;
virtual void construct_children();
virtual bool ok()const;
void set_voice_translator();
public:
- Voice_iterator(Voice const*);
+ Voice_iterator (Voice const*);
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
virtual void do_print()const;
virtual void construct_children();
~Voice_iterator();
- virtual void process_and_next(Moment);
+ virtual void process_and_next (Moment);
virtual Moment next_moment()const;
virtual bool ok()const;
};
public:
int multi_level_i_;
- Music_list(Music_list const&);
+ Music_list (Music_list const&);
Music_list();
DECLARE_MY_RUNTIME_TYPEINFO;
VIRTUAL_COPY_CONS(Music_list,Music);
- virtual void add(Music*);
- virtual void transpose(Melodic_req const *);
+ virtual void add (Music*);
+ virtual void transpose (Melodic_req const *);
Pointer_list<Music*> music_p_list_;
protected:
Chord();
DECLARE_MY_RUNTIME_TYPEINFO;
VIRTUAL_COPY_CONS(Chord,Music);
- virtual void translate(Moment dt);
+ virtual void translate (Moment dt);
virtual MInterval time_int()const;
};
Voice();
DECLARE_MY_RUNTIME_TYPEINFO;
VIRTUAL_COPY_CONS(Voice, Music);
- virtual void translate(Moment dt);
+ virtual void translate (Moment dt);
virtual MInterval time_int()const;
};
virtual MInterval time_int()const;
virtual ~Music(){}
void print() const;
- virtual void transpose(Melodic_req const *);
- virtual void translate(Moment dt);
+ virtual void transpose (Melodic_req const *);
+ virtual void translate (Moment dt);
VIRTUAL_COPY_CONS(Music,Music);
DECLARE_MY_RUNTIME_TYPEINFO;
Music();
Duration duration_;
/* *************** */
- void set_duration(Duration);
- bool do_equal_b(Request*)const;
+ void set_duration (Duration);
+ bool do_equal_b (Request*)const;
virtual Moment duration() const;
Rhythmic_req();
- static int compare(Rhythmic_req const&,Rhythmic_req const&);
+ static int compare (Rhythmic_req const&,Rhythmic_req const&);
REQUESTMETHODS(Rhythmic_req, rhythmic);
};
Text_def *tdef_p_;
/* *************** */
- Text_req(int d, Text_def*);
+ Text_req (int d, Text_def*);
~Text_req();
- Text_req(Text_req const&);
+ Text_req (Text_req const&);
REQUESTMETHODS(Text_req,text);
};
*/
class Lyric_req : public Rhythmic_req, public Text_req {
public:
- Lyric_req(Text_def* t_p);
+ Lyric_req (Text_def* t_p);
REQUESTMETHODS(Lyric_req, lreq_l);
};
int height()const;
/// transpose. #delta# is relative to central c.
- void transpose(Melodic_req const &delta);
+ void transpose (Melodic_req const &delta);
/// return pitch from central c (in halfnotes)
int pitch()const;
Melodic_req();
- bool do_equal_b(Request*)const;
- static int compare( Melodic_req const&,Melodic_req const&);
+ bool do_equal_b (Request*)const;
+ static int compare (Melodic_req const&,Melodic_req const&);
REQUESTMETHODS(Melodic_req,melodic);
};
/// force/supress printing of accidental.
bool forceacc_b_;
Note_req();
- bool do_equal_b(Request*)const;
- Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
+ bool do_equal_b (Request*)const;
+ Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic (); }
REQUESTMETHODS(Note_req, note);
};
enum {
NOSPAN, START, STOP
} spantype ;
- bool do_equal_b(Request*)const;
+ bool do_equal_b (Request*)const;
REQUESTMETHODS(Span_req,span);
Span_req();
enum Loudness {
FFF, FF, F, MF, MP, P, PP, PPP
};
- static String loudness_str(Loudness);
+ static String loudness_str (Loudness);
REQUESTMETHODS(Dynamic_req, dynamic);
};
Array<Input> define_spot_array_;
String init_str_;
- void add_requests( Chord*v);
+ void add_requests (Chord*v);
- Chord * get_note_element(Note_req * ,Duration *);
- Chord* get_rest_element(String,Duration *);
- Chord* get_word_element(Text_def*, Duration*);
+ Chord * get_note_element (Note_req * ,Duration *);
+ Chord* get_rest_element (String,Duration *);
+ Chord* get_word_element (Text_def*, Duration*);
- void set_last_duration(Duration const *);
- void set_default_duration(Duration const *);
- void set_duration_mode(String s);
- friend int yyparse( void*);
+ void set_last_duration (Duration const *);
+ void set_default_duration (Duration const *);
+ void set_duration_mode (String s);
+ friend int yyparse (void*);
public:
int default_octave_i_;
Duration default_duration_;
My_lily_lexer * lexer_p_;
Moment plet_mom();
- void add_notename(String, Melodic_req* req_p);
+ void add_notename (String, Melodic_req* req_p);
Input here_input()const;
void remember_spot();
Input pop_spot();
Paper_def*default_paper();
Midi_def*default_midi();
void do_yyparse();
- void parser_error(String);
+ void parser_error (String);
void clear_notenames();
- Request* get_parens_request(char c);
+ Request* get_parens_request (char c);
void set_debug();
- void set_yydebug(bool);
+ void set_yydebug (bool);
void print_declarations();
bool ignore_version_b_;
public:
void do_init_file();
void parse_file ( String init_str, String file_str);
- My_lily_parser(Sources * sources_l);
+ My_lily_parser (Sources * sources_l);
~My_lily_parser();
- void set_version_check(bool ignore);
+ void set_version_check (bool ignore);
};
#endif // MY_LILY_PARSER_HH
int dir_i_;
- bool acceptable_elem_b(Score_elem const*)const;
+ bool acceptable_elem_b (Score_elem const*)const;
protected:
- virtual void set_feature(Feature);
- virtual void acknowledge_element(Score_elem_info);
+ virtual void set_feature (Feature);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
public:
#include "head-column.hh"
/** a struct for treating a group of noteheads (noteheads, stem
- (chord) and scripts ) as a single entity. */
+ (chord) and scripts) as a single entity. */
class Note_column : public Head_column {
protected:
virtual void do_pre_processing();
DECLARE_MY_RUNTIME_TYPEINFO;
Note_column();
- virtual void set(Stem *);
+ virtual void set (Stem *);
void sort();
};
/* *************** */
- void set_rhythmic(Rhythmic_req *);
+ void set_rhythmic (Rhythmic_req *);
/**
position of top line (5 linestaff: 8)
*/
- Note_head(int staff_size);
+ Note_head (int staff_size);
void set_dots();
- static int compare(Note_head * const &a, Note_head *const &b) ;
+ static int compare (Note_head * const &a, Note_head *const &b) ;
protected:
virtual void do_print()const;
virtual void do_pre_processing();
protected:
virtual void process_requests();
- virtual bool do_try_request( Request *req_l ) ;
+ virtual bool do_try_request (Request *req_l) ;
virtual void do_print() const;
private:
class Notename_table : Assoc<String, P<Melodic_req> >{
public:
- void add(String, Melodic_req*);
- Melodic_req*get_l(String);
+ void add (String, Melodic_req*);
+ Melodic_req*get_l (String);
};
#endif // NOTENAME_TABLE_HH
struct Notename_tab {
String notetab[7*5];
- void set(int l, int s, String nm);
- void lookup(int &large, int &small, String s);
+ void set (int l, int s, String nm);
+ void lookup (int &large, int &small, String s);
};
-void set_notename_tab(Notename_tab*n);
-void lookup_notename(int &large, int &small, String s);
+void set_notename_tab (Notename_tab*n);
+void lookup_notename (int &large, int &small, String s);
#endif // NOTENAME_HH
}
Offset operator+=(Offset o) {
- x()+=o.x();
- y()+=o.y();
+ x()+=o.x ();
+ y()+=o.y ();
return *this;
}
- Offset(Real ix , Real iy) {
+ Offset (Real ix , Real iy) {
x()=ix;
y()=iy;
}
bool breakpoint_b() const;
void clean_breakable_items();
- void add(Item *i);
+ void add (Item *i);
/// Can this be broken? true eg. for bars.
bool breakable_b()const;
@return < 0 if c1 < c2.
*/
- static int compare(const PCol &c1, const PCol &c2);
- void set_rank(int);
+ static int compare (const PCol &c1, const PCol &c2);
+ void set_rank (int);
void OK() const;
void set_breakable();
-1 is uninitialised.
*/
int rank_i_;
- PCol(PCol const&){}
+ PCol (PCol const&){}
};
#include "compare.hh"
-instantiate_compare(PCol &, PCol::compare);
+INSTANTIATE_COMPARE(PCol &, PCol::compare);
#endif
/* *************** */
/* CONSTRUCTION */
- Paper_score(Paper_def*);
+ Paper_score (Paper_def*);
/// add a line to the broken stuff. Positions given in #config#
- void set_breaking(Array<Col_hpositions> const &);
+ void set_breaking (Array<Col_hpositions> const &);
/** add an item.
add the item in specified containers. If breakstatus is set
properly, add it to the {pre,post}break of the pcol.
*/
- void typeset_item(Item *item_p, PCol *pcol_l);
+ void typeset_item (Item *item_p, PCol *pcol_l);
/// add to bottom of pcols
- void add(PCol*);
+ void add (PCol*);
/**
@return argument as a cursor of the list
*/
- PCursor<PCol *> find_col(PCol const *)const;
+ PCursor<PCol *> find_col (PCol const *)const;
- Link_array<PCol> col_range(PCol *left_l, PCol *right_l) const;
- Link_array<PCol> breakable_col_range(PCol*,PCol*) const;
- Link_array<PCol> broken_col_range(PCol*,PCol*) const;
+ Link_array<PCol> col_range (PCol *left_l, PCol *right_l) const;
+ Link_array<PCol> breakable_col_range (PCol*,PCol*) const;
+ Link_array<PCol> broken_col_range (PCol*,PCol*) const;
/* MAIN ROUTINES */
void process();
/// last deed of this struct
- void output(Tex_stream &ts);
+ void output (Tex_stream &ts);
/* UTILITY ROUTINES */
void OK()const;
void print() const;
~Paper_score();
- void typeset_element(Score_elem*);
- void typeset_broken_spanner(Spanner*);
+ void typeset_element (Score_elem*);
+ void typeset_broken_spanner (Spanner*);
/// add a Spanner
- void typeset_unbroken_spanner(Spanner*);
+ void typeset_unbroken_spanner (Spanner*);
private:
/* *************** */
- void set_var(String, Real);
+ void set_var (String, Real);
Real get_var (String)const;
void reinit();
Paper_def();
- void set(Lookup*);
- void set (Input_translator * );
+ void set (Lookup*);
+ void set (Input_translator *);
Global_translator * get_global_translator_p()const;
~Paper_def();
- Paper_def(Paper_def const&);
+ Paper_def (Paper_def const&);
/// The distance between beams
Real interbeam_f()const;
/**
/** convert a duration to an idealspacing
influence using the geometric_ and parameters.
*/
- Real duration_to_dist(Moment);
+ Real duration_to_dist (Moment);
};
#endif // Paper_def_HH
#include "lily-proto.hh"
-String * get_scriptdef(char c);
-Request* get_script_req(char);
-Request*get_script_req(int d , Script_def*def);
-Request*get_text_req(int d , Text_def*def);
-Request* get_stemdir_req(int);
-Request*get_grouping_req(Array<int> i_arr);
-Request* get_hshift_req(int);
+String * get_scriptdef (char c);
+Request* get_script_req (char);
+Request*get_script_req (int d , Script_def*def);
+Request*get_text_req (int d , Text_def*def);
+Request* get_stemdir_req (int);
+Request*get_grouping_req (Array<int> i_arr);
+Request* get_hshift_req (int);
#endif // PARSECONSTRUCT_HH
DECLARE_MY_RUNTIME_TYPEINFO;
Input_translator* itrans_l_;
- virtual void add( Performer* perf_p );
- virtual bool do_try_request( Request* req_l );
+ virtual void add (Performer* perf_p);
+ virtual bool do_try_request (Request* req_l);
virtual void print() const;
- virtual bool try_request(Request* r);
+ virtual bool try_request (Request* r);
protected:
virtual ~Performer_group_performer();
- virtual Translator* find_get_translator_l( String name, String id );
+ virtual Translator* find_get_translator_l (String name, String id);
virtual Translator* get_default_interpreter();
- Translator * ancestor_l( int l = 1 );
+ Translator * ancestor_l (int l = 1);
virtual int depth_i() const;
virtual void process_requests();
virtual void do_creation_processing();
bool is_bottom_performer_b() const;
- virtual Performer_group_performer* find_performer_l( String name, String id );
+ virtual Performer_group_performer* find_performer_l (String name, String id);
virtual void do_print()const;
private:
void print() const;
virtual void process_requests();
- virtual bool try_request( Request* req_l );
+ virtual bool try_request (Request* req_l);
virtual void do_removal_processing();
void creation_processing();
protected:
virtual void do_creation_processing();
- virtual bool do_try_request(Request*);
+ virtual bool do_try_request (Request*);
virtual int get_tempo_i() const;
virtual void do_print() const;
- virtual void play( Audio_element * elem_p );
+ virtual void play (Audio_element * elem_p );
};
#include "global-performers.hh"
Array<int> eq_cons;
Array<Real> eq_consrhs;
public:
- Mixed_qp(int n);
+ Mixed_qp (int n);
void OK() const;
void print() const;
- Vector solve(Vector start) const;
- void add_fixed_var(int i , Real value);
+ Vector solve (Vector start) const;
+ void add_fixed_var (int i , Real value);
/**
c*vars == r
PRE
- c.dim()==dim();
+ c.dim()==dim ();
*/
- void add_equality_cons(Vector c, double r);
+ void add_equality_cons (Vector c, double r);
};
#endif
public:
String status()const;
- Vector vec(int k) const { return opt->cons[k]; }
- Real rhs(int k) const { return opt->consrhs[k]; }
+ Vector vec (int k) const { return opt->cons[k]; }
+ Real rhs (int k) const { return opt->consrhs[k]; }
/** drop constraint. drop constraint k from the active set. k is the index of the
add constraint j to the active set j is the index of the
constraint in #inactive#
*/
- void add(int j);
+ void add (int j);
/// exchange in and out.
- void exchange(int in, int out) { add(in); drop (out); }
+ void exchange (int in, int out) { add (in); drop (out); }
- Vector find_active_optimum(Vector g);
+ Vector find_active_optimum (Vector g);
/// get lagrange multipliers.
- Vector get_lagrange(Vector v);
+ Vector get_lagrange (Vector v);
- Active_constraints(Ineq_constrained_qp const *op);
+ Active_constraints (Ineq_constrained_qp const *op);
/** construct: no constraints active, n vars. Put the equalities
into the constraints. */
int j;
Active_constraints const* ac;
public:
- Inactive_iter(Active_constraints const &c) { ac=&c; j=0; }
+ Inactive_iter (Active_constraints const &c) { ac=&c; j=0; }
int idx() const { return j; }
void operator ++(int) { j++; }
int constraint_id() const { return ac->inactive[j]; }
- Vector vec() const { return ac->vec(constraint_id()); }
- Real rhs() const { return ac->rhs(constraint_id()); }
- bool ok() const { return j < ac->inactive.size(); }
+ Vector vec() const { return ac->vec (constraint_id ()); }
+ Real rhs() const { return ac->rhs (constraint_id ()); }
+ bool ok() const { return j < ac->inactive.size (); }
};
#endif // QLPSOLVE_HH
VIRTUAL_COPY_CONS(Request,Music);
virtual MInterval time_int() const;
- virtual void transpose(Melodic_req const &){}
+ virtual void transpose (Melodic_req const &){}
virtual Moment duration() const { return 0; }
/* accessors for children
virtual Blank_req * blank() { return 0; }
virtual Musical_req *musical() { return 0; }
virtual Command_req * command() { return 0; }
- bool equal_b(Request*) const;
+ bool equal_b (Request*) const;
protected:
- virtual bool do_equal_b(Request*) const;
+ virtual bool do_equal_b (Request*) const;
virtual void do_print()const;
};
General_script_def *scriptdef_p_;
/* *************** */
- bool do_equal_b(Request*)const;
+ bool do_equal_b (Request*)const;
Script_req();
REQUESTMETHODS(Script_req,script);
~Script_req();
- Script_req(Script_req const&);
+ Script_req (Script_req const&);
};
class Rest_column : public Head_column {
public:
DECLARE_MY_RUNTIME_TYPEINFO;
- void translate_heads(int dy);
+ void translate_heads (int dy);
};
#endif // REST_COLUMN_HH
Score_align_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
};
#endif // SCORE_ALIGN_GRAV_HH
/* *************** */
Moment when() { return when_; }
- Score_column(Moment when);
- void add_duration(Moment );
+ Score_column (Moment when);
+ void add_duration (Moment);
void preprocess();
bool musical_b() { return musical_b_; }
void print() const;
Array<Engraver*> origin_grav_l_arr_;
/* *** */
- Score_elem_info(Score_elem*, Request*);
+ Score_elem_info (Score_elem*, Request*);
Score_elem_info();
};
Status status_;
- Score_elem* dependency(int) const;
- Score_elem* dependent(int) const;
+ Score_elem* dependency (int) const;
+ Score_elem* dependent (int) const;
int dependent_size() const;
int dependency_size() const;
public:
Paper_score *pscore_l_;
Axis_group_element * axis_group_l_a_[2];
- Score_elem(Score_elem const&);
- virtual String TeX_string () const ;
- String TeX_string_without_offset(Offset)const;
+ Score_elem (Score_elem const&);
+ virtual String TeX_string() const ;
+ String TeX_string_without_offset (Offset)const;
virtual void print() const;
Paper_def *paper() const;
Score_elem();
DECLARE_MY_RUNTIME_TYPEINFO;
- Interval extent(Axis)const;
+ Interval extent (Axis)const;
Interval width() const;
Interval height() const;
Status status() const;
/**
translate the symbol. The symbol does not have to be created yet.
*/
- void translate(Offset);
+ void translate (Offset);
/**
translate in one direction
*/
- void translate(Real, Axis);
- Real relative_coordinate(Axis_group_element*, Axis)const;
+ void translate (Real, Axis);
+ Real relative_coordinate (Axis_group_element*, Axis)const;
Offset absolute_offset()const;
- Real absolute_coordinate(Axis)const;
- Axis_group_element*common_group(Score_elem const* s, Axis a)const;
+ Real absolute_coordinate (Axis)const;
+ Axis_group_element*common_group (Score_elem const* s, Axis a)const;
void add_processing();
void OK() const;
*/
void unlink();
void unlink_all();
- void substitute_dependency(Score_elem*,Score_elem*);
- void remove_dependency(Score_elem*);
+ void substitute_dependency (Score_elem*,Score_elem*);
+ void remove_dependency (Score_elem*);
/**
add a dependency. It may be the 0 pointer, in which case, it is ignored.
*/
- void add_dependency(Score_elem* );
- void copy_dependencies(Score_elem const&);
+ void add_dependency (Score_elem*);
+ void copy_dependencies (Score_elem const&);
/**
junk the dependency array. Don't do derived stuff.
*/
/// do calculations after determining horizontal spacing
virtual void do_post_processing();
- virtual void do_substitute_dependency(Score_elem * , Score_elem *);
- virtual void do_substitute_dependent(Score_elem *, Score_elem *);
+ virtual void do_substitute_dependency (Score_elem * , Score_elem *);
+ virtual void do_substitute_dependent (Score_elem *, Score_elem *);
virtual void do_break_processing();
virtual void handle_broken_dependencies();
virtual void handle_prebroken_dependencies();
Score_column* musical_column_l_;
friend class Score;
- void set_columns(Score_column*,Score_column*);
+ void set_columns (Score_column*,Score_column*);
void typeset_all();
public:
protected:
/* Global_translator interface */
- virtual void set_score(Score * score_l);
- virtual void prepare(Moment);
+ virtual void set_score (Score * score_l);
+ virtual void prepare (Moment);
virtual void finish();
virtual void process();
- virtual int depth_i() const { return Global_translator::depth_i();}
- virtual Translator* ancestor_l(int l) { return Global_translator::ancestor_l(l);}
+ virtual int depth_i() const { return Global_translator::depth_i ();}
+ virtual Translator* ancestor_l (int l) { return Global_translator::ancestor_l (l);}
protected:
/* Engraver_group_engraver interface */
virtual Staff_info get_staff_info()const;
- virtual bool do_try_request(Request*);
+ virtual bool do_try_request (Request*);
virtual void do_creation_processing();
virtual void do_removal_processing();
- virtual void announce_element(Score_elem_info);
+ virtual void announce_element (Score_elem_info);
virtual void do_announces();
- virtual void typeset_element(Score_elem*elem_p);
+ virtual void typeset_element (Score_elem*elem_p);
virtual Paper_def * paper() const;
virtual void do_pre_move_processing();
};
DECLARE_MY_RUNTIME_TYPEINFO;
Score_horizontal_align_engraver();
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
};
#endif // SCORE_HALIGN_GRAV_HH
~Score_performer();
protected:
- virtual Translator* ancestor_l(int l);
+ virtual Translator* ancestor_l (int l);
virtual int depth_i() const;
virtual void finish();
- virtual void prepare(Moment mom);
+ virtual void prepare (Moment mom);
virtual void process();
- virtual void set_score(Score* score_l);
+ virtual void set_score (Score* score_l);
virtual void start();
virtual int get_tempo_i() const;
- virtual void play(Audio_element* p);
+ virtual void play (Audio_element* p);
private:
- void header(Midi_stream&);
+ void header (Midi_stream&);
Moment now_mom_;
Audio_column* audio_column_l_;
/// construction
Score();
- Score(Score const&);
+ Score (Score const&);
~Score();
/// do everything except outputting to file
void process();
/// output to file
- void output(String fn);
+ void output (String fn);
///
- void set(Midi_def* midi_p);
+ void set (Midi_def* midi_p);
///
- void set(Paper_def* midi_p);
+ void set (Paper_def* midi_p);
void print() const;
private:
- void run_translator(Global_translator*);
+ void run_translator (Global_translator*);
void midi_output();
void paper_output();
void paper();
// utils:
- PCursor<Score_column*> create_cols(Moment, PCursor<Score_column*> &last);
+ PCursor<Score_column*> create_cols (Moment, PCursor<Score_column*> &last);
/**
make the pcol_l_ fields of each Score_column point to the correct PCol,
DECLARE_MY_RUNTIME_TYPEINFO;
Line_of_score();
- void add(Score_elem *);
+ void add (Score_elem *);
/// is #c# contained in #*this#?
- bool contains_b(PCol const *c)const;
+ bool contains_b (PCol const *c)const;
Link_array<Line_of_score> get_lines()const;
- void set_breaking(Array<Col_hpositions> const&);
+ void set_breaking (Array<Col_hpositions> const&);
protected:
- virtual void break_into_pieces(bool);
+ virtual void break_into_pieces (bool);
virtual Interval do_width()const;
virtual void do_print() const;
SCORE_ELEM_CLONE(Line_of_score);
#include "elem-group-item.hh"
/** a struct for treating a group of noteheads (noteheads, stem
- (chord) and scripts ) as a single entity. */
+ (chord) and scripts) as a single entity. */
class Script_column : public Horizontal_vertical_group_item {
protected:
virtual void do_print() const;
- virtual void do_substitute_dependency(Score_elem*, Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*, Score_elem*);
virtual void do_pre_processing() ;
public:
Link_array<Script> script_l_arr_;
Link_array<Item> support_l_arr_;
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual void add(Script *);
- void add_support(Item*);
+ virtual void add (Script *);
+ void add_support (Item*);
};
#endif // SCRIPT_COLUMN_HH
virtual int rel_stem_dir_i()const;
virtual int priority_i()const;
virtual bool inside_b()const;
- virtual Atom get_atom(Paper_def* p, int dir_i_)const;
+ virtual Atom get_atom (Paper_def* p, int dir_i_)const;
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual bool do_equal_b(General_script_def const *)const;
+ virtual bool do_equal_b (General_script_def const *)const;
virtual void do_print() const;
Script_def();
- void set_from_input(String, bool, int, int ,bool,int );
+ void set_from_input (String, bool, int, int ,bool,int);
protected:
VIRTUAL_COPY_CONS(Script_def,General_script_def);
DECLARE_MY_RUNTIME_TYPEINFO;
Script_engraver();
protected:
- virtual bool do_try_request(Request*);
+ virtual bool do_try_request (Request*);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
protected:
Molecule *brew_molecule_p()const;
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void do_print() const;
virtual Interval symbol_height()const;
virtual void do_pre_processing();
public:
General_script_def *specs_l_;
- static int compare(Script *const&, Script *const&) ;
+ static int compare (Script *const&, Script *const&) ;
Script();
- void set_stem(Stem*);
+ void set_stem (Stem*);
DECLARE_MY_RUNTIME_TYPEINFO;
};
/* *************** */
protected:
virtual ~Slur_engraver();
- virtual bool do_try_request(Request*);
- virtual void set_feature(Feature);
+ virtual bool do_try_request (Request*);
+ virtual void set_feature (Feature);
virtual void do_process_requests();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
public:
class Slur : public Bow {
public:
Link_array<Note_column> encompass_arr_;
- void add(Note_column*);
+ void add (Note_column*);
protected:
virtual void set_default_dir();
virtual void do_post_processing();
- virtual void do_substitute_dependency(Score_elem*, Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*, Score_elem*);
virtual void do_pre_processing();
SCORE_ELEM_CLONE(Slur);
DECLARE_MY_RUNTIME_TYPEINFO;
Span_bar_engraver();
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
virtual Span_bar* get_span_bar_p()const;
};
Span_bar();
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Span_bar);
- void add(Bar* );
- void set( Vertical_align_element *);
+ void add (Bar*);
+ void set (Vertical_align_element *);
protected:
virtual Interval do_width()const;
virtual void do_pre_processing();
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual Molecule * brew_molecule_p()const;
- virtual Symbol get_bar_sym(Real dy) const;
+ virtual Symbol get_bar_sym (Real dy) const;
};
#endif // SPAN_BAR_HH
SCORE_ELEM_CLONE(Piano_brace);
protected:
virtual Interval do_width()const;
- virtual Symbol get_bar_sym(Real) const;
+ virtual Symbol get_bar_sym (Real) const;
};
#endif // SPAN_SCORE_BAR_HH
virtual Spanner* spanner() { return this; }
Spanner();
bool broken_b() const;
- Spanner* find_broken_piece(Line_of_score*)const;
+ Spanner* find_broken_piece (Line_of_score*)const;
protected:
void set_my_columns();
SCORE_ELEM_CLONE(Spanner);
/**
this is virtual; for instance, Line_of_score overrides it.
*/
- virtual void break_into_pieces(bool);
+ virtual void break_into_pieces (bool);
Link_array<Spanner> broken_into_l_arr_;
Array<Colinfo> loose_col_arr_;
/// mark column #i# as being loose.
- void loosen_column(int i);
+ void loosen_column (int i);
/// the index of #c# in #cols#
- int col_id(PCol const *c) const;
+ int col_id (PCol const *c) const;
/// generate an (nonoptimal) solution
Vector find_initial_solution() const;
bool check_feasible() const;
/// does #this# contain the column #w#?
- bool contains(PCol const *w);
+ bool contains (PCol const *w);
/// make the energy function
- void make_matrices(Matrix &quad, Vector &lin,Real&) const;
+ void make_matrices (Matrix &quad, Vector &lin,Real&) const;
/// generate the LP constraints
- void make_constraints(Mixed_qp& lp) const;
+ void make_constraints (Mixed_qp& lp) const;
void handle_loose_cols();
- void position_loose_cols(Vector &) const;
+ void position_loose_cols (Vector &) const;
/**
add a idealspacing to the problem.
since they can be "summed" if the columns to which #i# refers are
not in this problem, the spacing is ignored.
*/
- void add_ideal(Idealspacing const *i);
+ void add_ideal (Idealspacing const *i);
Vector try_initial_solution() const;
void calc_idealspacing();
- void set_fixed_cols(Mixed_qp&)const;
+ void set_fixed_cols (Mixed_qp&)const;
- Score_column* scol_l(int);
- void connect(int i,int j, Real,Real);
+ Score_column* scol_l (int);
+ void connect (int i,int j, Real,Real);
Line_of_cols error_pcol_l_arr()const;
public:
static Line_spacer *constructor();
- virtual void solve(Col_hpositions*) const;
- virtual void lower_bound_solution(Col_hpositions*) const;
- virtual void add_column(PCol *, bool fixed=false, Real fixpos=0.0);
+ virtual void solve (Col_hpositions*) const;
+ virtual void lower_bound_solution (Col_hpositions*) const;
+ virtual void add_column (PCol *, bool fixed=false, Real fixpos=0.0);
virtual Vector default_solution() const;
- virtual bool check_constraints(Vector v) const;
+ virtual bool check_constraints (Vector v) const;
virtual void OK() const;
virtual void print() const;
virtual void prepare();
int pos_i_;
- void set_staffsym(Staff_symbol * );
+ void set_staffsym (Staff_symbol * );
Staff_side();
- void add_support(Score_elem*);
+ void add_support (Score_elem*);
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
virtual Interval symbol_height() const;
- virtual void do_substitute_dependency(Score_elem *, Score_elem*);
+ virtual void do_substitute_dependency (Score_elem *, Score_elem*);
virtual void do_post_processing();
};
#endif // STAFF_SIDE_HH
public:
- void set_extent(PCol* p1, PCol* p2);
+ void set_extent (PCol* p1, PCol* p2);
DECLARE_MY_RUNTIME_TYPEINFO;
- Staff_symbol(int lines);
+ Staff_symbol (int lines);
Real inter_note_f()const;
int steps_i()const;
protected:
protected:
~Stem_beam_engraver();
- virtual void set_feature(Feature dir_i_);
- virtual bool do_try_request(Request*);
+ virtual void set_feature (Feature dir_i_);
+ virtual bool do_try_request (Request*);
virtual void do_process_requests();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
};
/* *************** */
- Stem(int staff_size_i);
+ Stem (int staff_size_i);
/// ensure that this Stem also encompasses the Notehead #n#
- void add(Note_head*n);
+ void add (Note_head*n);
DECLARE_MY_RUNTIME_TYPEINFO;
Real hpos_f()const;
void do_print() const;
- void set_stemend(Real);
+ void set_stemend (Real);
int get_default_dir();
int get_center_distance_from_top();
int get_center_distance_from_bottom();
int max_head_i() const;
int min_head_i() const;
protected:
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void do_pre_processing();
virtual Interval do_width() const;
Molecule* brew_molecule_p() const;
public:
Link_array<Line_of_score> lines_arr_;
Line_of_score * line_of_score_l_;
- void add_broken_line(Line_of_score*);
+ void add_broken_line (Line_of_score*);
Super_elem();
virtual String TeX_string()const;
protected:
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void handle_broken_dependencies();
virtual void do_add_processing();
*/
class Swallow_engraver : public Engraver {
protected:
- bool acceptable_request_b(Request*) const;
- bool do_try_request(Request*) ;
+ bool acceptable_request_b (Request*) const;
+ bool do_try_request (Request*) ;
public:
DECLARE_MY_RUNTIME_TYPEINFO;
};
public:
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual bool do_try_request (Request* ) { return true; }
+ virtual bool do_try_request (Request*) { return true; }
};
#endif // SWALLOW_PERF_HH
/* *************** */
- void translate(Offset o) {
+ void translate (Offset o) {
off_ += o;
}
- void translate(Real r,Axis a){
+ void translate (Real r,Axis a){
off_[a] += r;
}
/// how big is #this#?
Box extent() const;
- Atom(Symbol s);
+ Atom (Symbol s);
void print() const;
struct Symtable : public Assoc<String, Symbol> {
String id_str;
- Symbol lookup(String)const;
+ Symbol lookup (String)const;
void print()const;
};
Symtable* operator()(String s);
~Symtables();
Symtables();
- Symtables(Symtables const&);
- void add(String, Symtable*);
+ Symtables (Symtables const&);
+ void add (String, Symtable*);
void print()const;
};
int line_len_i_;
/// open a file for writing
- Tex_stream(String filename);
+ Tex_stream (String filename);
void header();
/// delegate conversion to string class.
Tex_stream &operator<<(String);
/// close the file
~Tex_stream();
private:
- Tex_stream(Tex_stream const&);
+ Tex_stream (Tex_stream const&);
};
#endif
this function provides a simple macro mechanism:
if source == "tex%bla%", then
- substitute_args(source, {"X","Y"}) == "texXblaY"
+ substitute_args (source, {"X","Y"}) == "texXblaY"
*/
String
-substitute_args(String source, Array<String> args);
+substitute_args (String source, Array<String> args);
/// parameter substitution in TeX_strings
String
-substitute_args(String source, Array<Scalar> args);
+substitute_args (String source, Array<Scalar> args);
/// #h# is in points
-String vstrut(Real h);
+String vstrut (Real h);
#endif
class Text_def : public General_script_def {
protected:
- virtual Atom get_atom(Paper_def* p, int dir_i_)const;
+ virtual Atom get_atom (Paper_def* p, int dir_i_)const;
DECLARE_MY_RUNTIME_TYPEINFO;
VIRTUAL_COPY_CONS(Text_def,General_script_def);
public:
virtual void do_print() const;
virtual ~Text_def() {};
- virtual bool do_equal_b(const General_script_def*)const;
+ virtual bool do_equal_b (const General_script_def*)const;
Text_def();
virtual void print() const;
- Interval width(Paper_def*) const;
+ Interval width (Paper_def*) const;
};
#endif // TEXT_DEF_HH
int dir_i_;
/* *************** */
protected:
- virtual void set_feature(Feature );
- virtual bool do_try_request(Request*);
+ virtual void set_feature (Feature);
+ virtual bool do_try_request (Request*);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
public:
Text_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
print a fixed width text above or below the staff.
*/
class Text_item : public Item ,public Staff_side{
- void init(Text_def* tdef_l);
+ void init (Text_def* tdef_l);
public:
/* ***************/
- Text_item(General_script_def*,int dir=0);
+ Text_item (General_script_def*,int dir=0);
virtual ~Text_item();
DECLARE_MY_RUNTIME_TYPEINFO;
Offset text_off_;
DECLARE_MY_RUNTIME_TYPEINFO;
- void set_support(Directional_spanner*);
+ void set_support (Directional_spanner*);
Text_spanner();
- Text_spanner(Text_spanner const&);
+ Text_spanner (Text_spanner const&);
protected:
SCORE_ELEM_CLONE(Text_spanner);
~Text_spanner();
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void do_pre_processing();
virtual void do_post_processing();
virtual Interval height() const ;
protected:
virtual ~Tie_engraver();
- virtual void acknowledge_element(Score_elem_info);
- virtual bool do_try_request(Request*);
- virtual bool acceptable_request_b(Request*);
+ virtual void acknowledge_element (Score_elem_info);
+ virtual bool do_try_request (Request*);
+ virtual bool acceptable_request_b (Request*);
virtual void sync_features();
virtual void do_process_requests();
virtual void do_post_move_processing();
virtual void do_pre_move_processing();
- virtual void set_feature(Feature);
+ virtual void set_feature (Feature);
public:
Tie_engraver();
DECLARE_MY_RUNTIME_TYPEINFO;
virtual void do_add_processing();
virtual void do_post_processing();
virtual void set_default_dir();
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
public:
bool same_pitch_b_;
Note_head * left_head_l_;
Note_head * right_head_l_;
- void set_head(int, Note_head*head_l);
+ void set_head (int, Note_head*head_l);
Tie();
DECLARE_MY_RUNTIME_TYPEINFO;
int bars_i_;
/* *************** */
- void set_cadenza(bool);
+ void set_cadenza (bool);
void OK() const;
Time_description();
- void add(Moment dt);
+ void add (Moment dt);
bool allow_meter_change_b();
String str()const;
void print() const;
- void setpartial(Moment p);
- String try_set_partial_str(Moment)const;
+ void setpartial (Moment p);
+ String try_set_partial_str (Moment)const;
Moment barleft()const;
Moment next_bar_moment()const;
- void set_meter(int,int);
+ void set_meter (int,int);
static int compare (const Time_description&, const Time_description&);
};
#include "compare.hh"
-instantiate_compare(Time_description&,Time_description::compare);
+INSTANTIATE_COMPARE(Time_description&,Time_description::compare);
void
-process_timing_reqs(Time_description &time_,
+process_timing_reqs (Time_description &time_,
Rhythmic_grouping *default_grouping,
Array<Timing_req*> const& timing_req_l_arr);
#endif // Time_description_HH
Link_array<Timing_req> timing_req_l_arr_;
- virtual void fill_staff_info(Staff_info&);
- virtual bool do_try_request(Request *req_l);
+ virtual void fill_staff_info (Staff_info&);
+ virtual bool do_try_request (Request *req_l);
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_creation_processing();
virtual void print()const;
virtual int depth_i()const=0;
virtual bool is_bottom_engraver_b() const { return false; }
- virtual bool try_request(Request*);
- virtual Translator *find_get_translator_l(String name, String id)=0;
- virtual Translator *ancestor_l(int l=1)=0;
+ virtual bool try_request (Request*);
+ virtual Translator *find_get_translator_l (String name, String id)=0;
+ virtual Translator *ancestor_l (int l=1)=0;
virtual ~Translator(){}
DECLARE_MY_RUNTIME_TYPEINFO;
Translator();
class Vertical_align_element : virtual public Score_elem {
Link_array<Score_elem> elem_l_arr_;
public:
- void add(Score_elem*);
- bool contains_b(Score_elem const*)const;
+ void add (Score_elem*);
+ bool contains_b (Score_elem const*)const;
Vertical_align_element();
DECLARE_MY_RUNTIME_TYPEINFO;
protected:
- virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_substitute_dependency (Score_elem*,Score_elem*);
virtual void do_post_processing() ;
};
#endif // VERTICAL_ALIGN_ITEM_HH
DECLARE_MY_RUNTIME_TYPEINFO;
Vertical_align_engraver();
protected:
- virtual void acknowledge_element(Score_elem_info);
+ virtual void acknowledge_element (Score_elem_info);
virtual void do_creation_processing();
virtual void do_removal_processing();
};
public:
DECLARE_MY_RUNTIME_TYPEINFO;
SCORE_ELEM_CLONE(Vertical_align_spanner);
- virtual void do_print() const { Vertical_align_element::do_print() ; }
+ virtual void do_print() const { Vertical_align_element::do_print () ; }
};
#endif // VERTICAL_ALIGN_SPANNER_HH
{
protected:
SCORE_ELEM_CLONE(Vertical_group_spanner);
- virtual void remove_all() { Vertical_group_element::remove_all(); }
+ virtual void remove_all() { Vertical_group_element::remove_all (); }
public:
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual void add_element(Score_elem*e) { Vertical_group_element::add_element(e); }
- virtual void remove_element(Score_elem*e) { Vertical_group_element::remove_element(e); }
+ virtual void add_element (Score_elem*e) { Vertical_group_element::add_element (e); }
+ virtual void remove_element (Score_elem*e) { Vertical_group_element::remove_element (e); }
};
#include "engraver-group.hh"
/**
- A group of voices which share certain characteristics (such as beams. ).
+ A group of voices which share certain characteristics (such as beams.).
*/
class Voice_group_engravers : public Engraver_group_engraver {
Moment termination_mom_;
protected:
virtual void do_print() const;
- virtual Scalar get_feature(String);
- virtual bool do_try_request(Request*);
+ virtual Scalar get_feature (String);
+ virtual bool do_try_request (Request*);
public:
DECLARE_MY_RUNTIME_TYPEINFO;
- static bool static_acceptable_request_b(Request*);
+ static bool static_acceptable_request_b (Request*);
Voice_group_engravers();
};
#endif // VOICEGROUPGRAVS_HH