glue_solve_bones.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 glue_solve
  16. //! @{
  17. class glue_solve_gen
  18. {
  19. public:
  20. template<typename T1, typename T2>
  21. struct traits
  22. {
  23. static const bool is_row = false;
  24. static const bool is_col = T2::is_col;
  25. static const bool is_xvec = false;
  26. };
  27. template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve_gen>& X);
  28. template<typename eT, typename T1, typename T2> inline static bool apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2>& B_expr, const uword flags);
  29. };
  30. class glue_solve_tri_default
  31. {
  32. public:
  33. template<typename T1, typename T2>
  34. struct traits
  35. {
  36. static const bool is_row = false;
  37. static const bool is_col = T2::is_col;
  38. static const bool is_xvec = false;
  39. };
  40. template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve_tri_default>& X);
  41. template<typename eT, typename T1, typename T2> inline static bool apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2>& B_expr, const uword flags);
  42. };
  43. class glue_solve_tri
  44. {
  45. public:
  46. template<typename T1, typename T2>
  47. struct traits
  48. {
  49. static const bool is_row = false;
  50. static const bool is_col = T2::is_col;
  51. static const bool is_xvec = false;
  52. };
  53. template<typename T1, typename T2> inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_solve_tri>& X);
  54. template<typename eT, typename T1, typename T2> inline static bool apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2>& B_expr, const uword flags);
  55. };
  56. namespace solve_opts
  57. {
  58. struct opts
  59. {
  60. const uword flags;
  61. inline explicit opts(const uword in_flags);
  62. inline const opts operator+(const opts& rhs) const;
  63. };
  64. inline
  65. opts::opts(const uword in_flags)
  66. : flags(in_flags)
  67. {}
  68. inline
  69. const opts
  70. opts::operator+(const opts& rhs) const
  71. {
  72. const opts result( flags | rhs.flags );
  73. return result;
  74. }
  75. // The values below (eg. 1u << 1) are for internal Armadillo use only.
  76. // The values can change without notice.
  77. static const uword flag_none = uword(0 );
  78. static const uword flag_fast = uword(1u << 0);
  79. static const uword flag_equilibrate = uword(1u << 1);
  80. static const uword flag_no_approx = uword(1u << 2);
  81. static const uword flag_triu = uword(1u << 3);
  82. static const uword flag_tril = uword(1u << 4);
  83. static const uword flag_no_band = uword(1u << 5);
  84. static const uword flag_no_sympd = uword(1u << 6);
  85. static const uword flag_allow_ugly = uword(1u << 7);
  86. static const uword flag_likely_sympd = uword(1u << 8);
  87. static const uword flag_refine = uword(1u << 9);
  88. static const uword flag_no_trimat = uword(1u << 10);
  89. struct opts_none : public opts { inline opts_none() : opts(flag_none ) {} };
  90. struct opts_fast : public opts { inline opts_fast() : opts(flag_fast ) {} };
  91. struct opts_equilibrate : public opts { inline opts_equilibrate() : opts(flag_equilibrate ) {} };
  92. struct opts_no_approx : public opts { inline opts_no_approx() : opts(flag_no_approx ) {} };
  93. struct opts_triu : public opts { inline opts_triu() : opts(flag_triu ) {} };
  94. struct opts_tril : public opts { inline opts_tril() : opts(flag_tril ) {} };
  95. struct opts_no_band : public opts { inline opts_no_band() : opts(flag_no_band ) {} };
  96. struct opts_no_sympd : public opts { inline opts_no_sympd() : opts(flag_no_sympd ) {} };
  97. struct opts_allow_ugly : public opts { inline opts_allow_ugly() : opts(flag_allow_ugly ) {} };
  98. struct opts_likely_sympd : public opts { inline opts_likely_sympd() : opts(flag_likely_sympd) {} };
  99. struct opts_refine : public opts { inline opts_refine() : opts(flag_refine ) {} };
  100. struct opts_no_trimat : public opts { inline opts_no_trimat() : opts(flag_no_trimat ) {} };
  101. static const opts_none none;
  102. static const opts_fast fast;
  103. static const opts_equilibrate equilibrate;
  104. static const opts_no_approx no_approx;
  105. static const opts_triu triu;
  106. static const opts_tril tril;
  107. static const opts_no_band no_band;
  108. static const opts_no_sympd no_sympd;
  109. static const opts_allow_ugly allow_ugly;
  110. static const opts_likely_sympd likely_sympd;
  111. static const opts_refine refine;
  112. static const opts_no_trimat no_trimat;
  113. }
  114. //! @}