CPPLapack
 All Classes Files Functions Variables Friends Pages
dgematrix-constructor.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! dgematrix constructor without arguments */
4 {CPPL_VERBOSE_REPORT;
5  //////// initialize ////////
6  m =0;
7  n =0;
8  array =NULL;
9  darray =NULL;
10 }
11 
12 ///////////////////////////////////////////////////////////////////////////////
13 ///////////////////////////////////////////////////////////////////////////////
14 ///////////////////////////////////////////////////////////////////////////////
15 
16 //=============================================================================
17 /*! dgematrix copy constructor */
18 inline dgematrix::dgematrix(const dgematrix& mat)
19 {CPPL_VERBOSE_REPORT;
20  //////// initialize ////////
21  m =mat.m;
22  n =mat.n;
23  array =new double[m*n];
24  darray =new double*[n];
25  for(int i=0; i<n; i++){
26  darray[i] =&array[i*m];
27  }
28 
29  //////// copy ////////
30  CPPL_INT mn =m*n;
31  CPPL_INT inc =1;
32  dcopy_(&mn, mat.array, &inc, array, &inc);
33 }
34 
35 //=============================================================================
36 /*! dgematrix constructor to cast _dgematrix */
37 inline dgematrix::dgematrix(const _dgematrix& mat)
38 {CPPL_VERBOSE_REPORT;
39  m =mat.m;
40  n =mat.n;
41  array =mat.array;
42  darray =mat.darray;
43 
44  mat.nullify();
45 }
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 ///////////////////////////////////////////////////////////////////////////////
49 ///////////////////////////////////////////////////////////////////////////////
50 
51 //=============================================================================
52 /*! dgematrix constructor with size specification */
53 inline dgematrix::dgematrix(const CPPL_INT& _m, const CPPL_INT& _n)
54 {CPPL_VERBOSE_REPORT;
55 #ifdef CPPL_DEBUG
56  if( _m<0 || _n<0 ){
57  ERROR_REPORT;
58  std::cerr << "Matrix sizes must be positive integers. " << std::endl
59  << "Your input was (" << _m << "," << _n << ")." << std::endl;
60  exit(1);
61  }
62 #endif//CPPL_DEBUG
63 
64  //////// initialize ////////
65  m =_m;
66  n =_n;
67  array =new double[m*n];
68  darray =new double*[n];
69  for(int i=0; i<n; i++){
70  darray[i] =&array[i*m];
71  }
72 }
73 
74 //=============================================================================
75 /*! dgematrix constructor with filename */
76 inline dgematrix::dgematrix(const char* filename)
77 {CPPL_VERBOSE_REPORT;
78  array =NULL;
79  darray =NULL;
80 
81  //// read ////
82  read(filename);
83 }
84 
85 ///////////////////////////////////////////////////////////////////////////////
86 ///////////////////////////////////////////////////////////////////////////////
87 ///////////////////////////////////////////////////////////////////////////////
88 
89 //=============================================================================
90 /*! dgematrix destructor */
92 {CPPL_VERBOSE_REPORT;
93  delete [] darray;
94  delete [] array;
95 }
CPPL_INT m
matrix row size
Definition: dgematrix.hpp:9
double ** darray
array of pointers of column head addresses
Definition: dgematrix.hpp:12
double * array
1D array to store matrix data
Definition: dgematrix.hpp:11
void read(const char *)
double ** darray
array of pointers of column head addresses
Definition: _dgematrix.hpp:12
CPPL_INT n
matrix column size
Definition: dgematrix.hpp:10
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
CPPL_INT m
matrix row size
Definition: _dgematrix.hpp:9
double * array
1D array to store matrix data
Definition: _dgematrix.hpp:11
void nullify() const
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
CPPL_INT n
matrix column size
Definition: _dgematrix.hpp:10
friend _dgematrix i(const dgematrix &)