My Project
dgematrix-calc.hpp
1 //=============================================================================
3 inline _dgematrix t(const dgematrix& mat)
4 {
5 #ifdef CPPL_VERBOSE
6  std::cerr << "# [MARK] t(const dgematrix&)"
7  << std::endl;
8 #endif//CPPL_VERBOSE
9 
10  dgematrix newmat(mat.N,mat.M);
11 
12  for(long i=0; i<newmat.M; i++){ for(long j=0; j<newmat.N; j++){
13  newmat(i,j) =mat(j,i);
14  }}
15 
16  return _(newmat);
17 }
18 
19 //=============================================================================
21 inline _dgematrix i(const dgematrix& mat)
22 {
23 #ifdef CPPL_VERBOSE
24  std::cerr << "# [MARK] i(const dgematrix&)"
25  << std::endl;
26 #endif//CPPL_VERBOSE
27 
28 #ifdef CPPL_DEBUG
29  if(mat.M!=mat.N){
30  std::cerr << "[ERROR] i(dgematrix&) " << std::endl
31  << "This matrix is not square and has no inverse matrix."
32  << std::endl
33  << "Your input was (" << mat.M << "x" << mat.N << ")."
34  << std::endl;
35  exit(1);
36  }
37 #endif//CPPL_DEBUG
38 
39  dgematrix mat_cp(mat), mat_inv(mat.M,mat.N);
40  mat_inv.identity();
41  mat_cp.dgesv(mat_inv);
42 
43  return _(mat_inv);
44 }
45 
49 
50 //=============================================================================
53 inline void idamax(long& i, long& j, const dgematrix& mat)
54 {
55 #ifdef CPPL_VERBOSE
56  std::cerr << "# [MARK] idamax(long&, long&, const dgematrix&)"
57  << std::endl;
58 #endif//CPPL_VERBOSE
59 
60  long index( idamax_(mat.M*mat.N, mat.Array, 1) -1 );
61  i =index%mat.M;
62  j =index/mat.M;
63 }
64 
65 //=============================================================================
67 inline double damax(const dgematrix& mat)
68 {
69 #ifdef CPPL_VERBOSE
70  std::cerr << "# [MARK] damax(const dgematrix&)"
71  << std::endl;
72 #endif//CPPL_VERBOSE
73 
74  return mat.Array[idamax_(mat.M*mat.N, mat.Array, 1) -1];
75 }
friend double damax(const drovector &)
Definition: drovector-calc.hpp:43
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
(DO NOT USE) Smart-temporary Real Double-precision General Dence Matrix Class
Definition: _dgematrix.hpp:3
friend _dcovector t(const drovector &)
Definition: drovector-calc.hpp:3
friend long idamax(const drovector &)
Definition: drovector-calc.hpp:31