fn_inv.hpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup fn_inv
  16. //! @{
  17. template<typename T1>
  18. arma_warn_unused
  19. arma_inline
  20. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv> >::result
  21. inv
  22. (
  23. const Base<typename T1::elem_type,T1>& X
  24. )
  25. {
  26. arma_extra_debug_sigprint();
  27. return Op<T1, op_inv>(X.get_ref());
  28. }
  29. //! NOTE: don't use this form: it will be removed
  30. template<typename T1>
  31. arma_deprecated
  32. inline
  33. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv> >::result
  34. inv
  35. (
  36. const Base<typename T1::elem_type,T1>& X,
  37. const bool // argument kept only for compatibility with old user code
  38. )
  39. {
  40. arma_extra_debug_sigprint();
  41. // arma_debug_warn("inv(X,bool) is deprecated and will be removed; change to inv(X)");
  42. return Op<T1, op_inv>(X.get_ref());
  43. }
  44. //! NOTE: don't use this form: it will be removed
  45. template<typename T1>
  46. arma_deprecated
  47. inline
  48. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv> >::result
  49. inv
  50. (
  51. const Base<typename T1::elem_type,T1>& X,
  52. const char* // argument kept only for compatibility with old user code
  53. )
  54. {
  55. arma_extra_debug_sigprint();
  56. // arma_debug_warn("inv(X,char*) is deprecated and will be removed; change to inv(X)");
  57. return Op<T1, op_inv>(X.get_ref());
  58. }
  59. template<typename T1>
  60. arma_warn_unused
  61. arma_inline
  62. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_tr> >::result
  63. inv
  64. (
  65. const Op<T1, op_trimat>& X
  66. )
  67. {
  68. arma_extra_debug_sigprint();
  69. return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
  70. }
  71. //! NOTE: don't use this form: it will be removed
  72. template<typename T1>
  73. arma_deprecated
  74. inline
  75. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_tr> >::result
  76. inv
  77. (
  78. const Op<T1, op_trimat>& X,
  79. const bool // argument kept only for compatibility with old user code
  80. )
  81. {
  82. arma_extra_debug_sigprint();
  83. // arma_debug_warn("inv(X,bool) is deprecated and will be removed; change to inv(X)");
  84. return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
  85. }
  86. //! NOTE: don't use this form: it will be removed
  87. template<typename T1>
  88. arma_deprecated
  89. inline
  90. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_tr> >::result
  91. inv
  92. (
  93. const Op<T1, op_trimat>& X,
  94. const char* // argument kept only for compatibility with old user code
  95. )
  96. {
  97. arma_extra_debug_sigprint();
  98. // arma_debug_warn("inv(X,char*) is deprecated and will be removed; change to inv(X)");
  99. return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
  100. }
  101. template<typename T1>
  102. inline
  103. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  104. inv
  105. (
  106. Mat<typename T1::elem_type>& out,
  107. const Base<typename T1::elem_type,T1>& X
  108. )
  109. {
  110. arma_extra_debug_sigprint();
  111. try
  112. {
  113. out = inv(X);
  114. }
  115. catch(std::runtime_error&)
  116. {
  117. return false;
  118. }
  119. return true;
  120. }
  121. //! NOTE: don't use this form: it will be removed
  122. template<typename T1>
  123. arma_deprecated
  124. inline
  125. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  126. inv
  127. (
  128. Mat<typename T1::elem_type>& out,
  129. const Base<typename T1::elem_type,T1>& X,
  130. const bool // argument kept only for compatibility with old user code
  131. )
  132. {
  133. arma_extra_debug_sigprint();
  134. // arma_debug_warn("inv(Y,X,bool) is deprecated and will be removed; change to inv(Y,X)");
  135. return inv(out,X);
  136. }
  137. //! NOTE: don't use this form: it will be removed
  138. template<typename T1>
  139. arma_deprecated
  140. inline
  141. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  142. inv
  143. (
  144. Mat<typename T1::elem_type>& out,
  145. const Base<typename T1::elem_type,T1>& X,
  146. const char* // argument kept only for compatibility with old user code
  147. )
  148. {
  149. arma_extra_debug_sigprint();
  150. // arma_debug_warn("inv(Y,X,char*) is deprecated and will be removed; change to inv(Y,X)");
  151. return inv(out,X);
  152. }
  153. template<typename T1>
  154. arma_warn_unused
  155. arma_inline
  156. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_sympd> >::result
  157. inv_sympd
  158. (
  159. const Base<typename T1::elem_type, T1>& X
  160. )
  161. {
  162. arma_extra_debug_sigprint();
  163. return Op<T1, op_inv_sympd>(X.get_ref());
  164. }
  165. //! NOTE: don't use this form: it will be removed
  166. template<typename T1>
  167. arma_deprecated
  168. inline
  169. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_sympd> >::result
  170. inv_sympd
  171. (
  172. const Base<typename T1::elem_type, T1>& X,
  173. const bool // argument kept only for compatibility with old user code
  174. )
  175. {
  176. arma_extra_debug_sigprint();
  177. // arma_debug_warn("inv_sympd(X,bool) is deprecated and will be removed; change to inv_sympd(X)");
  178. return Op<T1, op_inv_sympd>(X.get_ref());
  179. }
  180. //! NOTE: don't use this form: it will be removed
  181. template<typename T1>
  182. arma_deprecated
  183. inline
  184. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_inv_sympd> >::result
  185. inv_sympd
  186. (
  187. const Base<typename T1::elem_type, T1>& X,
  188. const char* // argument kept only for compatibility with old user code
  189. )
  190. {
  191. arma_extra_debug_sigprint();
  192. // arma_debug_warn("inv_sympd(X,char*) is deprecated and will be removed; change to inv_sympd(X)");
  193. return Op<T1, op_inv_sympd>(X.get_ref());
  194. }
  195. template<typename T1>
  196. inline
  197. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  198. inv_sympd
  199. (
  200. Mat<typename T1::elem_type>& out,
  201. const Base<typename T1::elem_type,T1>& X
  202. )
  203. {
  204. arma_extra_debug_sigprint();
  205. try
  206. {
  207. out = inv_sympd(X);
  208. }
  209. catch(std::runtime_error&)
  210. {
  211. return false;
  212. }
  213. return true;
  214. }
  215. //! NOTE: don't use this form: it will be removed
  216. template<typename T1>
  217. arma_deprecated
  218. inline
  219. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  220. inv_sympd
  221. (
  222. Mat<typename T1::elem_type>& out,
  223. const Base<typename T1::elem_type,T1>& X,
  224. const bool // argument kept only for compatibility with old user code
  225. )
  226. {
  227. arma_extra_debug_sigprint();
  228. // arma_debug_warn("inv_sympd(Y,X,bool) is deprecated and will be removed; change to inv_sympd(Y,X)");
  229. return inv_sympd(out,X);
  230. }
  231. //! NOTE: don't use this form: it will be removed
  232. template<typename T1>
  233. arma_deprecated
  234. inline
  235. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  236. inv_sympd
  237. (
  238. Mat<typename T1::elem_type>& out,
  239. const Base<typename T1::elem_type,T1>& X,
  240. const char* // argument kept only for compatibility with old user code
  241. )
  242. {
  243. arma_extra_debug_sigprint();
  244. // arma_debug_warn("inv_sympd(Y,X,char*) is deprecated and will be removed; change to inv_sympd(Y,X)");
  245. return inv_sympd(out,X);
  246. }
  247. //! @}