MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
JacSubMatrix.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/JacSubMatrix.cc,v 1.21 2011/05/22 20:41:59 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 2003
7  *
8  * Marco Morandini <morandini@aero.polimi.it>
9  *
10  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
11  * via La Masa, 34 - 20156 Milano, Italy
12  * http://www.aero.polimi.it
13  *
14  * Changing this copyright notice is forbidden.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation (version 2 of the License).
19  *
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 /* here goes Morandini's copyright */
32 
33 /* Portions Copyright (C) 2009 Pierangelo Masarati <masarati@aero.polimi.it> */
34 
35 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
36 
37 #include <algorithm>
38 #include <iomanip>
39 
40 #include "myassert.h"
41 #include "JacSubMatrix.h"
42 
44 
47  ReDim(n);
48 }
51  //we have to accept = 0, some elements do ReDim(0,0) (PointForceElement))
52  ASSERTMSGBREAK(n>=0, "ExpandableRowVector:ReDim(), n shold be >= 0");
53 // std::cerr << "ExpandableRowVector::ReDim(" << n << ")" << std::endl;
54 // std::cerr << "----------------------" << std::endl;
55  v.resize(n, er_Zero);
56 }
58  return v.size();
59 };
61  for (std::vector<ExpandableRowElement>::iterator i = v.begin(); i != v.end(); ++i) {
62  i->x = 0.;
63  }
64 }
66  std::fill(v.begin(), v.end(), er_Zero);
67 }
68 void ExpandableRowVector::Link(const integer i, const ExpandableRowVector*const xp, const integer rhs_block) {
69  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Link() underflow");
70  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Link() overflow");
71  ASSERTMSGBREAK(v[i - 1].idx == 0, "ExpandableRowVector::Link() fatal error");
72  if (std::vector<ExpandableRowVector *>::size_type(rhs_block) > v[ i - 1].xm.size()) {
73  v[ i - 1].xm.resize(rhs_block);
74  }
75  v[i - 1].xm[rhs_block - 1] = xp;
76 }
78  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Set() underflow");
79  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Set() overflow");
80  v[i - 1].x = xx;
81 }
83  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Set() underflow");
84  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i+3) <= v.size(), "ExpandableRowVector::Set() overflow");
85  v[i - 1].x = xx(1);
86  v[i - 0].x = xx(2);
87  v[i + 1].x = xx(3);
88 }
90  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::SetIdx() underflow");
91  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::SetIdx() overflow");
92 // std::cerr << "ExpandableRowVector::SetIdx(" << i <<", " << iidx << ")" << std::endl;
93  v[i - 1].idx = iidx;
94 }
96  Set(xx, i);
97  SetIdx(i, iidx);
98 }
100  Set(xx, i);
101  SetIdx(i, iidx);
102  SetIdx(i+1, iidx+1);
103  SetIdx(i+2, iidx+2);
104 }
105 doublereal&
107 {
108  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
109  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
110  return v[i - 1].x;
111 }
112 const doublereal&
114 {
115  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
116  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
117  return v[i - 1].x;
118 }
120  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Add() underflow");
121  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Add() overflow");
122  v[i - 1].x += xx;
123 }
125  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Sub() underflow");
126  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Sub() overflow");
127  v[i - 1].x -= xx;
128 }
130  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
131  if (v[i].x == 0.) {
132  continue;
133  }
134 
135  if (v[i].idx != 0) {
136  WorkVec.IncCoef(v[i].idx, c*v[i].x);
137  } else {
138  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
139  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
140  v[i].xm[rhs_block]->Add(WorkVec, c*v[i].x);
141  }
142  }
143  }
144 }
146  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
147  if (v[i].x == 0.) {
148  continue;
149  }
150 
151  if (v[i].idx != 0) {
152  WorkVec.DecCoef(v[i].idx, c*v[i].x);
153  } else {
154  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
155  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Sub() null pointer to ExpandableRowVector");
156  v[i].xm[rhs_block]->Sub(WorkVec, c*v[i].x);
157  }
158  }
159  }
160 }
162  const integer eq,
163  const doublereal c) const {
164 // std::cerr << "\t\t\tExpandableRowVector::Add" << std::endl;
165  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
166 // std::cerr << "\t\t\t\ti " << i << std::endl;
167 
168  if (v[i].x == 0.) {
169  continue;
170  }
171 
172  if (v[i].idx != 0) {
173 // std::cerr << "Adding("<< eq << ", " << v[i].idx << ") = " <<
174 // c*v[i].x << std::endl;
175 // std::cerr << "\t\t\t\tdentro if" << std::endl;
176  WM.IncCoef(eq, v[i].idx, c*v[i].x);
177  } else {
178 // std::cerr << "\t\t\t\tdentro else" << std::endl;
179  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
180 // std::cerr << "\t\t\t\t\trhs_block " << rhs_block << std::endl;
181 // std::cerr << "\t\t\t\t\t\trhs_block_ptr " << v[i].xm[rhs_block] << std::endl;
182  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
183  v[i].xm[rhs_block]->Add(WM, eq, c*v[i].x);
184  }
185  }
186  }
187 // std::cerr << "\t\t\t ---- ExpandableRowVector::Add" << std::endl;
188 }
190  const std::vector<integer>& eq,
191  const std::vector<doublereal>& cc,
192  const doublereal c) const
193 {
194  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
195  if (v[i].x == 0.) {
196  continue;
197  }
198 
199  integer idx = v[i].idx;
200  if (idx != 0) {
201  doublereal d = c*v[i].x;
202  for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
203  WM.IncCoef(eq[j], idx, cc[j]*d);
204  }
205  } else {
206  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
207  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
208  v[i].xm[rhs_block]->Add(WM, eq, cc, c*v[i].x);
209  }
210  }
211  }
212 }
214  const integer eq,
215  const doublereal c) const {
216  for (std::vector<ExpandableRowElement>::size_type i = 0 ; i < v.size(); i++) {
217  if (v[i].x == 0.) {
218  continue;
219  }
220 
221  if (v[i].idx != 0) {
222  WM.DecCoef(eq, v[i].idx, c*v[i].x);
223  } else {
224  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
225  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Sub() null pointer to ExpandableRowVector");
226  v[i].xm[rhs_block]->Sub(WM, eq, c*v[i].x);
227  }
228  }
229  }
230 }
232  const std::vector<integer>& eq,
233  const std::vector<doublereal>& cc,
234  const doublereal c) const
235 {
236  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
237  if (v[i].x == 0.) {
238  continue;
239  }
240 
241  integer idx = v[i].idx;
242  if (idx != 0) {
243  doublereal d = c*v[i].x;
244  for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
245  WM.DecCoef(eq[j], idx, cc[j]*d);
246  }
247  } else {
248  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
249  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
250  v[i].xm[rhs_block]->Sub(WM, eq, cc, c*v[i].x);
251  }
252  }
253  }
254 }
255 
256 std::ostream & ExpandableRowVector::Write(std::ostream &out, const char *sFill) const {
257  out << "LocalDof: ";
258  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
259  if (v[i].idx != 0) {
260  out << sFill << std::setw(12) << v[i].idx;
261  } else {
262  out << sFill << std::setw(12) << "linked";
263  }
264  }
265  out << std::endl;
266  out << " Value: ";
267  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
268  out << sFill << std::setw(12) << v[i].x;
269  }
270  out << std::endl;
271  return out;
272 }
273 
274 std::ostream & operator << (std::ostream & s, const ExpandableRowVector & z) {
275  return z.Write(s);
276 }
277 
278 // -------------------------------------
280 
281 
284  ReDim(n, m);
285 }
287 void ExpandableMatrix::ReDim(const integer n, const integer m) {
288  //we have to accept = 0, some elements do ReDim(0,0) (PointForceElement))
289  ASSERTMSGBREAK(n>=0, "ExpandableMatrix:ReDim(), n shold be >= 0");
290  ASSERTMSGBREAK(m>=0, "ExpandableMatrix:ReDim(), m shold be >= 0");
291  v.resize(m, ecb_Zero);
292  for (std::vector<ExpandableColBlock>::iterator i = v.begin(); i != v.end(); ++i) {
293  i->ReDim(n);
294  }
295 }
296 void ExpandableMatrix::SetBlockDim(const integer block, const integer ncols) {
297  ASSERTMSGBREAK(block>0, "ExpandableMatrix:SetBlockDim(), block shold be > 0");
298  ASSERTMSGBREAK(block <= GetNBlocks(), "ExpandableMatrix:SetBlockDim(), block shold be "
299  "<= GetNBlocks()");
300 // std::cerr << "ExpandableMatrix::SetBlockDim(" << block <<", " << ncols << ")" << std::endl;
301  int pippo = 0;
302  for (std::vector<ExpandableRowVector>::iterator i = v[block-1].rows.begin();
303  i != v[block-1].rows.end(); ++i)
304  {
305  pippo++;
306 // std::cerr << "\t" << pippo << std::endl;
307  i->ReDim(ncols);
308  }
309 }
311  for (std::vector<ExpandableColBlock>::iterator i = v.begin(); i != v.end(); ++i) {
312  i->Zero();
313  }
314 }
316  if (v.begin() != v.end() ) {
317  return v[0].GetBlockNRows();
318  } else {
319  return 0;
320  }
321 };
323  return v.size();
324 };
326  ASSERTMSGBREAK(block >= 0, "ExpandableMatrix:GetBlockNCols(), "
327  "block shold be >= 0");
328  ASSERTMSGBREAK((unsigned long)block < v.size(), "ExpandableMatrix:GetBlockNCols(), "
329  "block shold be < nblocks");
330  return v[block].GetBlockNCols();
331 }
333  for (std::vector<ExpandableColBlock>::iterator i = v.begin();
334  i != v.end(); ++i)
335  {
336  i->Reset();
337  }
338 }
339 
340 void ExpandableMatrix::Link(const integer i, const ExpandableMatrix*const xp) {
341  ASSERTMSGBREAK(i > 0, "ExpandableMatrix::Link() underflow");
342  ASSERTMSGBREAK(std::vector<ExpandableColBlock>::size_type(i) <= v.size(), "ExpandableMatrix::Link() overflow");
343  //FIXME
344  //ASSERTMSGBREAK(v[i - 1].idx == 0, "ExpandableMatrix::Link() fatal error");
345  ASSERTMSGBREAK(v[i - 1].GetBlockNCols() == xp->GetNRows(),
346  "ExpandableMatrix::Link() dimension mismatch");
347  v[i - 1].Link(xp);
348 }
349 
350 void ExpandableMatrix::Link(const integer i, const ExpandableRowVector*const xp) {
351  ASSERTMSGBREAK(i > 0, "ExpandableMatrix::Link() underflow");
352  ASSERTMSGBREAK(std::vector<ExpandableColBlock>::size_type(i) <= v.size(), "ExpandableMatrix::Link() overflow");
353  //FIXME
354  //ASSERTMSGBREAK(v[i - 1].idx == 0, "ExpandableMatrix::Link() fatal error");
355  ASSERTMSGBREAK(v[i - 1].GetBlockNCols() == 1,
356  "ExpandableMatrix::Link() dimension mismatch");
357  v[i - 1].Link(xp);
358 }
359 
361  ASSERTMSGBREAK(eq > 0, "ExpandableMatrix::Set() underflow");
362  ASSERTMSGBREAK(block > 0, "ExpandableMatrix::Set() underflow");
363  ASSERTMSGBREAK(block_col > 0, "ExpandableMatrix::Set() underflow");
364  ASSERTMSGBREAK(eq <= GetNRows(), "ExpandableRowVector::Set() overflow");
365  ASSERTMSGBREAK(block <= GetNBlocks(), "ExpandableRowVector::Set() overflow");
366  ASSERTMSGBREAK(block_col <= GetBlockNCols(block), "ExpandableRowVector::Set() overflow");
367  v[block - 1].rows[eq - 1].Set(xx, block_col);
368 }
369 void ExpandableMatrix::Set(Vec3 xx, integer eq, integer block, integer block_col) {
370  for (integer i = 0; i <3; i++) {
371  Set(xx(i + 1), eq + i, block, block_col);
372  }
373 }
374 void ExpandableMatrix::Set(Mat3x3 xx, integer eq, integer block, integer block_col) {
375  for (integer i = 0; i <3; i++) {
376  for (integer ii = 0; ii <3; ii++) {
377  Set(xx(i + 1, ii + 1), eq + i, block, block_col + ii);
378  }
379  }
380 }
382  ASSERTMSGBREAK(block > 0, "ExpandableMatrix::SetColIdx() underflow");
383  ASSERTMSGBREAK(block <= GetNBlocks(), "ExpandableMatrix::SetColIdx() overflow");
384 // std::cerr << "ExpandableMatrix::SetBlockIdx" << std::endl;
385  v[block - 1].SetColIdx(iidx);
386 }
387 // void ExpandableRowVector::Set(doublereal xx, integer block, integer i, integer iidx) {
388 // Set(xx, i);
389 // SetIdx(i, iidx);
390 // }
391 // doublereal&
392 // ExpandableRowVector::operator ()(integer i)
393 // {
394 // ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
395 // ASSERTMSGBREAK(std::vector<ExpandableRow>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
396 // return v[i - 1].x;
397 // }
398 // const doublereal&
399 // ExpandableRowVector::operator ()(integer i) const
400 // {
401 // ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
402 // ASSERTMSGBREAK(std::vector<ExpandableRow>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
403 // return v[i - 1].x;
404 // }
406  ASSERTMSGBREAK(eq > 0, "ExpandableMatrix::Add() underflow");
407  ASSERTMSGBREAK(block > 0, "ExpandableMatrix::Add() underflow");
408  ASSERTMSGBREAK(block_col > 0, "ExpandableMatrix::Add() underflow");
409  ASSERTMSGBREAK(eq <= GetNRows(), "ExpandableRowVector::Add() overflow");
410  ASSERTMSGBREAK(block <= GetNBlocks(), "ExpandableRowVector::Add() overflow");
411  ASSERTMSGBREAK(block_col <= GetBlockNCols(block), "ExpandableRowVector::Add() overflow");
412  v[block - 1].rows[eq - 1].Add(xx, block_col);
413 }
415  ASSERTMSGBREAK(eq > 0, "ExpandableMatrix::Sub() underflow");
416  ASSERTMSGBREAK(block > 0, "ExpandableMatrix::Sub() underflow");
417  ASSERTMSGBREAK(block_col > 0, "ExpandableMatrix::Sub() underflow");
418  ASSERTMSGBREAK(eq <= GetNRows(), "ExpandableRowVector::Sub() overflow");
419  ASSERTMSGBREAK(block <= GetNBlocks(), "ExpandableRowVector::Sub() overflow");
420  ASSERTMSGBREAK(block_col <= GetBlockNCols(block), "ExpandableRowVector::Sub() overflow");
421  v[block - 1].rows[eq - 1].Sub(xx, block_col);
422 }
423 void ExpandableMatrix::Add(Vec3 xx, integer eq, integer block, integer block_col) {
424  for (integer i = 0; i <3; i++) {
425  Add(xx(i + 1), eq + i, block, block_col);
426  }
427 }
428 void ExpandableMatrix::Add(Mat3x3 xx, integer eq, integer block, integer block_col) {
429  for (integer i = 0; i <3; i++) {
430  for (integer ii = 0; ii <3; ii++) {
431  Add(xx(i + 1, ii + 1), eq + i, block, block_col + ii);
432  }
433  }
434 }
435 void ExpandableMatrix::Sub(Vec3 xx, integer eq, integer block, integer block_col) {
436  for (integer i = 0; i <3; i++) {
437  Sub(xx(i + 1), eq + i, block, block_col);
438  }
439 }
440 void ExpandableMatrix::Sub(Mat3x3 xx, integer eq, integer block, integer block_col) {
441  for (integer i = 0; i <3; i++) {
442  for (integer ii = 0; ii <3; ii++) {
443  Sub(xx(i + 1, ii + 1), eq + i, block, block_col + ii);
444  }
445  }
446 }
447 // void ExpandableRowVector::Add(SubVectorHandler& WorkVec, const doublereal c) const {
448 // for (std::vector<ExpandableRow>::size_type i = 0; i < v.size(); i++) {
449 // if (v[i].x == 0.) {
450 // continue;
451 // }
452 //
453 // if (v[i].idx != 0) {
454 // WorkVec.Add(v[i].idx, c*v[i].x);
455 // } else {
456 // ASSERTMSGBREAK(v[i].xm != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
457 // v[i].xm->Add(WorkVec, c*v[i].x);
458 // }
459 // }
460 // }
461 // void ExpandableRowVector::Sub(SubVectorHandler& WorkVec, const doublereal c) const {
462 // for (std::vector<ExpandableRow>::size_type i = 0; i < v.size(); i++) {
463 // if (v[i].x == 0.) {
464 // continue;
465 // }
466 //
467 // if (v[i].idx != 0) {
468 // WorkVec.Sub(v[i].idx, c*v[i].x);
469 // } else {
470 // ASSERTMSGBREAK(v[i].xm != 0, "ExpandableRowVector::Sub() null pointer to ExpandableRowVector");
471 // v[i].xm->Sub(WorkVec, c*v[i].x);
472 // }
473 // }
474 // }
476  const integer eq,
477  const doublereal c) const {
478 // std::cerr << "ExpandableMatrix::Add" << std::endl;
479 // std::cerr << "\teq " << eq << std::endl;
480 // std::cerr << "\tc " << c << std::endl;
481  for (integer block = 0; block < GetNBlocks(); block++) {
482 // std::cerr << "\t\tblock " << block << std::endl;
483  v[block].Add(WM, eq, c);
484  }
485 }
486 // void ExpandableRowVector::Add(FullSubMatrixHandler& WM,
487 // const std::vector<integer>& eq,
488 // const std::vector<doublereal>& cc,
489 // const doublereal c) const
490 // {
491 // for (std::vector<ExpandableRow>::size_type i = 0; i < v.size(); i++) {
492 // if (v[i].x == 0.) {
493 // continue;
494 // }
495 //
496 // integer idx = v[i].idx;
497 // if (idx != 0) {
498 // doublereal d = c*v[i].x;
499 // for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
500 // WM.IncCoef(eq[j], idx, cc[j]*d);
501 // }
502 // } else {
503 // ASSERTMSGBREAK(v[i].xm != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
504 // v[i].xm->Add(WM, eq, cc, c*v[i].x);
505 // }
506 // }
507 // }
509  const integer eq,
510  const doublereal c) const {
511  for (integer block = 0; block < GetNBlocks(); block++) {
512  v[block].Sub(WM, eq, c);
513  }
514 }
515 // void ExpandableRowVector::Sub(FullSubMatrixHandler& WM,
516 // const std::vector<integer>& eq,
517 // const std::vector<doublereal>& cc,
518 // const doublereal c) const
519 // {
520 // for (std::vector<ExpandableRow>::size_type i = 0; i < v.size(); i++) {
521 // if (v[i].x == 0.) {
522 // continue;
523 // }
524 //
525 // integer idx = v[i].idx;
526 // if (idx != 0) {
527 // doublereal d = c*v[i].x;
528 // for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
529 // WM.DecCoef(eq[j], idx, cc[j]*d);
530 // }
531 // } else {
532 // ASSERTMSGBREAK(v[i].xm != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
533 // v[i].xm->Sub(WM, eq, cc, c*v[i].x);
534 // }
535 // }
536 // }
537 
538 std::ostream & ExpandableMatrix::Write(std::ostream &out, const char *sFill) const {
539  for (integer block = 0; block < GetNBlocks(); block++) {
540  out << "Block: " << block << std::endl;
541  v[block].Write(out, "\t");
542  }
543  return out;
544 }
545 
546 std::ostream & operator << (std::ostream & s, const ExpandableMatrix & z) {
547  return z.Write(s);
548 }
integer GetBlockNCols(const integer block) const
integer GetNRows() const
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
integer GetDim(void) const
Definition: JacSubMatrix.cc:57
void Set(doublereal xx, integer i, integer iidx)
Definition: JacSubMatrix.cc:95
std::vector< ExpandableColBlock > v
Definition: JacSubMatrix.h:89
Definition: matvec3.h:98
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void Add(doublereal xx, integer i)
std::ostream & operator<<(std::ostream &s, const ExpandableRowVector &z)
void Set(doublereal xx, integer eq, integer block, integer block_col=1)
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
static ExpandableMatrix::ExpandableColBlock ecb_Zero
void Sub(doublereal xx, integer eq, integer block, integer block_col=1)
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:683
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:694
virtual void DecCoef(integer iRow, const doublereal &dCoef)=0
void ReDim(const integer n)
Definition: JacSubMatrix.cc:50
static const char * eq[]
Definition: drvdisp.cc:196
void Add(doublereal xx, integer eq, integer block, integer block_col=1)
virtual ~ExpandableRowVector(void)
Definition: JacSubMatrix.cc:49
std::ostream & Write(std::ostream &out, const char *sFill="") const
void Link(const integer i, const ExpandableRowVector *const xp, const integer rhs_block=1)
Definition: JacSubMatrix.cc:68
void ReDim(const integer n, const integer m)
static std::stack< cleanup * > c
Definition: cleanup.cc:59
virtual ~ExpandableMatrix(void)
void SetIdx(integer i, integer iidx)
Definition: JacSubMatrix.cc:89
std::ostream & Write(std::ostream &out, const char *sFill="") const
void Sub(doublereal xx, integer i)
doublereal & operator()(integer i)
void Reset(void)
double doublereal
Definition: colamd.c:52
void SetBlockDim(const integer block, const integer ncols)
long int integer
Definition: colamd.c:51
void Link(const integer block, const ExpandableMatrix *const xp)
static ExpandableRowVector::ExpandableRowElement er_Zero
Definition: JacSubMatrix.cc:43
integer GetNBlocks() const
void SetBlockIdx(integer block, integer iidx)