fn_logmat.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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_logmat
  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 && is_cx<typename T1::elem_type>::no), const mtOp<std::complex<typename T1::elem_type>, T1, op_logmat> >::result
  21. logmat(const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
  22. {
  23. arma_extra_debug_sigprint();
  24. return mtOp<std::complex<typename T1::elem_type>, T1, op_logmat>(X.get_ref(), n_iters, uword(0));
  25. }
  26. template<typename T1>
  27. arma_warn_unused
  28. arma_inline
  29. typename enable_if2< (is_supported_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::yes), const Op<T1, op_logmat_cx> >::result
  30. logmat(const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
  31. {
  32. arma_extra_debug_sigprint();
  33. return Op<T1, op_logmat_cx>(X.get_ref(), n_iters, uword(0));
  34. }
  35. template<typename T1>
  36. inline
  37. typename enable_if2< (is_supported_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::no), bool >::result
  38. logmat(Mat< std::complex<typename T1::elem_type> >& Y, const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
  39. {
  40. arma_extra_debug_sigprint();
  41. const bool status = op_logmat::apply_direct(Y, X.get_ref(), n_iters);
  42. if(status == false)
  43. {
  44. Y.soft_reset();
  45. arma_debug_warn("logmat(): transformation failed");
  46. }
  47. return status;
  48. }
  49. template<typename T1>
  50. inline
  51. typename enable_if2< (is_supported_blas_type<typename T1::elem_type>::value && is_cx<typename T1::elem_type>::yes), bool >::result
  52. logmat(Mat<typename T1::elem_type>& Y, const Base<typename T1::elem_type,T1>& X, const uword n_iters = 100u)
  53. {
  54. arma_extra_debug_sigprint();
  55. const bool status = op_logmat_cx::apply_direct(Y, X.get_ref(), n_iters);
  56. if(status == false)
  57. {
  58. Y.soft_reset();
  59. arma_debug_warn("logmat(): transformation failed");
  60. }
  61. return status;
  62. }
  63. //
  64. template<typename T1>
  65. arma_warn_unused
  66. arma_inline
  67. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_logmat_sympd> >::result
  68. logmat_sympd(const Base<typename T1::elem_type,T1>& X)
  69. {
  70. arma_extra_debug_sigprint();
  71. return Op<T1, op_logmat_sympd>(X.get_ref());
  72. }
  73. template<typename T1>
  74. inline
  75. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  76. logmat_sympd(Mat<typename T1::elem_type>& Y, const Base<typename T1::elem_type,T1>& X)
  77. {
  78. arma_extra_debug_sigprint();
  79. const bool status = op_logmat_sympd::apply_direct(Y, X.get_ref());
  80. if(status == false)
  81. {
  82. Y.soft_reset();
  83. arma_debug_warn("logmat_sympd(): transformation failed");
  84. }
  85. return status;
  86. }
  87. //! @}