MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
MySubVectorHandler Class Reference

#include <submat.h>

Inheritance diagram for MySubVectorHandler:
Collaboration diagram for MySubVectorHandler:

Public Member Functions

 MySubVectorHandler (integer iSize)
 
 MySubVectorHandler (integer iSize, integer *piTmpRow, doublereal *pdTmpVec)
 
virtual ~MySubVectorHandler (void)
 
virtual doublerealpdGetVec (void) const
 
virtual integer iGetSize (void) const
 
virtual void Resize (integer iSize)
 
virtual void Reset (void)
 
void Detach (void)
 
void Attach (integer iSize, doublereal *pd, integer *pi, integer iMSize=0)
 
virtual void PutCoef (integer i, const doublereal &d)
 
virtual void IncCoef (integer i, const doublereal &d)
 
virtual void DecCoef (integer i, const doublereal &d)
 
virtual const doublerealdGetCoef (integer i) const
 
virtual const doublerealoperator() (integer iRow) const
 
virtual doublerealoperator() (integer iRow)
 
virtual void PutRowIndex (integer iSubRow, integer iRow)
 
virtual integer iGetRowIndex (integer iSubRow) const
 
virtual void PutItem (integer iSubRow, integer iRow, const doublereal &dCoef)
 
virtual VectorHandlerAddTo (VectorHandler &VH) const
 
virtual VectorHandlerAddTo (MyVectorHandler &VH) const
 
- Public Member Functions inherited from SubVectorHandler
virtual ~SubVectorHandler (void)
 
- Public Member Functions inherited from VectorHandler
virtual ~VectorHandler (void)
 
virtual void ResizeReset (integer)
 
virtual VectorHandleroperator+= (const SubVectorHandler &SubVH)
 
virtual doublereal Norm (void) const
 
virtual doublereal InnerProd (const VectorHandler &VH) const
 
- Public Member Functions inherited from MyVectorHandler
 MyVectorHandler (const MyVectorHandler &)
 
 MyVectorHandler (integer iSize=0, doublereal *pdTmpVec=NULL)
 
virtual ~MyVectorHandler (void)
 
void Detach (void)
 
void Attach (integer iSize, doublereal *pd, integer iMSize=0)
 
virtual void Add (integer iRow, const Vec3 &v)
 
virtual void Sub (integer iRow, const Vec3 &v)
 
virtual void Put (integer iRow, const Vec3 &v)
 
virtual VectorHandlerScalarAddMul (const VectorHandler &VH, const VectorHandler &VH1, const doublereal &d)
 
virtual VectorHandlerScalarAddMul (const VectorHandler &VH, const doublereal &d)
 
virtual VectorHandlerScalarMul (const VectorHandler &VH, const doublereal &d)
 
virtual VectorHandleroperator+= (const VectorHandler &VH)
 
virtual MyVectorHandleroperator+= (const MyVectorHandler &VH)
 
virtual VectorHandleroperator-= (const VectorHandler &VH)
 
virtual VectorHandleroperator*= (const doublereal &d)
 
virtual MyVectorHandleroperator-= (const MyVectorHandler &VH)
 
virtual VectorHandleroperator= (const VectorHandler &VH)
 
virtual MyVectorHandleroperator= (const MyVectorHandler &VH)
 
doublereal Dot (void) const
 

Protected Attributes

integerpiRowm1
 
- Protected Attributes inherited from MyVectorHandler
bool bOwnsMemory
 
integer iMaxSize
 
integer iCurSize
 
doublerealpdVecm1
 

Private Member Functions

 MySubVectorHandler (const MySubVectorHandler &)
 

Friends

std::ostream & operator<< (std::ostream &out, const SubVectorHandler &v)
 

Detailed Description

Definition at line 1465 of file submat.h.

Constructor & Destructor Documentation

MySubVectorHandler::MySubVectorHandler ( const MySubVectorHandler )
private
MySubVectorHandler::MySubVectorHandler ( integer  iSize)

Definition at line 1600 of file submat.cc.

References Resize().

1601 : MyVectorHandler(), piRowm1(NULL) {
1602  Resize(iSize);
1603 }
virtual void Resize(integer iSize)
Definition: submat.cc:1628
MyVectorHandler(const MyVectorHandler &)
Definition: vh.cc:321
integer * piRowm1
Definition: submat.h:1474

Here is the call graph for this function:

MySubVectorHandler::MySubVectorHandler ( integer  iSize,
integer piTmpRow,
doublereal pdTmpVec 
)

Definition at line 1605 of file submat.cc.

References ASSERT, MyVectorHandler::bOwnsMemory, MBDYN_EXCEPT_ARGS, piRowm1, and SAFENEWARR.

1607 : MyVectorHandler(iSize, pdTmpVec), piRowm1(0)
1608 {
1609  if (piTmpRow == 0) {
1610  /* ... because set by MyVectorHandler() */
1611  ASSERT(bOwnsMemory == true);
1612 
1613  if (pdTmpVec == 0) {
1614  silent_cerr("MySubVectorHandler(): illegal args" << std::endl);
1616  }
1617 
1618  SAFENEWARR(piRowm1, integer, iSize);
1619  }
1620 
1621  piRowm1--;
1622 #ifdef DEBUG
1623  IsValid();
1624 #endif /* DEBUG */
1625 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
MyVectorHandler(const MyVectorHandler &)
Definition: vh.cc:321
#define ASSERT(expression)
Definition: colamd.c:977
integer * piRowm1
Definition: submat.h:1474
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
long int integer
Definition: colamd.c:51
bool bOwnsMemory
Definition: vh.h:152
virtual MySubVectorHandler::~MySubVectorHandler ( void  )
inlinevirtual

Definition at line 1499 of file submat.h.

References Detach().

1499  {
1500  Detach();
1501  };
void Detach(void)
Definition: submat.cc:1694

Here is the call graph for this function:

Member Function Documentation

VectorHandler & MySubVectorHandler::AddTo ( VectorHandler VH) const
virtual

Implements SubVectorHandler.

Definition at line 1747 of file submat.cc.

References iGetSize(), VectorHandler::IncCoef(), MyVectorHandler::pdVecm1, and piRowm1.

1748 {
1749 #ifdef DEBUG
1750  IsValid();
1751  VH.IsValid();
1752 #endif /* DEBUG */
1753 
1754  for (integer i = iGetSize(); i > 0; i--) {
1755 #if 0
1756  /* FIXME: workaround for SchurVectorHandler... */
1757  VH(piRowm1[i]) += pdVecm1[i];
1758 #endif
1759  VH.IncCoef(piRowm1[i], pdVecm1[i]);
1760  }
1761 
1762  return VH;
1763 }
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: submat.h:1523
integer * piRowm1
Definition: submat.h:1474
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MySubVectorHandler::AddTo ( MyVectorHandler VH) const
virtual

Definition at line 1766 of file submat.cc.

References iGetSize(), MyVectorHandler::pdGetVec(), MyVectorHandler::pdVecm1, and piRowm1.

1767 {
1768 #ifdef DEBUG
1769  IsValid();
1770  VH.IsValid();
1771 #endif /* DEBUG */
1772 
1773  doublereal* pdm1 = VH.pdGetVec() - 1;
1774  for (integer i = iGetSize(); i > 0; i--) {
1775  pdm1[piRowm1[i]] += pdVecm1[i];
1776  }
1777  return VH;
1778 }
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: submat.h:1523
integer * piRowm1
Definition: submat.h:1474
double doublereal
Definition: colamd.c:52
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void MySubVectorHandler::Attach ( integer  iSize,
doublereal pd,
integer pi,
integer  iMSize = 0 
)

Definition at line 1714 of file submat.cc.

References MyVectorHandler::bOwnsMemory, Detach(), MyVectorHandler::iCurSize, MyVectorHandler::iMaxSize, MyVectorHandler::pdVecm1, and piRowm1.

1716 {
1717  if (bOwnsMemory && pdVecm1 != NULL) {
1718  Detach();
1719  bOwnsMemory = false;
1720  }
1721 
1722  iMaxSize = iCurSize = iSize;
1723  if (iMSize >= iSize) {
1724  iMaxSize = iMSize;
1725  }
1726 
1727  pdVecm1 = pd - 1;
1728  piRowm1 = pi - 1;
1729 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
void Detach(void)
Definition: submat.cc:1694
integer * piRowm1
Definition: submat.h:1474
bool bOwnsMemory
Definition: vh.h:152

Here is the call graph for this function:

virtual void MySubVectorHandler::DecCoef ( integer  i,
const doublereal d 
)
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1581 of file submat.h.

References MyVectorHandler::DecCoef().

1581  {
1583  };
virtual void DecCoef(integer iRow, const doublereal &dCoef)
Definition: vh.h:291

Here is the call graph for this function:

void MySubVectorHandler::Detach ( void  )

Definition at line 1694 of file submat.cc.

References MyVectorHandler::bOwnsMemory, MyVectorHandler::iCurSize, MyVectorHandler::iMaxSize, MyVectorHandler::pdVecm1, piRowm1, and SAFEDELETEARR.

Referenced by Attach(), and ~MySubVectorHandler().

1695 {
1696  if (bOwnsMemory) {
1697  if (pdVecm1 != NULL) {
1698  pdVecm1++;
1700 
1701  piRowm1++;
1703  }
1704 
1705  bOwnsMemory = false;
1706  }
1707 
1708  iMaxSize = iCurSize = 0;
1709  pdVecm1 = NULL;
1710  piRowm1 = NULL;
1711 }
integer iCurSize
Definition: vh.h:156
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
integer * piRowm1
Definition: submat.h:1474
bool bOwnsMemory
Definition: vh.h:152
virtual const doublereal& MySubVectorHandler::dGetCoef ( integer  i) const
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1588 of file submat.h.

References MyVectorHandler::dGetCoef().

Referenced by Modal::AssRes(), testSubVecAss(), and testSubVecAssMatVec().

1588  {
1589  return MyVectorHandler::dGetCoef(i);
1590  };
virtual const doublereal & dGetCoef(integer iRow) const
Definition: vh.h:304

Here is the call graph for this function:

integer MySubVectorHandler::iGetRowIndex ( integer  iSubRow) const
inlinevirtual

Implements SubVectorHandler.

Definition at line 1645 of file submat.h.

References ASSERT, MyVectorHandler::iCurSize, and piRowm1.

Referenced by Modal::AssRes(), and testSubVecAssMatVec().

1646 {
1647 #ifdef DEBUG
1648  IsValid();
1649  ASSERT((iSubRow > 0) && (iSubRow <= iCurSize));
1650 #endif /* DEBUG */
1651 
1652  return piRowm1[iSubRow];
1653 }
integer iCurSize
Definition: vh.h:156
#define ASSERT(expression)
Definition: colamd.c:977
integer * piRowm1
Definition: submat.h:1474
virtual integer MySubVectorHandler::iGetSize ( void  ) const
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1523 of file submat.h.

References MyVectorHandler::iGetSize().

Referenced by AddTo(), Modal::AssRes(), testSubVecAss(), and testSubVecAssMatVec().

1523  {
1524  return MyVectorHandler::iGetSize();
1525  };
virtual integer iGetSize(void) const
Definition: vh.h:255

Here is the call graph for this function:

virtual void MySubVectorHandler::IncCoef ( integer  i,
const doublereal d 
)
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1574 of file submat.h.

References MyVectorHandler::IncCoef().

1574  {
1576  };
virtual void IncCoef(integer iRow, const doublereal &dCoef)
Definition: vh.h:278

Here is the call graph for this function:

virtual const doublereal& MySubVectorHandler::operator() ( integer  iRow) const
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1592 of file submat.h.

References MyVectorHandler::operator()().

1592  {
1593  return MyVectorHandler::operator () (iRow);
1594  };
virtual const doublereal & operator()(integer iRow) const
Definition: vh.h:317

Here is the call graph for this function:

virtual doublereal& MySubVectorHandler::operator() ( integer  iRow)
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1596 of file submat.h.

References MyVectorHandler::operator()().

1596  {
1597  return MyVectorHandler::operator () (iRow);
1598  };
virtual const doublereal & operator()(integer iRow) const
Definition: vh.h:317

Here is the call graph for this function:

virtual doublereal* MySubVectorHandler::pdGetVec ( void  ) const
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1516 of file submat.h.

References MyVectorHandler::pdGetVec().

1516  {
1517  return MyVectorHandler::pdGetVec();
1518  };
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245

Here is the call graph for this function:

virtual void MySubVectorHandler::PutCoef ( integer  i,
const doublereal d 
)
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1567 of file submat.h.

References MyVectorHandler::PutCoef().

1567  {
1569  };
virtual void PutCoef(integer iRow, const doublereal &dCoef)
Definition: vh.h:261

Here is the call graph for this function:

void MySubVectorHandler::PutItem ( integer  iSubRow,
integer  iRow,
const doublereal dCoef 
)
inlinevirtual

Reimplemented from SubVectorHandler.

Definition at line 1656 of file submat.h.

References ASSERT, MyVectorHandler::iCurSize, MyVectorHandler::pdVecm1, and piRowm1.

1658 {
1659 #ifdef DEBUG
1660  IsValid();
1661  ASSERT((iSubRow > 0) && (iSubRow <= iCurSize));
1662  ASSERT(iRow > 0);
1663 #endif /* DEBUG */
1664 
1665  piRowm1[iSubRow] = iRow;
1666  pdVecm1[iSubRow] = dCoef;
1667 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
integer * piRowm1
Definition: submat.h:1474
void MySubVectorHandler::PutRowIndex ( integer  iSubRow,
integer  iRow 
)
inlinevirtual

Implements SubVectorHandler.

Definition at line 1633 of file submat.h.

References ASSERT, MyVectorHandler::iCurSize, and piRowm1.

1634 {
1635 #ifdef DEBUG
1636  IsValid();
1637  ASSERT((iSubRow > 0) && (iSubRow <= iCurSize));
1638  ASSERT(iRow > 0);
1639 #endif /* DEBUG */
1640 
1641  piRowm1[iSubRow] = iRow;
1642 }
integer iCurSize
Definition: vh.h:156
#define ASSERT(expression)
Definition: colamd.c:977
integer * piRowm1
Definition: submat.h:1474
virtual void MySubVectorHandler::Reset ( void  )
inlinevirtual

Reimplemented from MyVectorHandler.

Definition at line 1537 of file submat.h.

References MyVectorHandler::Reset().

Referenced by Modal::AssRes().

1537  {
1539  };
virtual void Reset(void)
Definition: vh.cc:459

Here is the call graph for this function:

void MySubVectorHandler::Resize ( integer  iSize)
virtual

Reimplemented from MyVectorHandler.

Definition at line 1628 of file submat.cc.

References ASSERT, MyVectorHandler::bOwnsMemory, MyVectorHandler::iCurSize, MyVectorHandler::iMaxSize, MBDYN_EXCEPT_ARGS, MyVectorHandler::pdVecm1, piRowm1, SAFEDELETEARR, and SAFENEWARR.

Referenced by Modal::AssRes(), and MySubVectorHandler().

1629 {
1630  if (iSize < 0) {
1631  silent_cerr("Negative size!" << std::endl);
1633  }
1634 
1635  ASSERT((piRowm1 == NULL && pdVecm1 == NULL)
1636  || (piRowm1 != NULL && pdVecm1 != NULL));
1637 
1638  if (!bOwnsMemory && piRowm1 != NULL) {
1639  if (iSize > iMaxSize) {
1640  silent_cerr("Can't resize to " << iSize
1641  << ": larger than max size " << iMaxSize
1642  << std::endl);
1644  }
1645  iCurSize = iSize;
1646 
1647  } else {
1648  if (piRowm1 != NULL) {
1649  if (iSize <= iMaxSize) {
1650  iCurSize = iSize;
1651 
1652  } else {
1653  doublereal* pd = NULL;
1654  SAFENEWARR(pd, doublereal, iSize);
1655  pd--;
1656 
1657  integer* pi = NULL;
1658  SAFENEWARR(pi, integer, iSize);
1659  pi--;
1660 
1661  for (integer i = iCurSize; i > 0; i--) {
1662  pd[i] = pdVecm1[i];
1663  pi[i] = piRowm1[i];
1664  }
1665 
1666  pdVecm1++;
1668 
1669  piRowm1++;
1671 
1672  pdVecm1 = pd;
1673  piRowm1 = pi;
1674  iMaxSize = iCurSize = iSize;
1675  }
1676 
1677  } else {
1678  if (iSize > 0) {
1679  bOwnsMemory = true;
1680 
1681  SAFENEWARR(pdVecm1, doublereal, iSize);
1682  pdVecm1--;
1683 
1684  SAFENEWARR(piRowm1, integer, iSize);
1685  piRowm1--;
1686 
1687  iMaxSize = iCurSize = iSize;
1688  }
1689  }
1690  }
1691 }
integer iCurSize
Definition: vh.h:156
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
#define ASSERT(expression)
Definition: colamd.c:977
integer * piRowm1
Definition: submat.h:1474
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
bool bOwnsMemory
Definition: vh.h:152

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const SubVectorHandler v 
)
friend

Definition at line 1781 of file submat.cc.

1782 {
1783 #ifdef DEBUG
1784  v.IsValid();
1785 #endif /* DEBUG */
1786 
1787  integer iRow = v.iGetSize();
1788 
1789  ASSERT(iRow > 0);
1790 
1791  for (integer i = 1; i <= iRow; i++) {
1792  out << std::setw(12) << v.iGetRowIndex(i)
1793  << " " << std::setw(12) << v(i) << std::endl;
1794  }
1795 
1796  return out << std::endl;
1797 }
virtual integer iGetSize(void) const =0
virtual integer iGetRowIndex(integer iSubRow) const =0
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Member Data Documentation

integer* MySubVectorHandler::piRowm1
protected

The documentation for this class was generated from the following files: