fn_expmat.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_expmat
  16. //! @{
  17. template<typename T1>
  18. arma_warn_unused
  19. inline
  20. typename
  21. enable_if2
  22. <
  23. is_real<typename T1::pod_type>::value,
  24. const Op<T1,op_expmat>
  25. >::result
  26. expmat(const Base<typename T1::elem_type,T1>& A)
  27. {
  28. arma_extra_debug_sigprint();
  29. return Op<T1,op_expmat>(A.get_ref());
  30. }
  31. template<typename T1>
  32. inline
  33. typename
  34. enable_if2
  35. <
  36. is_real<typename T1::pod_type>::value,
  37. bool
  38. >::result
  39. expmat(Mat<typename T1::elem_type>& B, const Base<typename T1::elem_type,T1>& A)
  40. {
  41. arma_extra_debug_sigprint();
  42. const bool status = op_expmat::apply_direct(B, A);
  43. if(status == false)
  44. {
  45. arma_debug_warn("expmat(): given matrix appears ill-conditioned");
  46. B.soft_reset();
  47. return false;
  48. }
  49. return true;
  50. }
  51. //
  52. template<typename T1>
  53. arma_warn_unused
  54. arma_inline
  55. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, const Op<T1, op_expmat_sym> >::result
  56. expmat_sym(const Base<typename T1::elem_type,T1>& X)
  57. {
  58. arma_extra_debug_sigprint();
  59. return Op<T1, op_expmat_sym>(X.get_ref());
  60. }
  61. template<typename T1>
  62. inline
  63. typename enable_if2< is_supported_blas_type<typename T1::elem_type>::value, bool >::result
  64. expmat_sym(Mat<typename T1::elem_type>& Y, const Base<typename T1::elem_type,T1>& X)
  65. {
  66. arma_extra_debug_sigprint();
  67. const bool status = op_expmat_sym::apply_direct(Y, X.get_ref());
  68. if(status == false)
  69. {
  70. Y.soft_reset();
  71. arma_debug_warn("expmat_sym(): transformation failed");
  72. }
  73. return status;
  74. }
  75. //! @}