home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / n / newmat06.zip / NEWMAT4.CXX < prev    next >
C/C++ Source or Header  |  1992-11-29  |  17KB  |  575 lines

  1. //$$ newmat4.cxx       Constructors, ReDimension, basic utilities
  2.  
  3. // Copyright (C) 1991,2: R B Davies
  4.  
  5. #include "include.h"
  6.  
  7. #include "newmat.h"
  8. #include "newmatrc.h"
  9.  
  10. //#define REPORT { static ExeCounter ExeCount(__LINE__,4); ExeCount++; }
  11.  
  12. #define REPORT {}
  13.  
  14. //#define REPORT1 { static ExeCounter ExeCount(__LINE__,4); ExeCount++; }
  15.  
  16. // REPORT1 constructors only - doesn't work in turbo and Borland C++
  17.  
  18. #define REPORT1 {}
  19.  
  20.  
  21. /*************************** general utilities *************************/
  22.  
  23. static int tristore(int n)                      // els in triangular matrix
  24. { return (n*(n+1))/2; }
  25.  
  26.  
  27. /****************************** constructors ***************************/
  28.  
  29. GeneralMatrix::GeneralMatrix()
  30. { store=0; storage=0; nrows=0; ncols=0; tag=-1; }
  31.  
  32. GeneralMatrix::GeneralMatrix(ArrayLengthSpecifier s)
  33. {
  34.    REPORT1
  35.    storage=s.Value(); tag=-1;
  36.    store = new Real [storage]; MatrixErrorNoSpace(store);
  37.    MONITOR_REAL_NEW("Make (GenMatrix)",storage,store)
  38. }
  39.  
  40. Matrix::Matrix(int m, int n) : GeneralMatrix(m*n)
  41. { REPORT1 nrows=m; ncols=n; }
  42.  
  43. SymmetricMatrix::SymmetricMatrix(ArrayLengthSpecifier n)
  44.    : GeneralMatrix(tristore(n.Value()))
  45. { REPORT1 nrows=n.Value(); ncols=n.Value(); }
  46.  
  47. UpperTriangularMatrix::UpperTriangularMatrix(ArrayLengthSpecifier n)
  48.    : GeneralMatrix(tristore(n.Value()))
  49. { REPORT1 nrows=n.Value(); ncols=n.Value(); }
  50.  
  51. LowerTriangularMatrix::LowerTriangularMatrix(ArrayLengthSpecifier n)
  52.    : GeneralMatrix(tristore(n.Value()))
  53. { REPORT1 nrows=n.Value(); ncols=n.Value(); }
  54.  
  55. DiagonalMatrix::DiagonalMatrix(ArrayLengthSpecifier m) : GeneralMatrix(m)
  56. { REPORT1 nrows=m.Value(); ncols=m.Value(); }
  57.  
  58. Matrix::Matrix(const BaseMatrix& M)
  59. {
  60.    REPORT1 CheckConversion(M);
  61.    GeneralMatrix* gmx=((BaseMatrix&)M).Evaluate(MatrixType::Rt);
  62.    GetMatrix(gmx);
  63. }
  64.  
  65. RowVector::RowVector(const BaseMatrix& M) : Matrix(M)
  66. {
  67.    if (nrows!=1)
  68.    {
  69.       Tracer tr("RowVector");
  70.       Throw(VectorException(*this));
  71.    }
  72. }
  73.  
  74. ColumnVector::ColumnVector(const BaseMatrix& M) : Matrix(M)
  75. {
  76.    if (ncols!=1)
  77.    {
  78.       Tracer tr("ColumnVector");
  79.       Throw(VectorException(*this));
  80.    }
  81. }
  82.  
  83. SymmetricMatrix::SymmetricMatrix(const BaseMatrix& M)
  84. {
  85.    REPORT1 CheckConversion(M);
  86.    GeneralMatrix* gmx=((BaseMatrix&)M).Evaluate(MatrixType::Sm);
  87.    GetMatrix(gmx);
  88. }
  89.  
  90. UpperTriangularMatrix::UpperTriangularMatrix(const BaseMatrix& M)
  91. {
  92.    REPORT1 CheckConversion(M);
  93.    GeneralMatrix* gmx=((BaseMatrix&)M).Evaluate(MatrixType::UT);
  94.    GetMatrix(gmx);
  95. }
  96.  
  97. LowerTriangularMatrix::LowerTriangularMatrix(const BaseMatrix& M)
  98. {
  99.    REPORT1 CheckConversion(M);
  100.    GeneralMatrix* gmx=((BaseMatrix&)M).Evaluate(MatrixType::LT);
  101.    GetMatrix(gmx);
  102. }
  103.  
  104. DiagonalMatrix::DiagonalMatrix(const BaseMatrix& M)
  105. {
  106.    REPORT1 CheckConversion(M);
  107.    GeneralMatrix* gmx=((BaseMatrix&)M).Evaluate(MatrixType::Dg);
  108.    GetMatrix(gmx);
  109. }
  110.  
  111. GeneralMatrix::~GeneralMatrix()
  112. {
  113.    if (store)
  114.    {
  115.       MONITOR_REAL_DELETE("Free (GenMatrix)",storage,store)
  116. #ifdef Version21
  117.       delete [] store;
  118. #else
  119.       delete [storage] store;
  120. #endif
  121.    }
  122. }
  123.  
  124. CroutMatrix::CroutMatrix(const BaseMatrix& m)
  125. {
  126.    REPORT1
  127.    Tracer tr("CroutMatrix");
  128.    GeneralMatrix* gm = ((BaseMatrix&)m).Evaluate(MatrixType::Rt);
  129.    GetMatrix(gm);
  130.    if (nrows!=ncols) Throw(NotSquareException(*this));
  131.    d=TRUE; sing=FALSE;
  132.    indx=new int [nrows]; MatrixErrorNoSpace(indx);
  133.    MONITOR_INT_NEW("Index (CroutMat)",nrows,indx)
  134.    ludcmp();
  135. }
  136.  
  137. CroutMatrix::~CroutMatrix()
  138. {
  139.    MONITOR_INT_DELETE("Index (CroutMat)",nrows,indx)
  140. #ifdef Version21
  141.    delete [] indx;
  142. #else
  143.    delete [nrows] indx;
  144. #endif
  145. }
  146.  
  147. //ReturnMatrixX::ReturnMatrixX(GeneralMatrix& gmx)
  148. //{
  149. //   REPORT1
  150. //   gm = gmx.Type().New();  MatrixErrorNoSpace(gm);
  151. //   gm->GetMatrix(&gmx);  gm->ReleaseAndDelete();
  152. //}
  153.  
  154. #ifndef TEMPS_DESTROYED_QUICKLY
  155.  
  156. GeneralMatrix::operator ReturnMatrixX() const
  157. {
  158.    REPORT
  159.    GeneralMatrix* gm = Type().New();  MatrixErrorNoSpace(gm);
  160.    gm->GetMatrix(this);  gm->ReleaseAndDelete();
  161.    return ReturnMatrixX(gm);
  162. }
  163.  
  164. #else
  165.  
  166. GeneralMatrix::operator ReturnMatrixX&() const
  167. {
  168.    REPORT
  169.    GeneralMatrix* gm = Type().New();  MatrixErrorNoSpace(gm);
  170.    gm->GetMatrix(this);  gm->ReleaseAndDelete();
  171.    ReturnMatrixX* x = new ReturnMatrixX(gm);
  172.    MatrixErrorNoSpace(x); return *x;
  173. }
  174.  
  175. #endif
  176.  
  177. /**************************** ReDimension matrices ***************************/
  178.  
  179. void GeneralMatrix::ReDimension(int nr, int nc, int s)
  180. {
  181.    REPORT 
  182.    if (store)
  183.    {
  184.       MONITOR_REAL_DELETE("Free (ReDimensi)",storage,store)
  185. #ifdef Version21
  186.       delete [] store;
  187. #else
  188.       delete [storage] store;
  189. #endif
  190.    }
  191.    storage=s; nrows=nr; ncols=nc; tag=-1;
  192.    store = new Real [storage]; MatrixErrorNoSpace(store);
  193.    MONITOR_REAL_NEW("Make (ReDimensi)",storage,store)
  194. }
  195.  
  196. void Matrix::ReDimension(int nr, int nc)
  197. { REPORT GeneralMatrix::ReDimension(nr,nc,nr*nc); }
  198.  
  199. void SymmetricMatrix::ReDimension(int nr)
  200. { REPORT GeneralMatrix::ReDimension(nr,nr,tristore(nr)); }
  201.  
  202. void UpperTriangularMatrix::ReDimension(int nr)
  203. { REPORT GeneralMatrix::ReDimension(nr,nr,tristore(nr)); }
  204.  
  205. void LowerTriangularMatrix::ReDimension(int nr)
  206. { REPORT GeneralMatrix::ReDimension(nr,nr,tristore(nr)); }
  207.  
  208. void DiagonalMatrix::ReDimension(int nr)
  209. { REPORT GeneralMatrix::ReDimension(nr,nr,nr); }
  210.  
  211. void RowVector::ReDimension(int nc)
  212. { REPORT GeneralMatrix::ReDimension(1,nc,nc); }
  213.  
  214. void ColumnVector::ReDimension(int nr)
  215. { REPORT GeneralMatrix::ReDimension(nr,1,nr); }
  216.  
  217.  
  218. /********************* manipulate types, storage **************************/
  219.  
  220. int GeneralMatrix::search(const BaseMatrix* s) const
  221. { REPORT return (s==this) ? 1 : 0; }
  222.  
  223. int MultipliedMatrix::search(const BaseMatrix* s) const
  224. { REPORT return bm1->search(s) + bm2->search(s); }
  225.  
  226. int ShiftedMatrix::search(const BaseMatrix* s) const
  227. { REPORT return bm->search(s); }
  228.  
  229. int NegatedMatrix::search(const BaseMatrix* s) const
  230. { REPORT return bm->search(s); }
  231.  
  232. int ConstMatrix::search(const BaseMatrix* s) const
  233. { REPORT return (s==cgm) ? 1 : 0; }
  234.  
  235. int ReturnMatrixX::search(const BaseMatrix* s) const
  236. { REPORT return (s==gm) ? 1 : 0; }
  237.  
  238. MatrixType Matrix::Type() const { return MatrixType::Rt; }
  239. MatrixType SymmetricMatrix::Type() const { return MatrixType::Sm; }
  240. MatrixType UpperTriangularMatrix::Type() const { return MatrixType::UT; }
  241. MatrixType LowerTriangularMatrix::Type() const { return MatrixType::LT; }
  242. MatrixType DiagonalMatrix::Type() const { return MatrixType::Dg; }
  243. MatrixType RowVector::Type() const { return MatrixType::RV; }
  244. MatrixType ColumnVector::Type() const { return MatrixType::CV; }
  245. MatrixType CroutMatrix::Type() const { return MatrixType::Ct; }
  246. MatrixType BandMatrix::Type() const { return MatrixType::BM; }
  247. MatrixType UpperBandMatrix::Type() const { return MatrixType::UB; }
  248. MatrixType LowerBandMatrix::Type() const { return MatrixType::LB; }
  249. MatrixType SymmetricBandMatrix::Type() const { return MatrixType::SB; }
  250. MatrixType RowedMatrix::Type() const { return MatrixType::RV; }
  251. MatrixType ColedMatrix::Type() const { return MatrixType::CV; }
  252. MatrixType DiagedMatrix::Type() const { return MatrixType::Dg; }
  253. MatrixType MatedMatrix::Type() const { return MatrixType::Rt; }
  254. MatrixType GetSubMatrix::Type() const { return mt; }
  255.  
  256. MatrixType AddedMatrix::Type() const
  257. { REPORT return bm1->Type() + bm2->Type(); }
  258.  
  259. MatrixType MultipliedMatrix::Type() const
  260. { REPORT return bm1->Type() * bm2->Type(); }
  261.  
  262. MatrixType SolvedMatrix::Type() const
  263. { REPORT return bm1->Type().i() * bm2->Type(); }
  264.  
  265. MatrixType SubtractedMatrix::Type() const
  266. { REPORT return bm1->Type() + bm2->Type(); }
  267.  
  268. MatrixType ShiftedMatrix::Type() const
  269. { REPORT return bm->Type().AddEqualEl(); }
  270.  
  271. MatrixType ScaledMatrix::Type() const { REPORT return bm->Type(); }
  272. MatrixType TransposedMatrix::Type() const { REPORT return bm->Type().t(); }
  273. MatrixType NegatedMatrix::Type() const { REPORT return bm->Type(); }
  274. MatrixType InvertedMatrix::Type() const { REPORT return bm->Type().i(); }
  275. MatrixType ConstMatrix::Type() const { REPORT return cgm->Type(); }
  276. MatrixType ReturnMatrixX::Type() const { REPORT return gm->Type(); }
  277.  
  278. /*
  279. int GeneralMatrix::NrowsV() const { return nrows; }
  280. int RowedMatrix::NrowsV() const { return 1; }
  281. int MatedMatrix::NrowsV() const { return nr; }
  282. int GetSubMatrix::NrowsV() const { return row_number; }
  283. int MultipliedMatrix::NrowsV() const  { return bm1->NrowsV(); }
  284. int ShiftedMatrix::NrowsV() const { return bm->NrowsV(); }
  285. int TransposedMatrix::NrowsV() const { return bm->NcolsV(); }
  286. int NegatedMatrix::NrowsV() const { return bm->NrowsV(); }
  287. int ColedMatrix::NrowsV() const { return bm->NrowsV() * bm->NcolsV(); }
  288. int DiagedMatrix::NrowsV() const { return bm->NrowsV() * bm->NcolsV(); }
  289. int ConstMatrix::NrowsV() const { return cgm->Nrows(); }
  290. int ReturnMatrixX::NrowsV() const { return gm->Nrows(); }
  291.  
  292. int GeneralMatrix::NcolsV() const { return ncols; }
  293. int ColedMatrix::NcolsV() const { return 1; }
  294. int MatedMatrix::NcolsV() const { return nc; }
  295. int GetSubMatrix::NcolsV() const { return col_number; }
  296. int MultipliedMatrix::NcolsV() const  { return bm2->NcolsV(); }
  297. int ShiftedMatrix::NcolsV() const { return bm->NcolsV(); }
  298. int TransposedMatrix::NcolsV() const { return bm->NrowsV(); }
  299. int NegatedMatrix::NcolsV() const { return bm->NcolsV(); }
  300. int RowedMatrix::NcolsV() const { return bm->NrowsV() * bm->NcolsV(); }
  301. int DiagedMatrix::NcolsV() const { return bm->NrowsV() * bm->NcolsV(); }
  302. int ConstMatrix::NcolsV() const { return cgm->Ncols(); }
  303. int ReturnMatrixX::NcolsV() const { return gm->Ncols(); }
  304. */
  305.  
  306. MatrixBandWidth BaseMatrix::BandWidth() const { return -1; }
  307. MatrixBandWidth DiagonalMatrix::BandWidth() const { return 0; }
  308.  
  309. MatrixBandWidth BandMatrix::BandWidth() const
  310.    { return MatrixBandWidth(lower,upper); }
  311.  
  312. MatrixBandWidth AddedMatrix::BandWidth() const
  313. { return gm1->BandWidth() + gm2->BandWidth(); }
  314.  
  315. MatrixBandWidth MultipliedMatrix::BandWidth() const
  316. { return gm1->BandWidth() * gm2->BandWidth(); }
  317.  
  318. MatrixBandWidth SolvedMatrix::BandWidth() const { return -1; }
  319. MatrixBandWidth ScaledMatrix::BandWidth() const { return gm->BandWidth(); }
  320. MatrixBandWidth NegatedMatrix::BandWidth() const { return gm->BandWidth(); }
  321.  
  322. MatrixBandWidth TransposedMatrix::BandWidth() const
  323. { return gm->BandWidth().t(); }
  324.  
  325. MatrixBandWidth InvertedMatrix::BandWidth() const { return -1; }
  326. MatrixBandWidth RowedMatrix::BandWidth() const { return -1; }
  327. MatrixBandWidth ColedMatrix::BandWidth() const { return -1; }
  328. MatrixBandWidth DiagedMatrix::BandWidth() const { return 0; }
  329. MatrixBandWidth MatedMatrix::BandWidth() const { return -1; }
  330. MatrixBandWidth ConstMatrix::BandWidth() const { return cgm->BandWidth(); }
  331. MatrixBandWidth ReturnMatrixX::BandWidth() const { return gm->BandWidth(); }
  332.  
  333. MatrixBandWidth GetSubMatrix::BandWidth() const
  334. {
  335.  
  336.    if (row_skip==col_skip && row_number==col_number) return gm->BandWidth();
  337.    else return MatrixBandWidth(-1);
  338. }
  339.  
  340.  
  341.  
  342. //  Rules regarding tDelete, reuse, GetStore
  343. //    All matrices processed during expression evaluation must be subject
  344. //    to exactly one of reuse(), tDelete(), GetStore() or BorrowStore().
  345. //    If reuse returns TRUE the matrix must be reused.
  346. //    GetMatrix(gm) always calls gm->GetStore()
  347. //    gm->Evaluate obeys rules
  348. //    bm->Evaluate obeys rules for matrices in bm structure
  349.  
  350. void GeneralMatrix::tDelete()
  351. {
  352.    if (tag<0)
  353.    {
  354.       if (tag<-1) { REPORT store=0; delete this; return; }  // borrowed
  355.       else { REPORT return; }
  356.    }
  357.    if (tag==1)
  358.    {
  359.       REPORT  MONITOR_REAL_DELETE("Free   (tDelete)",storage,store)
  360. #ifdef Version21
  361.       if (store) delete [] store;
  362. #else
  363.       if (store) delete [storage] store;
  364. #endif
  365.       store=0; tag=-1; return;
  366.    }
  367.    if (tag==0) { REPORT delete this; return; }
  368.    REPORT tag--; return;
  369. }
  370.  
  371. static void BlockCopy(int n, Real* from, Real* to)
  372. {
  373.    REPORT
  374.    int i = (n >> 3);
  375.    while (i--)
  376.    {
  377.       *to++ = *from++; *to++ = *from++; *to++ = *from++; *to++ = *from++;
  378.       *to++ = *from++; *to++ = *from++; *to++ = *from++; *to++ = *from++;
  379.    }
  380.    i = n & 7; while (i--) *to++ = *from++;
  381. }
  382.  
  383. Boolean GeneralMatrix::reuse()
  384. {
  385.    if (tag<-1)
  386.    {
  387.       REPORT
  388.       Real* s = new Real [storage]; MatrixErrorNoSpace(s);
  389.       MONITOR_REAL_NEW("Make     (reuse)",storage,s)
  390.       BlockCopy(storage, store, s); store=s; tag=0; return TRUE;
  391.    }
  392.    if (tag<0) { REPORT return FALSE; }
  393.    if (tag<=1)  { REPORT return TRUE; }
  394.    REPORT tag--; return FALSE;
  395. }
  396.  
  397. Real* GeneralMatrix::GetStore()
  398. {
  399.    if (tag<0 || tag>1)
  400.    {
  401.       Real* s = new Real [storage]; MatrixErrorNoSpace(s);
  402.       MONITOR_REAL_NEW("Make  (GetStore)",storage,s)
  403.       BlockCopy(storage, store, s);
  404.       if (tag>1) { REPORT tag--; }
  405.       else if (tag < -1) { REPORT store=0; delete this; } // borrowed store
  406.       else { REPORT }
  407.       return s;
  408.    }
  409.    Real* s=store; store=0;
  410.    if (tag==0) { REPORT delete this; }
  411.    else { REPORT tag=-1; }
  412.    return s;
  413. }
  414.  
  415. /*
  416. #ifndef __ZTC__
  417. void GeneralMatrix::GetMatrixC(const GeneralMatrix* gmx)
  418. {
  419.    REPORT tag=-1;
  420.    nrows=gmx->nrows; ncols=gmx->ncols; storage=gmx->storage;
  421.    SetParameters(gmx); 
  422.    store = new Real [storage]; MatrixErrorNoSpace(store);
  423.    MONITOR_REAL_NEW("Make (GetMatrix)",storage,store)
  424.    BlockCopy(storage, gmx->store, store);
  425. }
  426. #endif
  427. */
  428.  
  429. void GeneralMatrix::GetMatrix(const GeneralMatrix* gmx)
  430. {
  431.    REPORT  tag=-1; nrows=gmx->Nrows(); ncols=gmx->Ncols();
  432.    storage=gmx->storage; SetParameters(gmx);
  433.    store=((GeneralMatrix*)gmx)->GetStore();
  434. }
  435.  
  436. GeneralMatrix* GeneralMatrix::BorrowStore(GeneralMatrix* gmx, MatrixType mt)
  437. // Copy storage of *this to storage of *gmx. Then convert to type mt.
  438. // If mt == 0 just let *gm point to storage of *this if tag<0.
  439. {
  440.    if (!mt)
  441.    {
  442.       if (tag == -1) { REPORT gmx->tag = -2; gmx->store = store; }
  443.       else { REPORT gmx->tag = 0; gmx->store = GetStore(); }
  444.    }
  445.    else if (mt!=gmx->Type())
  446.    {
  447.       REPORT gmx->tag = -2; gmx->store = store;
  448.       gmx = gmx->Evaluate(mt); gmx->tag = 0; tDelete();
  449.    }
  450.    else { REPORT  gmx->tag = 0; gmx->store = GetStore(); }
  451.  
  452.    return gmx;
  453. }
  454.  
  455. void GeneralMatrix::Eq(const BaseMatrix& X, MatrixType mt)
  456. // Count number of references to this in X.
  457. // If zero delete storage in X;
  458. // otherwise tag X to show when storage can be deleted
  459. // evaluate X and copy to current object
  460. {
  461.    int counter=X.search(this);
  462.    if (counter==0)
  463.    {
  464.       REPORT
  465.       if (store)
  466.       {
  467.          MONITOR_REAL_DELETE("Free (operator=)",storage,store)
  468. #ifdef Version21
  469.          REPORT delete [] store; storage=0;
  470. #else
  471.          REPORT delete [storage] store; storage=0;
  472. #endif
  473.       }
  474.    }
  475.    else { REPORT Release(counter); }
  476.    GeneralMatrix* gmx = ((BaseMatrix&)X).Evaluate(mt);
  477.    if (gmx!=this) { REPORT GetMatrix(gmx); }
  478.    else { REPORT }
  479.    Protect();
  480. }
  481.  
  482. void GeneralMatrix::Inject(const GeneralMatrix& X)
  483. // copy stored values of X; otherwise leave els of *this unchanged
  484. {
  485.    REPORT
  486.    Tracer tr("Inject");
  487.    if (nrows != X.nrows || ncols != X.ncols)
  488.       Throw(IncompatibleDimensionsException());
  489.    MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry);
  490.    MatrixRow mrx(this, LoadOnEntry+StoreOnExit+DirectPart);
  491.    int i=nrows;
  492.    while (i--) { mrx.Inject(mr); mrx.Next(); mr.Next(); }
  493. }  
  494.  
  495. void GeneralMatrix::CheckConversion(const BaseMatrix& M)
  496. {
  497.    if (!(this->Type() >= M.Type()))
  498.       Throw(ProgramException("Illegal Conversion"));
  499. }
  500.  
  501.  
  502. /************************* nricMatrix routines *****************************/
  503.  
  504. void nricMatrix::MakeRowPointer()
  505. {
  506.    row_pointer = new Real* [nrows]; MatrixErrorNoSpace(row_pointer);
  507.    Real* s = Store() - 1; int i = nrows; Real** rp = row_pointer;
  508.    while (i--) { *rp++ = s; s+=ncols; }
  509. }
  510.  
  511. void nricMatrix::DeleteRowPointer()
  512. #ifdef Version21
  513. { if (nrows) delete [] row_pointer; }
  514. #else
  515. { if (nrows) delete [nrows] row_pointer; }
  516. #endif
  517.  
  518. void GeneralMatrix::CheckStore() const
  519. {
  520.    if (!store) 
  521.       Throw(ProgramException("NRIC accessing matrix with unset dimensions"));
  522. }
  523.  
  524.  
  525. /***************************** CleanUp routines *****************************/
  526.  
  527. void GeneralMatrix::CleanUp()
  528. {
  529.    // set matrix dimensions to zero, delete storage
  530.    REPORT
  531.    if (store && storage)
  532.    {
  533.       MONITOR_REAL_DELETE("Free (CleanUp)    ",storage,store)
  534. #ifdef Version21
  535.          REPORT delete [] store;
  536. #else
  537.          REPORT delete [storage] store;
  538. #endif
  539.    }
  540.    store=0; storage=0; nrows=0; ncols=0;
  541. }
  542.  
  543. void nricMatrix::CleanUp()
  544. { DeleteRowPointer(); GeneralMatrix::CleanUp(); }
  545.  
  546. void RowVector::CleanUp()
  547. { GeneralMatrix::CleanUp(); nrows=1; }
  548.  
  549. void ColumnVector::CleanUp()
  550. { GeneralMatrix::CleanUp(); ncols=1; }
  551.  
  552. void CroutMatrix::CleanUp()
  553. #ifdef Version21
  554.    if (nrows) delete [] indx;
  555. #else
  556.    if (nrows) delete [nrows] indx;
  557. #endif
  558.    GeneralMatrix::CleanUp();
  559. }
  560.  
  561. void BandLUMatrix::CleanUp()
  562. #ifdef Version21
  563.    if (nrows) delete [] indx;
  564.    if (storage2) delete [] store2;
  565. #else
  566.    if (nrows) delete [nrows] indx;
  567.    if (storage2) delete [storage2] store2;
  568. #endif
  569.    GeneralMatrix::CleanUp();
  570. }
  571.  
  572.  
  573.