1 /*!\file
2 * \author Matthias Elf
3 *
4 * \par License:
5 * This file is part of ABACUS - A Branch And CUt System
6 * Copyright (C) 1995 - 2003
7 * University of Cologne, Germany
8 *
9 * \par
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * \par
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * \par
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * \see http://www.gnu.org/copyleft/gpl.html
27 */
28
29 #include <ogdf/lib/abacus/row.h>
30
31 namespace abacus {
32
33
operator <<(std::ostream & out,const Row & rhs)34 std::ostream &operator<<(std::ostream& out, const Row &rhs)
35 {
36 double eps = rhs.glob_->machineEps();
37 const int rhsNnz = rhs.nnz();
38
39 for (int i = 0; i < rhsNnz; i++) {
40 int s = rhs.support(i);
41 double c = rhs.coeff(i);
42
43 char sign;
44 if (c < 0.0) {
45 sign = '-';
46 c = -c;
47 }
48 else sign = '+';
49
50 if (i > 0 || sign == '-') // do not print first \a '+' of row
51 out << sign << ' ';
52 if (c < 1.0 - eps || 1.0 + eps < c) // do not print coefficient 1
53 out << c << ' ';
54 out << 'x' << s << ' ';
55
56 if (i && !(i % 10)) out << std::endl;
57 }
58
59 return out << rhs.sense_ << ' ' << rhs.rhs();
60 }
61
62
copy(const Row & row)63 void Row::copy(const Row &row)
64 {
65 sense_ = row.sense_;
66 rhs_ = row.rhs_;
67
68 SparVec::copy(row);
69 }
70 }
71