Menu

[r91]: / trunk / include / small / dgematrix_small.hpp  Maximize  Restore  History

Download this file

54 lines (48 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//=============================================================================
//! Samll Real Double-precision General Dence Matrix Class
template<long m, long n> class dgematrix_small
{
public:
//////// data ////////
double array[m*n];
//////// constructor ////////
dgematrix_small(){;}
dgematrix_small(const double& x){
for(long k=0; k<m*n; k++){ array[k]=x; }
}
~dgematrix_small(){;}
//////// function ////////
double& operator()(const long& i, const long& j);
double operator()(const long& i, const long& j)const;
//long M(){ return m; }
//long N(){ return n; }
dgematrix_small<m,n>& zero(){
for(long k=0; k<m*n; k++){ array[k]=0.; }
return *this;
}
dgematrix_small<m,n>& identity(){
zero();
for(long k=0; k<std::min(m,n); k++){ (*this)(k,k)=1.; }
return *this;
}
dgematrix_small<m,n>& set(const long& i, const long& j, const double& v){
(*this)(i,j)=v;
return *this;
}
dcovector_small<m> col(const long& j) const{
dcovector_small<m> vec;
for(long i=0; i<m; i++){ vec(i)=(*this)(i,j); }
return vec;
}
void write(const char* filename) const;
void read(const char* filename);
_dgematrix to_dgematrix() const{
dgematrix mat(m,n);
for(long i=0; i<m; i++){
for(long j=0; j<n; j++){
mat(i,j)=(*this)(i,j);
}
}
return _(mat);
}
};
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.