source: Sophya/trunk/SophyaLib/TArray/triangmtx.h@ 919

Last change on this file since 919 was 914, checked in by ansari, 25 years ago

documentation cmv 13/4/00

File size: 2.0 KB
RevLine 
[762]1// This may look like C code, but it is really -*- C++ -*-
2
3#ifndef TRIANGMTX_H_SEEN
4#define TRIANGMTX_H_SEEN
5
6#include "ndatablock.h"
7#include "pexceptions.h"
8
9namespace SOPHYA {
10
[914]11//! Class for inferior triangular matrix (base class for the class Alm)
[762]12template <class T>
[914]13class TriangularMatrix {
14public :
[762]15
[914]16//! Default constructor
[762]17TriangularMatrix() {};
[914]18//! instanciate a triangular matrix from the number of rows
[762]19TriangularMatrix(int rowSize) : long_diag_((uint_4)rowSize) {elem_.ReSize((uint_4) (rowSize*(rowSize+1)/2) ); };
[914]20//! Copy constructor (possibility of sharing datas)
[762]21TriangularMatrix(const TriangularMatrix<T>& a, bool share=false) : elem_(a.elem_, share), long_diag_(a.long_diag_) {;}
[914]22
23//! resize the matrix with a new number of rows
[762]24inline void ReSizeRow(int rowSize)
25 {
26 long_diag_=(uint_4)rowSize;
27 elem_.ReSize(long_diag_*(long_diag_+1)/2);
28 }
29 inline void SetTemp(bool temp=false) const {elem_.SetTemp(temp);}
30
[914]31//! Equal operator
[762]32inline TriangularMatrix<T>& operator = (const TriangularMatrix<T>& a)
33{
34 elem_=a.elem_;
35 long_diag_ = a.long_diag_;
36 return *this;
37}
[914]38
39//! () operator : access to elements row \b l and column \b m
[762]40inline T& operator()(int l, int m)
41 {
42 return elem_(adr_ij(l,m));
43 }
[914]44//! () operator : access to elements row \b l and column \b m
[762]45inline T const& operator()(int l, int m) const
46 {
47 return *(elem_.Begin()+ adr_ij(l,m));
48 }
[914]49
50//! Return number of rows
51inline int_4 rowNumber() const {return (int_4)long_diag_;}
52
53private:
54//! compute the address of an element in the single array representing the matrix
[762]55inline uint_4 adr_ij(int i,int j) const
56{
57 int adr= i*(i+1)/2+j;
[862]58 // if ( adr >= elem_.Size() || adr <0 )
59 //{
60 // cout << " attention depassement dans triangularMatrix " << endl;
61 // cout << " l= " << i << " m= " << j << " tableau reserve longueur " << elem_.Size() << endl;
62 //}
[762]63 return(i*(i+1)/2+j);
64}
65
[914]66uint_4 long_diag_; //!< size of the square matrix
67NDataBlock<T> elem_; //!< Data block
[762]68
69 };
70
71} // namespace SOPHYA
72
73#endif
Note: See TracBrowser for help on using the repository browser.