fn_qz.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_qz
  16. //! @{
  17. //! QZ decomposition for pair of N-by-N general matrices A and B
  18. template<typename T1, typename T2>
  19. inline
  20. typename
  21. enable_if2
  22. <
  23. is_supported_blas_type<typename T1::elem_type>::value,
  24. bool
  25. >::result
  26. qz
  27. (
  28. Mat<typename T1::elem_type>& AA,
  29. Mat<typename T1::elem_type>& BB,
  30. Mat<typename T1::elem_type>& Q,
  31. Mat<typename T1::elem_type>& Z,
  32. const Base<typename T1::elem_type,T1>& A_expr,
  33. const Base<typename T1::elem_type,T2>& B_expr,
  34. const char* select = "none"
  35. )
  36. {
  37. arma_extra_debug_sigprint();
  38. const char sig = (select != NULL) ? select[0] : char(0);
  39. arma_debug_check( ( (sig != 'n') && (sig != 'l') && (sig != 'r') && (sig != 'i') && (sig != 'o') ), "qz(): unknown select form" );
  40. const bool status = auxlib::qz(AA, BB, Q, Z, A_expr.get_ref(), B_expr.get_ref(), sig);
  41. if(status == false)
  42. {
  43. AA.soft_reset();
  44. BB.soft_reset();
  45. Q.soft_reset();
  46. Z.soft_reset();
  47. arma_debug_warn("qz(): decomposition failed");
  48. }
  49. return status;
  50. }
  51. //! @}