55 SetMatrix(iRows,iCols,afEntry);
63 SetMatrix(iRows,iCols,aafMatrix);
88 m_afData =
new Real[m_iQuantity];
91 memset(m_afData,0,m_iQuantity*
sizeof(Real));
94 m_aafEntry =
new Real*[m_iRows];
95 for (
int iRow = 0; iRow < m_iRows; iRow++)
97 m_aafEntry[iRow] = &m_afData[iRow*m_iCols];
101 template <
class Real>
108 template <
class Real>
112 if (iRows > 0 && iCols > 0)
116 m_iQuantity = m_iRows*m_iCols;
129 template <
class Real>
136 template <
class Real>
142 template <
class Real>
148 template <
class Real>
154 template <
class Real>
160 template <
class Real>
166 template <
class Real>
170 return m_aafEntry[iRow];
173 template <
class Real>
177 return m_aafEntry[iRow];
180 template <
class Real>
183 return m_aafEntry[iRow][iCol];
186 template <
class Real>
190 return m_aafEntry[iRow][iCol];
193 template <
class Real>
197 Real* afSave = m_aafEntry[iRow0];
198 m_aafEntry[iRow0] = m_aafEntry[iRow1];
199 m_aafEntry[iRow1] = afSave;
202 template <
class Real>
206 for (
int iCol = 0; iCol < m_iCols; iCol++)
208 m_aafEntry[iRow][iCol] = rkV[iCol];
212 template <
class Real>
217 for (
int iCol = 0; iCol < m_iCols; iCol++)
219 kV[iCol] = m_aafEntry[iRow][iCol];
224 template <
class Real>
228 for (
int iRow = 0; iRow < m_iRows; iRow++)
230 m_aafEntry[iRow][iCol] = rkV[iRow];
234 template <
class Real>
239 for (
int iRow = 0; iRow < m_iRows; iRow++)
241 kV[iRow] = m_aafEntry[iRow][iCol];
246 template <
class Real>
250 if (iRows > 0 && iCols > 0)
254 m_iQuantity = m_iRows*m_iCols;
256 size_t uiSize = m_iQuantity*
sizeof(Real);
257 memcpy(m_afData,afData,uiSize);
269 template <
class Real>
273 if (iRows > 0 && iCols > 0)
277 m_iQuantity = m_iRows*m_iCols;
279 for (
int iRow = 0; iRow < m_iRows; iRow++)
281 for (
int iCol = 0; iCol < m_iCols; iCol++)
283 m_aafEntry[iRow][iCol] = aafEntry[iRow][iCol];
297 template <
class Real>
300 for (
int iRow = 0, i = 0; iRow < m_iRows; iRow++)
302 for (
int iCol = 0; iCol < m_iCols; iCol++)
304 afCMajor[i++] = m_aafEntry[iCol][iRow];
309 template <
class Real>
322 for (
int iRow = 0; iRow < m_iRows; iRow++)
324 for (
int iCol = 0; iCol < m_iCols; iCol++)
326 m_aafEntry[iRow][iCol] = rkM.
m_aafEntry[iRow][iCol];
342 template <
class Real>
345 return memcmp(m_afData,rkM.
m_afData,m_iQuantity*
sizeof(Real));
348 template <
class Real>
351 return CompareArrays(rkM) == 0;
354 template <
class Real>
357 return CompareArrays(rkM) != 0;
360 template <
class Real>
363 return CompareArrays(rkM) < 0;
366 template <
class Real>
369 return CompareArrays(rkM) <= 0;
372 template <
class Real>
375 return CompareArrays(rkM) > 0;
378 template <
class Real>
381 return CompareArrays(rkM) >= 0;
384 template <
class Real>
388 for (
int i = 0; i < m_iQuantity; i++)
395 template <
class Real>
399 for (
int i = 0; i < m_iQuantity; i++)
406 template <
class Real>
412 for (
int iRow = 0; iRow < kProd.
m_iRows; iRow++)
414 for (
int iCol = 0; iCol < kProd.
m_iCols; iCol++)
416 for (
int iMid = 0; iMid < m_iCols; iMid++)
418 kProd.
m_aafEntry[iRow][iCol] += m_aafEntry[iRow][iMid] *
426 template <
class Real>
430 for (
int i = 0; i < m_iQuantity; i++)
432 kProd.
m_afData[i] = fScalar*m_afData[i];
437 template <
class Real>
443 if (fScalar != (Real)0.0)
445 Real fInvScalar = ((Real)1.0)/fScalar;
446 for (i = 0; i < m_iQuantity; i++)
448 kQuot.
m_afData[i] = fInvScalar*m_afData[i];
453 for (i = 0; i < m_iQuantity; i++)
462 template <
class Real>
466 for (
int i = 0; i < m_iQuantity; i++)
473 template <
class Real>
477 const Real* afMEntry = rkM;
478 Real* afPEntry = kProd;
481 afPEntry[i] = fScalar*afMEntry[i];
486 template <
class Real>
489 for (
int i = 0; i < m_iQuantity; i++)
496 template <
class Real>
499 for (
int i = 0; i < m_iQuantity; i++)
506 template <
class Real>
509 for (
int i = 0; i < m_iQuantity; i++)
511 m_afData[i] *= fScalar;
516 template <
class Real>
521 if (fScalar != (Real)0.0)
523 Real fInvScalar = ((Real)1.0)/fScalar;
524 for (i = 0; i < m_iQuantity; i++)
526 m_afData[i] *= fInvScalar;
531 for (i = 0; i < m_iQuantity; i++)
540 template <
class Real>
544 for (
int iRow = 0; iRow < m_iRows; iRow++)
546 for (
int iCol = 0; iCol < m_iCols; iCol++)
548 kTranspose.
m_aafEntry[iCol][iRow] = m_aafEntry[iRow][iCol];
554 template <
class Real>
560 for (
int iRow = 0; iRow < kProd.
m_iRows; iRow++)
562 for (
int iCol = 0; iCol < kProd.
m_iCols; iCol++)
564 for (
int iMid = 0; iMid < m_iRows; iMid++)
566 kProd.
m_aafEntry[iRow][iCol] += m_aafEntry[iMid][iRow] *
574 template <
class Real>
580 for (
int iRow = 0; iRow < kProd.
m_iRows; iRow++)
582 for (
int iCol = 0; iCol < kProd.
m_iCols; iCol++)
584 for (
int iMid = 0; iMid < m_iCols; iMid++)
586 kProd.
m_aafEntry[iRow][iCol] += m_aafEntry[iRow][iMid] *
594 template <
class Real>
599 for (
int iRow = 0; iRow < m_iRows; iRow++)
601 for (
int iCol = 0; iCol < m_iCols; iCol++)
603 kProd[iRow] += m_aafEntry[iRow][iCol]*rkV[iCol];
610 template <
class Real>
615 Real* afPEntry = kProd;
616 for (
int iCol = 0; iCol < rkM.
GetColumns(); iCol++)
618 for (
int iRow = 0; iRow < rkM.
GetRows(); iRow++)
620 afPEntry[iCol] += rkV[iRow]*rkM[iRow][iCol];
626 template <
class Real>
631 return rkU.
Dot((*
this)*rkV);
634 template <
class Real>
638 if (GetRows() > 0 && GetRows() != GetColumns())
643 int iSize = GetRows();
646 int* aiColIndex =
new int[iSize];
647 int* aiRowIndex =
new int[iSize];
648 bool* abPivoted =
new bool[iSize];
649 memset(abPivoted,0,iSize*
sizeof(
bool));
651 int i1, i2, iRow = 0, iCol = 0;
655 for (
int i0 = 0; i0 < iSize; i0++)
658 Real fMax = (Real)0.0;
659 for (i1 = 0; i1 < iSize; i1++)
663 for (i2 = 0; i2 < iSize; i2++)
679 if (fMax == (Real)0.0)
688 abPivoted[iCol] =
true;
697 aiRowIndex[i0] = iRow;
698 aiColIndex[i0] = iCol;
701 Real fInv = ((Real)1.0)/rkInverse[iCol][iCol];
702 rkInverse[iCol][iCol] = (Real)1.0;
703 for (i2 = 0; i2 < iSize; i2++)
705 rkInverse[iCol][i2] *= fInv;
709 for (i1 = 0; i1 < iSize; i1++)
713 fSave = rkInverse[i1][iCol];
714 rkInverse[i1][iCol] = (Real)0.0;
715 for (i2 = 0; i2 < iSize; i2++)
717 rkInverse[i1][i2] -= rkInverse[iCol][i2]*fSave;
724 for (i1 = iSize-1; i1 >= 0; i1--)
726 if (aiRowIndex[i1] != aiColIndex[i1])
728 for (i2 = 0; i2 < iSize; i2++)
730 fSave = rkInverse[i2][aiRowIndex[i1]];
731 rkInverse[i2][aiRowIndex[i1]] =
732 rkInverse[i2][aiColIndex[i1]];
733 rkInverse[i2][aiColIndex[i1]] = fSave;
746 template <
class Real>
758 template <
class Real>
767 template <
class Real>
773 template <
class Real>
777 m_iSize = rkM.m_iSize;
778 m_iLBands = rkM.m_iLBands;
779 m_iUBands = rkM.m_iUBands;
782 size_t uiSize = m_iSize*
sizeof(Real);
783 memcpy(m_afDBand,rkM.m_afDBand,uiSize);
786 for (i = 0; i < m_iLBands; i++)
788 uiSize = (m_iSize-1-i)*
sizeof(Real);
789 memcpy(m_aafLBand[i],rkM.m_aafLBand[i],uiSize);
792 for (i = 0; i < m_iUBands; i++)
794 uiSize = (m_iSize-1-i)*
sizeof(Real);
795 memcpy(m_aafUBand[i],rkM.m_aafUBand[i],uiSize);
801 template <
class Real>
807 template <
class Real>
813 template <
class Real>
819 template <
class Real>
825 template <
class Real>
831 template <
class Real>
838 template <
class Real>
844 return m_aafLBand[i];
849 template <
class Real>
855 return m_aafLBand[i];
860 template <
class Real>
867 template <
class Real>
873 return m_aafUBand[i];
878 template <
class Real>
884 return m_aafUBand[i];
889 template <
class Real>
894 int iBand = iCol - iRow;
897 if (--iBand < m_iUBands && iRow < m_iSize-1-iBand)
899 return m_aafUBand[iBand][iRow];
902 else if ( iBand < 0 )
905 if (--iBand < m_iLBands && iCol < m_iSize-1-iBand)
907 return m_aafLBand[iBand][iCol];
912 return m_afDBand[iRow];
915 static Real s_fDummy = (Real)0.0;
919 template <
class Real>
924 int iBand = iCol - iRow;
927 if (--iBand < m_iUBands && iRow < m_iSize-1-iBand)
929 return m_aafUBand[iBand][iRow];
932 else if ( iBand < 0 )
935 if (--iBand < m_iLBands && iCol < m_iSize-1-iBand)
937 return m_aafLBand[iBand][iCol];
942 return m_afDBand[iRow];
948 template <
class Real>
953 memset(m_afDBand,0,m_iSize*
sizeof(Real));
956 for (i = 0; i < m_iLBands; i++)
958 memset(m_aafLBand[i],0,(m_iSize-1-i)*
sizeof(Real));
961 for (i = 0; i < m_iUBands; i++)
963 memset(m_aafUBand[i],0,(m_iSize-1-i)*
sizeof(Real));
967 template <
class Real>
973 for (i = 0; i < m_iSize; i++)
975 m_afDBand[i] = (Real)1.0;
978 for (i = 0; i < m_iLBands; i++)
980 memset(m_aafLBand[i],0,(m_iSize-1-i)*
sizeof(Real));
983 for (i = 0; i < m_iUBands; i++)
985 memset(m_aafUBand[i],0,(m_iSize-1-i)*
sizeof(Real));
989 template <
class Real>
995 m_afDBand =
new Real[m_iSize];
996 memset(m_afDBand,0,m_iSize*
sizeof(Real));
1000 m_aafLBand =
new Real*[m_iLBands];
1009 m_aafUBand =
new Real*[m_iUBands];
1017 for (i = 0; i < m_iLBands; i++)
1019 m_aafLBand[i] =
new Real[m_iSize-1-i];
1020 memset(m_aafLBand[i],0,(m_iSize-1-i)*
sizeof(Real));
1023 for (i = 0; i < m_iUBands; i++)
1025 m_aafUBand[i] =
new Real[m_iSize-1-i];
1026 memset(m_aafUBand[i],0,(m_iSize-1-i)*
sizeof(Real));
1030 template <
class Real>
1039 for (i = 0; i < m_iLBands; i++)
1041 delete[] m_aafLBand[i];
1044 delete[] m_aafLBand;
1050 for (i = 0; i < m_iUBands; i++)
1052 delete[] m_aafUBand[i];
1055 delete[] m_aafUBand;
void SetRow(int iRow, const moDVector< Real > &rkV)
moDBandedMatrix(int iSize, int iLBands, int iUBands)
Real operator()(int iRow, int iCol) const
moDMatrix operator-() const
void SetMatrix(int iRows, int iCols, const Real *afEntry)
moDMatrix & operator+=(const moDMatrix &rkM)
int CompareArrays(const moDMatrix &rkM) const
moDMatrix< Real > operator*(Real fScalar, const moDMatrix< Real > &rkM)
void SetSize(int iRows, int iCols)
Clase base abstracta de donde deben derivar los objetos [virtual pura].
moDBandedMatrix & operator=(const moDBandedMatrix &rkM)
Real Dot(const moDVector &rkV) const
void GetColumnMajor(Real *afCMajor) const
moDMatrix & operator*=(Real fScalar)
bool operator==(const moDMatrix &rkM) const
moDMatrix Transpose() const
moDMatrix operator/(Real fScalar) const
bool GetInverse(moDMatrix< Real > &rkInverse) const
bool operator!=(const moDMatrix &rkM) const
moDVector< Real > GetRow(int iRow) const
moDMatrix(int iRows=0, int iCols=0)
void Allocate(bool bSetToZero)
moDMatrix & operator/=(Real fScalar)
moDMatrix TransposeTimes(const moDMatrix &rkM) const
Real QForm(const moDVector< Real > &rkU, const moDVector< Real > &rkV) const
moDMatrix & operator=(const moDMatrix &rkM)
bool operator<(const moDMatrix &rkM) const
bool operator>(const moDMatrix &rkM) const
void SwapRows(int iRow0, int iRow1)
void GetSize(int &riRows, int &riCols) const
int GetLBandMax(int i) const
const Real * operator[](int iRow) const
moDVector< Real > GetColumn(int iCol) const
bool operator>=(const moDMatrix &rkM) const
int GetUBandMax(int i) const
static Real FAbs(Real fValue)
moDMatrix & operator-=(const moDMatrix &rkM)
moDMatrix TimesTranspose(const moDMatrix &rkM) const
Real & operator()(int iRow, int iCol)
moDMatrix operator+(const moDMatrix &rkM) const
moDMatrix operator*(const moDMatrix &rkM) const
bool operator<=(const moDMatrix &rkM) const
void SetColumn(int iCol, const moDVector< Real > &rkV)