fn_schur.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_schur
  16. //! @{
  17. template<typename T1>
  18. inline
  19. bool
  20. schur
  21. (
  22. Mat<typename T1::elem_type>& S,
  23. const Base<typename T1::elem_type,T1>& X,
  24. const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
  25. )
  26. {
  27. arma_extra_debug_sigprint();
  28. arma_ignore(junk);
  29. typedef typename T1::elem_type eT;
  30. Mat<eT> U;
  31. const bool status = auxlib::schur(U, S, X.get_ref(), false);
  32. if(status == false)
  33. {
  34. S.soft_reset();
  35. arma_debug_warn("schur(): decomposition failed");
  36. }
  37. return status;
  38. }
  39. template<typename T1>
  40. arma_warn_unused
  41. inline
  42. Mat<typename T1::elem_type>
  43. schur
  44. (
  45. const Base<typename T1::elem_type,T1>& X,
  46. const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
  47. )
  48. {
  49. arma_extra_debug_sigprint();
  50. arma_ignore(junk);
  51. typedef typename T1::elem_type eT;
  52. Mat<eT> S;
  53. Mat<eT> U;
  54. const bool status = auxlib::schur(U, S, X.get_ref(), false);
  55. if(status == false)
  56. {
  57. S.soft_reset();
  58. arma_stop_runtime_error("schur(): decomposition failed");
  59. }
  60. return S;
  61. }
  62. template<typename T1>
  63. inline
  64. bool
  65. schur
  66. (
  67. Mat<typename T1::elem_type>& U,
  68. Mat<typename T1::elem_type>& S,
  69. const Base<typename T1::elem_type,T1>& X,
  70. const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
  71. )
  72. {
  73. arma_extra_debug_sigprint();
  74. arma_ignore(junk);
  75. arma_debug_check( void_ptr(&U) == void_ptr(&S), "schur(): 'U' is an alias of 'S'" );
  76. const bool status = auxlib::schur(U, S, X.get_ref(), true);
  77. if(status == false)
  78. {
  79. U.soft_reset();
  80. S.soft_reset();
  81. arma_debug_warn("schur(): decomposition failed");
  82. }
  83. return status;
  84. }
  85. //! @}