fn_wishrnd.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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_wishrnd
  16. //! @{
  17. template<typename T1>
  18. arma_warn_unused
  19. inline
  20. typename
  21. enable_if2
  22. <
  23. is_real<typename T1::elem_type>::value,
  24. const Op<T1, op_wishrnd>
  25. >::result
  26. wishrnd(const Base<typename T1::elem_type, T1>& S, typename T1::elem_type df)
  27. {
  28. arma_extra_debug_sigprint();
  29. return Op<T1, op_wishrnd>(S.get_ref(), df, uword(1), uword(0));
  30. }
  31. template<typename T1, typename T2>
  32. arma_warn_unused
  33. inline
  34. typename
  35. enable_if2
  36. <
  37. is_real<typename T1::elem_type>::value,
  38. const Op<T2, op_wishrnd>
  39. >::result
  40. wishrnd(const Base<typename T1::elem_type, T1>& S, typename T1::elem_type df, const Base<typename T1::elem_type, T2>& D)
  41. {
  42. arma_extra_debug_sigprint();
  43. arma_ignore(S);
  44. return Op<T2, op_wishrnd>(D.get_ref(), df, uword(2), uword(0));
  45. }
  46. template<typename T1>
  47. inline
  48. typename
  49. enable_if2
  50. <
  51. is_real<typename T1::elem_type>::value,
  52. bool
  53. >::result
  54. wishrnd(Mat<typename T1::elem_type>& W, const Base<typename T1::elem_type, T1>& S, typename T1::elem_type df)
  55. {
  56. arma_extra_debug_sigprint();
  57. const bool status = op_wishrnd::apply_direct(W, S.get_ref(), df, uword(1));
  58. if(status == false)
  59. {
  60. arma_debug_warn("wishrnd(): given matrix is not symmetric positive definite");
  61. return false;
  62. }
  63. return true;
  64. }
  65. template<typename T1, typename T2>
  66. inline
  67. typename
  68. enable_if2
  69. <
  70. is_real<typename T1::elem_type>::value,
  71. bool
  72. >::result
  73. wishrnd(Mat<typename T1::elem_type>& W, const Base<typename T1::elem_type, T1>& S, typename T1::elem_type df, const Base<typename T1::elem_type, T2>& D)
  74. {
  75. arma_extra_debug_sigprint();
  76. arma_ignore(S);
  77. return op_wishrnd::apply_direct(W, D.get_ref(), df, uword(2));
  78. }
  79. //
  80. template<typename T1>
  81. arma_warn_unused
  82. inline
  83. typename
  84. enable_if2
  85. <
  86. is_real<typename T1::elem_type>::value,
  87. const Op<T1, op_iwishrnd>
  88. >::result
  89. iwishrnd(const Base<typename T1::elem_type, T1>& T, typename T1::elem_type df)
  90. {
  91. arma_extra_debug_sigprint();
  92. return Op<T1, op_iwishrnd>(T.get_ref(), df, uword(1), uword(0));
  93. }
  94. template<typename T1, typename T2>
  95. arma_warn_unused
  96. inline
  97. typename
  98. enable_if2
  99. <
  100. is_real<typename T1::elem_type>::value,
  101. const Op<T2, op_iwishrnd>
  102. >::result
  103. iwishrnd(const Base<typename T1::elem_type, T1>& T, typename T1::elem_type df, const Base<typename T1::elem_type, T2>& Dinv)
  104. {
  105. arma_extra_debug_sigprint();
  106. arma_ignore(T);
  107. return Op<T2, op_iwishrnd>(Dinv.get_ref(), df, uword(2), uword(0));
  108. }
  109. template<typename T1>
  110. inline
  111. typename
  112. enable_if2
  113. <
  114. is_real<typename T1::elem_type>::value,
  115. bool
  116. >::result
  117. iwishrnd(Mat<typename T1::elem_type>& W, const Base<typename T1::elem_type, T1>& T, typename T1::elem_type df)
  118. {
  119. arma_extra_debug_sigprint();
  120. const bool status = op_iwishrnd::apply_direct(W, T.get_ref(), df, uword(1));
  121. if(status == false)
  122. {
  123. arma_debug_warn("iwishrnd(): given matrix is not symmetric positive definite and/or df is too low");
  124. return false;
  125. }
  126. return true;
  127. }
  128. template<typename T1, typename T2>
  129. inline
  130. typename
  131. enable_if2
  132. <
  133. is_real<typename T1::elem_type>::value,
  134. bool
  135. >::result
  136. iwishrnd(Mat<typename T1::elem_type>& W, const Base<typename T1::elem_type, T1>& T, typename T1::elem_type df, const Base<typename T1::elem_type, T2>& Dinv)
  137. {
  138. arma_extra_debug_sigprint();
  139. arma_ignore(T);
  140. return op_iwishrnd::apply_direct(W, Dinv.get_ref(), df, uword(2));
  141. }
  142. //! @}