fn_det.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 
20 template<typename T1>
21 inline
23 typename T1::elem_type
24 det
25  (
27  const bool slow = false,
29  )
30  {
32 
34 
35  return auxlib::det(X, slow);
36  }
37 
38 
39 
41 template<typename T1>
42 inline
44 typename T1::elem_type
45 det
46  (
47  const Op<T1, op_diagmat>& X,
48  const bool slow = false
49  )
50  {
52  arma_ignore(slow);
53 
54  typedef typename T1::elem_type eT;
55 
56  const diagmat_proxy<T1> A(X.m);
57 
58  const uword A_n_elem = A.n_elem;
59 
60  eT val = eT(1);
61 
62  for(uword i=0; i<A_n_elem; ++i)
63  {
64  val *= A[i];
65  }
66 
67  return val;
68  }
69 
70 
71 
73 template<typename T1>
74 inline
76 typename T1::elem_type
77 det
78  (
79  const Op<T1,op_inv>& in,
80  const bool slow = false,
82  )
83  {
86 
87  typedef typename T1::elem_type eT;
88 
89  eT tmp = det(in.m, slow);
90  arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" );
91 
92  return eT(1) / tmp;
93  }
94 
95 
96 
98 template<typename T1>
99 inline
101 typename T1::elem_type
102 det
103  (
104  const Op<T1,op_htrans>& in,
105  const bool slow = false,
106  const typename arma_blas_type_only<typename T1::elem_type>::result* junk1 = 0,
107  const typename arma_not_cx<typename T1::elem_type>::result* junk2 = 0
108  )
109  {
111  arma_ignore(junk1);
112  arma_ignore(junk2);
113 
114  typedef typename T1::elem_type eT;
115 
116  const unwrap<T1> tmp(in.m);
117  const Mat<eT>& X = tmp.M;
118 
119  return det(X, slow);
120  }
121 
122 
123 
const uword n_elem
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
Definition: Op_bones.hpp:45
u32 uword
Definition: typedef.hpp:85
const Mat< eT > M
Definition: unwrap.hpp:32
#define arma_ignore(variable)
arma_warn_unused T1::elem_type det(const Base< typename T1::elem_type, T1 > &X, const bool slow=false, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
determinant of mat
Definition: fn_det.hpp:25
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
#define arma_warn_unused
void arma_cold arma_warn(const bool state, const T1 &x)
print a message to the warn stream
Definition: debug.hpp:298
Dense matrix class.
static eT det(const Base< eT, T1 > &X, const bool slow=false)


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57