Menu

[r164]: / trunk / include / dgbmatrix- / dgbmatrix-calc.hpp  Maximize  Restore  History

Download this file

35 lines (30 with data), 989 Bytes

 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
//=============================================================================
/*! return transposed dgbmatrix */
inline _dgbmatrix t(const dgbmatrix& mat)
{CPPL_VERBOSE_REPORT;
dgbmatrix newmat(mat.n, mat.m, mat.ku, mat.kl);
for(long i=0; i<newmat.m; i++){
for(long j=std::max(long(0),i-newmat.kl); j<std::min(newmat.n,i+newmat.ku+1); j++){
newmat(i,j) =mat(j,i);
}
}
return _(newmat);
}
//=============================================================================
/*! return its inverse matrix */
inline _dgematrix i(const dgbmatrix& mat)
{CPPL_VERBOSE_REPORT;
#ifdef CPPL_DEBUG
if(mat.m!=mat.n){
ERROR_REPORT;
std::cerr << "This matrix is not square and has no inverse matrix." << std::endl
<< "Your input was (" << mat.m << "x" << mat.n << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
dgbmatrix mat_cp(mat);
dgematrix mat_inv(mat.m,mat.n);
mat_inv.identity();
mat_cp.dgbsv(mat_inv);
return _(mat_inv);
}
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.