52 ASSERTMSGBREAK(n>=0,
"ExpandableRowVector:ReDim(), n shold be >= 0");
61 for (std::vector<ExpandableRowElement>::iterator i =
v.begin(); i !=
v.end(); ++i) {
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);
75 v[i - 1].xm[rhs_block - 1] = xp;
79 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::Set() overflow");
84 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i+3) <=
v.size(),
"ExpandableRowVector::Set() overflow");
91 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::SetIdx() overflow");
109 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::() overflow");
116 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::() overflow");
121 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::Add() overflow");
126 ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <=
v.size(),
"ExpandableRowVector::Sub() overflow");
130 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
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);
146 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
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);
165 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
179 for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block <
v[i].xm.size(); rhs_block++) {
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);
190 const std::vector<integer>&
eq,
191 const std::vector<doublereal>& cc,
194 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
202 for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
203 WM.
IncCoef(eq[j], idx, cc[j]*d);
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);
216 for (std::vector<ExpandableRowElement>::size_type i = 0 ; i <
v.size(); i++) {
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);
232 const std::vector<integer>&
eq,
233 const std::vector<doublereal>& cc,
236 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
244 for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
245 WM.
DecCoef(eq[j], idx, cc[j]*d);
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);
258 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
260 out << sFill << std::setw(12) <<
v[i].idx;
262 out << sFill << std::setw(12) <<
"linked";
267 for (std::vector<ExpandableRowElement>::size_type i = 0; i <
v.size(); i++) {
268 out << sFill << std::setw(12) <<
v[i].x;
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) {
297 ASSERTMSGBREAK(block>0,
"ExpandableMatrix:SetBlockDim(), block shold be > 0");
302 for (std::vector<ExpandableRowVector>::iterator i =
v[block-1].rows.begin();
303 i !=
v[block-1].rows.end(); ++i)
311 for (std::vector<ExpandableColBlock>::iterator i =
v.begin(); i !=
v.end(); ++i) {
316 if (
v.begin() !=
v.end() ) {
317 return v[0].GetBlockNRows();
327 "block shold be >= 0");
328 ASSERTMSGBREAK((
unsigned long)block <
v.size(),
"ExpandableMatrix:GetBlockNCols(), "
329 "block shold be < nblocks");
330 return v[block].GetBlockNCols();
333 for (std::vector<ExpandableColBlock>::iterator i =
v.begin();
342 ASSERTMSGBREAK(std::vector<ExpandableColBlock>::size_type(i) <=
v.size(),
"ExpandableMatrix::Link() overflow");
346 "ExpandableMatrix::Link() dimension mismatch");
352 ASSERTMSGBREAK(std::vector<ExpandableColBlock>::size_type(i) <=
v.size(),
"ExpandableMatrix::Link() overflow");
356 "ExpandableMatrix::Link() dimension mismatch");
363 ASSERTMSGBREAK(block_col > 0,
"ExpandableMatrix::Set() underflow");
367 v[block - 1].rows[eq - 1].Set(xx, block_col);
370 for (
integer i = 0; i <3; i++) {
371 Set(xx(i + 1), eq + i, block, 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);
382 ASSERTMSGBREAK(block > 0,
"ExpandableMatrix::SetColIdx() underflow");
385 v[block - 1].SetColIdx(iidx);
408 ASSERTMSGBREAK(block_col > 0,
"ExpandableMatrix::Add() underflow");
412 v[block - 1].rows[eq - 1].Add(xx, block_col);
417 ASSERTMSGBREAK(block_col > 0,
"ExpandableMatrix::Sub() underflow");
421 v[block - 1].rows[eq - 1].Sub(xx, block_col);
424 for (
integer i = 0; i <3; i++) {
425 Add(xx(i + 1), eq + i, block, 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);
436 for (
integer i = 0; i <3; i++) {
437 Sub(xx(i + 1), eq + i, block, 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);
483 v[block].Add(WM, eq, c);
512 v[block].Sub(WM, eq, c);
540 out <<
"Block: " << block << std::endl;
541 v[block].Write(out,
"\t");
integer GetBlockNCols(const integer block) const
#define ASSERTMSGBREAK(expr, msg)
integer GetDim(void) const
void Set(doublereal xx, integer i, integer iidx)
std::vector< ExpandableColBlock > v
std::vector< ExpandableRowElement > v
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)
ExpandableRowVector(void)
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
virtual void DecCoef(integer iRow, const doublereal &dCoef)=0
void ReDim(const integer n)
void Add(doublereal xx, integer eq, integer block, integer block_col=1)
virtual ~ExpandableRowVector(void)
std::ostream & Write(std::ostream &out, const char *sFill="") const
void Link(const integer i, const ExpandableRowVector *const xp, const integer rhs_block=1)
void ReDim(const integer n, const integer m)
static std::stack< cleanup * > c
virtual ~ExpandableMatrix(void)
void SetIdx(integer i, integer iidx)
std::ostream & Write(std::ostream &out, const char *sFill="") const
void Sub(doublereal xx, integer i)
doublereal & operator()(integer i)
void SetBlockDim(const integer block, const integer ncols)
void Link(const integer block, const ExpandableMatrix *const xp)
static ExpandableRowVector::ExpandableRowElement er_Zero
integer GetNBlocks() const
void SetBlockIdx(integer block, integer iidx)