cond_rel_meat.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 cond_rel
  16. //! @{
  17. template<>
  18. template<typename eT>
  19. arma_inline
  20. bool
  21. cond_rel<true>::lt(const eT A, const eT B)
  22. {
  23. return (A < B);
  24. }
  25. template<>
  26. template<typename eT>
  27. arma_inline
  28. bool
  29. cond_rel<false>::lt(const eT, const eT)
  30. {
  31. return false;
  32. }
  33. template<>
  34. template<typename eT>
  35. arma_inline
  36. bool
  37. cond_rel<true>::gt(const eT A, const eT B)
  38. {
  39. return (A > B);
  40. }
  41. template<>
  42. template<typename eT>
  43. arma_inline
  44. bool
  45. cond_rel<false>::gt(const eT, const eT)
  46. {
  47. return false;
  48. }
  49. template<>
  50. template<typename eT>
  51. arma_inline
  52. bool
  53. cond_rel<true>::leq(const eT A, const eT B)
  54. {
  55. return (A <= B);
  56. }
  57. template<>
  58. template<typename eT>
  59. arma_inline
  60. bool
  61. cond_rel<false>::leq(const eT, const eT)
  62. {
  63. return false;
  64. }
  65. template<>
  66. template<typename eT>
  67. arma_inline
  68. bool
  69. cond_rel<true>::geq(const eT A, const eT B)
  70. {
  71. return (A >= B);
  72. }
  73. template<>
  74. template<typename eT>
  75. arma_inline
  76. bool
  77. cond_rel<false>::geq(const eT, const eT)
  78. {
  79. return false;
  80. }
  81. template<>
  82. template<typename eT>
  83. arma_inline
  84. eT
  85. cond_rel<true>::make_neg(const eT val)
  86. {
  87. return -val;
  88. }
  89. template<>
  90. template<typename eT>
  91. arma_inline
  92. eT
  93. cond_rel<false>::make_neg(const eT)
  94. {
  95. return eT(0);
  96. }
  97. //! @}