MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
dgeequ.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/dgeequ.cc,v 1.15 2017/01/12 14:43:53 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <sstream>
35 
36 #include "dgeequ.h"
37 
39 :dCondBefore(-1.),
40  dCondAfter(-1.),
41  uFlags(scale.uFlags),
42  bOK(true)
43 {
44 
45 }
46 
48 {
49 
50 }
51 
52 std::ostream& MatrixScaleBase::Report(std::ostream& os) const
53 {
55  && dCondBefore > 0 && dCondAfter > 0) {
56  os << "cond: (" << dCondBefore << ") " << dCondAfter << std::endl;
57  }
58 
61  vReport(os);
62  }
63 
64  return os;
65 }
66 
68 MatrixScaleBase::ScaleVector(VectorHandler& v, const std::vector<doublereal>& s)
69 {
70  if (static_cast<size_t>(v.iGetSize()) != s.size()) {
71  ASSERT(0);
73  }
74 
75  for (int i = 0; i < v.iGetSize(); ++i) {
76  v(i + 1) *= s[i];
77  }
78 
79  return v;
80 }
81 
83 {
84  nrows = mh.iGetNumRows();
85 
86  if (nrows <= 0) {
87  // error
89  "invalid null or negative row number");
90  }
91 
92  if (rowScale.empty()) {
93  rowScale.resize(nrows, 0.);
94  } else {
95  if (rowScale.size() != unsigned(nrows)) {
96  // error
98  "row number mismatch");
99  }
100  rowScale.assign(nrows, 0.);
101  }
102 }
103 
105 {
106  ncols = mh.iGetNumCols();
107 
108  if (ncols <= 0) {
109  // error
111  "invalid null or negative column number");
112  }
113 
114  if (colScale.empty()) {
115  colScale.resize(ncols, 0.);
116  } else {
117  if (colScale.size() != unsigned(ncols)) {
118  // error
120  "column number mismatch");
121  }
122  colScale.assign(ncols, 0.);
123  }
124 }
virtual integer iGetNumCols(void) const =0
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal dCondBefore
Definition: dgeequ.h:69
const unsigned uFlags
Definition: dgeequ.h:70
std::vector< doublereal > colScale
Definition: dgeequ.h:68
MatrixScaleBase(const SolutionManager::ScaleOpt &scale)
Definition: dgeequ.cc:38
virtual integer iGetSize(void) const =0
std::ostream & Report(std::ostream &os) const
Definition: dgeequ.cc:52
static VectorHandler & ScaleVector(VectorHandler &v, const std::vector< doublereal > &s)
Definition: dgeequ.cc:68
void PrepareCols(const MatrixHandler &mh, integer &ncols)
Definition: dgeequ.cc:104
virtual ~MatrixScaleBase()
Definition: dgeequ.cc:47
doublereal dCondAfter
Definition: dgeequ.h:69
Definition: mbdyn.h:77
#define ASSERT(expression)
Definition: colamd.c:977
std::vector< doublereal > rowScale
Definition: dgeequ.h:68
virtual std::ostream & vReport(std::ostream &os) const =0
void PrepareRows(const MatrixHandler &mh, integer &nrows)
Definition: dgeequ.cc:82
long int integer
Definition: colamd.c:51
virtual integer iGetNumRows(void) const =0