"Fossies" - the Fresh Open Source Software Archive

Member "armadillo-9.800.3/include/armadillo_bits/arma_rel_comparators.hpp" (16 Jun 2016, 2768 Bytes) of package /linux/misc/armadillo-9.800.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "arma_rel_comparators.hpp" see the Fossies "Dox" file reference documentation.

    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 
   16 
   17 //! \addtogroup arma_rel_comparators
   18 //! @{
   19 
   20 
   21 
   22 template<typename eT>
   23 struct arma_lt_comparator
   24   {
   25   arma_inline bool operator() (const eT a, const eT b) const { return (a < b); }
   26   };
   27 
   28 
   29 
   30 template<typename eT>
   31 struct arma_gt_comparator
   32   {
   33   arma_inline bool operator() (const eT a, const eT b) const { return (a > b); }
   34   };
   35 
   36 
   37 
   38 template<typename eT>
   39 struct arma_leq_comparator
   40   {
   41   arma_inline bool operator() (const eT a, const eT b) const { return (a <= b); }
   42   };
   43   
   44 
   45 
   46 template<typename eT>
   47 struct arma_geq_comparator
   48   {
   49   arma_inline bool operator() (const eT a, const eT b) const { return (a >= b); }
   50   };
   51 
   52 
   53 
   54 template<typename T>
   55 struct arma_lt_comparator< std::complex<T> >
   56   {
   57   typedef typename std::complex<T> eT;
   58   
   59   inline bool operator() (const eT& a, const eT& b) const { return (std::abs(a) < std::abs(b)); }
   60   
   61   // inline
   62   // bool
   63   // operator() (const eT& a, const eT& b) const
   64   //   {
   65   //   const T abs_a = std::abs(a);
   66   //   const T abs_b = std::abs(b);
   67   //   
   68   //   return ( (abs_a != abs_b) ? (abs_a < abs_b) : (std::arg(a) < std::arg(b)) );
   69   //   }
   70   };
   71 
   72 
   73 
   74 template<typename T>
   75 struct arma_gt_comparator< std::complex<T> >
   76   {
   77   typedef typename std::complex<T> eT;
   78   
   79   inline bool operator() (const eT& a, const eT& b) const { return (std::abs(a) > std::abs(b)); }
   80   
   81   // inline
   82   // bool
   83   // operator() (const eT& a, const eT& b) const
   84   //   {
   85   //   const T abs_a = std::abs(a);
   86   //   const T abs_b = std::abs(b);
   87   //   
   88   //   return ( (abs_a != abs_b) ? (abs_a > abs_b) : (std::arg(a) > std::arg(b)) );
   89   //   }
   90   };
   91 
   92 
   93 
   94 template<typename T>
   95 struct arma_leq_comparator< std::complex<T> >
   96   {
   97   typedef typename std::complex<T> eT;
   98   
   99   inline bool operator() (const eT& a, const eT& b) const { return (std::abs(a) <= std::abs(b)); }
  100   };
  101 
  102 
  103 
  104 template<typename T>
  105 struct arma_geq_comparator< std::complex<T> >
  106   {
  107   typedef typename std::complex<T> eT;
  108   
  109   inline bool operator() (const eT& a, const eT& b) const { return (std::abs(a) >= std::abs(b)); }
  110   };
  111 
  112 
  113 
  114 //! @}