vtf-logo

FixedArray.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // CONTINUE: If I make most of the functions free, I could remove the class
00004 // specializations for 1, 2 and 3.  I would just keep specializations of
00005 // the free functions.
00006 
00012 #if !defined(__FixedArray_h__)
00013 #define __FixedArray_h__
00014 
00015 #if defined(DEBUG_ads) && !defined(DEBUG_FixedArray)
00016 #define DEBUG_FixedArray
00017 #endif
00018 
00019 #include "ArrayTypes.h"
00020 
00021 #include "../algorithm/is_sorted.h"
00022 
00023 #include "../../third-party/loki/static_check.h"
00024 
00025 #include <iostream>
00026 #include <functional>
00027 #include <algorithm>
00028 #include <limits>
00029 #include <numeric>
00030 #include <cmath>
00031 
00032 #include <cassert>
00033 
00034 BEGIN_NAMESPACE_ADS
00035 
00037 template<int N, typename T = double, bool A = true>
00038 class Array;
00039 
00041 
00056 template<int N, typename T = double>
00057 class FixedArray {
00058   //
00059   // Private types.
00060   //
00061 
00062 private:
00063 
00064   typedef ArrayTypes<T> Types;
00065 
00066   //
00067   // Public types.
00068   //
00069 
00070 public:
00071 
00072   //--------------------------------------------------------------------------
00074   // @{
00075 
00077   typedef typename Types::value_type value_type;
00079   typedef typename Types::parameter_type parameter_type;
00081   typedef typename Types::pointer pointer;
00083   typedef typename Types::const_pointer const_pointer;
00085   typedef typename Types::iterator iterator;
00087   typedef typename Types::const_iterator const_iterator;
00089   typedef typename Types::reference reference;
00091   typedef typename Types::const_reference const_reference;
00093 
00099   typedef typename Types::size_type size_type;
00101   typedef typename Types::difference_type difference_type;
00102 
00104 
00105 private:
00106 
00107   //
00108   // Data
00109   //
00110 
00112   value_type _data[N];
00113 
00114 public:
00115 
00116   //--------------------------------------------------------------------------
00139   // @{
00140 
00142   FixedArray() {
00143     LOKI_STATIC_CHECK(N > 3, dimension_greater_than_3);
00144   }
00145 
00147   ~FixedArray() {
00148     LOKI_STATIC_CHECK(N > 3, dimension_greater_than_3);
00149   }
00150 
00152   FixedArray(const FixedArray& x) {
00153     LOKI_STATIC_CHECK(N > 3, dimension_greater_than_3);
00154     std::copy(x.begin(), x.end(), _data);
00155   }
00156 
00158   template<typename T2> 
00159   FixedArray(const FixedArray<N,T2>& x) {
00160     LOKI_STATIC_CHECK(N > 3, dimension_greater_than_3);
00161     for (int n = 0; n != N; ++n) {
00162       _data[n] = static_cast<value_type>(x[n]);
00163     }
00164   }
00165 
00167   explicit 
00168   FixedArray(parameter_type x);
00169 
00171   explicit
00172   FixedArray(const const_pointer p) {
00173     copy(p, p + N);
00174   }
00175 
00177   FixedArray(const void* p) {
00178     copy(static_cast<const_pointer>(p), 
00179          static_cast<const_pointer>(p) + N);
00180   }
00181 
00183 
00186   FixedArray(parameter_type x0, parameter_type x1);
00187   // This function is intentionally left undefined for the general case.
00188   // It is only defined in the specialization for N == 2.
00189 
00191 
00194   FixedArray(parameter_type x0, parameter_type x1, 
00195              parameter_type x2);
00196   // This function is intentionally left undefined for the general case.
00197   // It is only defined in the specialization for N == 3.
00198 
00200 
00203   FixedArray(parameter_type x0, parameter_type x1, 
00204              parameter_type x2, parameter_type x3);
00205 
00207 
00210   FixedArray(parameter_type x0, parameter_type x1, 
00211              parameter_type x2, parameter_type x3, 
00212              parameter_type x4);
00213 
00215 
00218   FixedArray(parameter_type x0, parameter_type x1, 
00219              parameter_type x2, parameter_type x3, 
00220              parameter_type x4, parameter_type x5);
00221 
00223 
00226   FixedArray(parameter_type x0, parameter_type x1, 
00227              parameter_type x2, parameter_type x3, 
00228              parameter_type x4, parameter_type x5, 
00229              parameter_type x6);
00230 
00232 
00235   FixedArray(parameter_type x0, parameter_type x1, 
00236              parameter_type x2, parameter_type x3, 
00237              parameter_type x4, parameter_type x5, 
00238              parameter_type x6, parameter_type x7);
00239 
00240   // @}
00241   //--------------------------------------------------------------------------
00243   // @{
00244 
00246   FixedArray& 
00247   operator=(const FixedArray& x);
00248 
00250   template<typename T2> 
00251   FixedArray& 
00252   operator=(const FixedArray<N,T2>& x);
00253 
00255   template<typename T2, bool A>
00256   FixedArray& 
00257   operator=(const Array<1, T2, A>& x);
00258 
00260   FixedArray& 
00261   operator=(parameter_type x);
00262 
00263   // @}
00264   //--------------------------------------------------------------------------
00266   // @{
00267 
00269   static
00270   size_type
00271   size() { 
00272     return N; 
00273   }
00274 
00276   static
00277   bool
00278   empty() { 
00279     // I do this because there is a specialization for N = 0.
00280     return false;
00281   }
00282 
00284   static
00285   size_type
00286   max_size() { 
00287     return std::numeric_limits<int>::max() / sizeof(value_type); 
00288   }
00289 
00290   // @}
00291   //--------------------------------------------------------------------------
00293   // @{
00294 
00296   const_iterator 
00297   begin() const { 
00298     return _data; 
00299   }
00300 
00302   const_iterator 
00303   end() const { 
00304     return _data + N; 
00305   }
00306 
00308   const_pointer 
00309   data() const { 
00310     return _data; 
00311   }
00312 
00314   parameter_type
00315   operator()(const int i) const {
00316 #ifdef DEBUG_FixedArray
00317     assert(0 <= i && i < N);
00318 #endif
00319     return _data[i];
00320   }
00321 
00323   parameter_type
00324   operator[](const int i) const {
00325 #ifdef DEBUG_FixedArray
00326     assert(0 <= i && i < N);
00327 #endif
00328     return _data[i];
00329   }
00330 
00332 
00335   template<typename EqualityComparable>
00336   const_iterator
00337   find(const EqualityComparable& x) const {
00338     return std::find(begin(), end(), x);
00339   }
00340 
00342 
00345   template<typename EqualityComparable>
00346   int
00347   find_index(const EqualityComparable& x) const {
00348     return int(find(x) - begin());
00349   }
00350 
00352   template<typename EqualityComparable>
00353   bool
00354   has(const EqualityComparable& x) const {
00355     return find(x) != end();
00356   }
00357 
00359   bool
00360   is_sorted() const;
00361 
00363   template<class StrictWeakOrdering>
00364   bool
00365   is_sorted(StrictWeakOrdering comp) const;
00366 
00368   int
00369   min_index() const;
00370 
00372   template<class StrictWeakOrdering>
00373   int
00374   min_index(StrictWeakOrdering comp) const;
00375 
00377   int
00378   max_index() const;
00379 
00381   template<class StrictWeakOrdering>
00382   int
00383   max_index(StrictWeakOrdering comp) const;
00384 
00385   // @}
00386   //--------------------------------------------------------------------------
00388   // @{
00389 
00391   iterator 
00392   begin() { 
00393     return _data; 
00394   }
00395 
00397   iterator 
00398   end() { 
00399     return _data + N; 
00400   }
00401 
00403   pointer 
00404   data() { 
00405     return _data; 
00406   }
00407 
00409   reference
00410   operator()(const int i) { 
00411 #ifdef DEBUG_FixedArray
00412     assert(0 <= i && i < N);
00413 #endif
00414     return _data[i];
00415   }
00416 
00418   reference
00419   operator[](const int i) {
00420 #ifdef DEBUG_FixedArray
00421     assert(0 <= i && i < N);
00422 #endif
00423     return _data[i];
00424   }
00425 
00427   void
00428   swap(FixedArray& x) {
00429     std::swap_ranges(begin(), end(), x.begin());
00430   }
00431 
00433 
00436   template<typename EqualityComparable>
00437   iterator
00438   find(const EqualityComparable& x) {
00439     return std::find(begin(), end(), x);
00440   }
00441 
00443   void
00444   negate();
00445 
00447   void
00448   fill(parameter_type value);
00449 
00451   template<typename InputIterator>
00452   void
00453   copy(InputIterator start, InputIterator finish);
00454     
00456   void
00457   sort();
00458 
00460   template<class StrictWeakOrdering>
00461   void
00462   sort(StrictWeakOrdering comp);
00463 
00464   // @}
00465   //--------------------------------------------------------------------------
00467   // @{
00468 
00470   FixedArray& 
00471   operator+=(parameter_type x);
00472 
00474   FixedArray& 
00475   operator-=(parameter_type x);
00476 
00478   FixedArray& 
00479   operator*=(parameter_type x);
00480 
00482   FixedArray& 
00483   operator/=(parameter_type x);
00484 
00486   FixedArray& 
00487   operator%=(parameter_type x);
00488 
00490   FixedArray& 
00491   operator<<=(int offset);
00492 
00494   FixedArray& 
00495   operator>>=(int offset);
00496 
00497   // @}
00498   //--------------------------------------------------------------------------
00500   // @{
00501 
00503   template<typename T2>
00504   FixedArray& 
00505   operator+=(const FixedArray<N,T2> & x);
00506 
00508   template<typename T2>
00509   FixedArray& 
00510   operator-=(const FixedArray<N,T2> & x);
00511 
00513   template<typename T2>
00514   FixedArray& 
00515   operator*=(const FixedArray<N,T2> & x);
00516 
00518   template<typename T2>
00519   FixedArray& 
00520   operator/=(const FixedArray<N,T2> & x);
00521 
00523   template<typename T2>
00524   FixedArray& 
00525   operator%=(const FixedArray<N,T2> & x);
00526 
00527   // @}
00528 };
00529 
00530 //
00531 // Unary Operators
00532 //
00533 
00535 
00536 template<int N, typename T>
00537 inline
00538 FixedArray<N,T>&
00539 operator+(FixedArray<N,T>& x) {
00540   return x;
00541 }
00542     
00544 
00545 template<int N, typename T>
00546 FixedArray<N,T>
00547 operator-(const FixedArray<N,T>& x) {
00548   FixedArray<N,T> a(x);
00549   a.negate();
00550   return a;
00551 }
00552 
00553 
00554 //
00555 // Binary Operators
00556 //
00557 
00559 
00560 template<int N, typename T>
00561 inline
00562 FixedArray<N,T>
00563 operator+(const FixedArray<N,T>& x, 
00564           const typename FixedArray<N,T>::parameter_type value) {
00565   FixedArray<N,T> result(x);
00566   return result += value;
00567 }
00568 
00570 
00571 template<int N, typename T>
00572 inline
00573 FixedArray<N,T>
00574 operator+(const typename FixedArray<N,T>::parameter_type value, 
00575           const FixedArray<N,T>& x) {
00576   return x + value;
00577 }
00578 
00580 
00581 template<int N, typename T>
00582 inline
00583 FixedArray<N,T>
00584 operator+(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00585   FixedArray<N,T> result(x);
00586   return result += y;
00587 }
00588 
00590 
00591 template<int N, typename T>
00592 inline
00593 FixedArray<N,T>
00594 operator-(const FixedArray<N,T>& x, 
00595           const typename FixedArray<N,T>::parameter_type value) {
00596   FixedArray<N,T> result(x);
00597   return result -= value;
00598 }
00599 
00601 
00602 template<int N, typename T>
00603 inline
00604 FixedArray<N,T>
00605 operator-(const typename FixedArray<N,T>::parameter_type value, 
00606           const FixedArray<N,T>& x) {
00607   return -(x - value);
00608 }
00609 
00611 
00612 template<int N, typename T>
00613 inline
00614 FixedArray<N,T>
00615 operator-(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00616   FixedArray<N,T> result(x);
00617   return result -= y;
00618 }
00619 
00621 
00622 template<int N, typename T>
00623 inline
00624 FixedArray<N,T>
00625 operator*(const FixedArray<N,T>& x, 
00626           const typename FixedArray<N,T>::parameter_type value) {
00627   FixedArray<N,T> result(x);
00628   return result *= value;
00629 }
00630 
00632 
00633 template<int N, typename T>
00634 inline
00635 FixedArray<N,T>
00636 operator*(const typename FixedArray<N,T>::parameter_type value, 
00637           const FixedArray<N,T>& x) {
00638   return x * value;
00639 }
00640 
00642 
00643 template<int N, typename T>
00644 inline
00645 FixedArray<N,T>
00646 operator*(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00647   FixedArray<N,T> result(x);
00648   return result *= y;
00649 }
00650 
00652 
00653 template<int N, typename T>
00654 inline
00655 FixedArray<N,T>
00656 operator/(const FixedArray<N,T>& x, 
00657           const typename FixedArray<N,T>::parameter_type value) {
00658   FixedArray<N,T> result(x);
00659   return result /= value;
00660 }
00661 
00663 
00664 template<int N, typename T>
00665 inline
00666 FixedArray<N,T>
00667 operator/(const typename FixedArray<N,T>::parameter_type value, 
00668           const FixedArray<N,T>& x) {
00669   FixedArray<N,T> result(value);
00670   return result /= x;
00671 }
00672 
00674 
00675 template<int N, typename T>
00676 inline
00677 FixedArray<N,T>
00678 operator/(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00679   FixedArray<N,T> result(x);
00680   return result /= y;
00681 }
00682 
00684 
00685 template<int N, typename T>
00686 inline
00687 FixedArray<N,T>
00688 operator%(const FixedArray<N,T>& x, 
00689           const typename FixedArray<N,T>::parameter_type value) {
00690   FixedArray<N,T> result(x);
00691   return result %= value;
00692 }
00693 
00695 
00696 template<int N, typename T>
00697 FixedArray<N,T>
00698 operator%(const typename FixedArray<N,T>::parameter_type value, 
00699           const FixedArray<N,T>& x) {
00700   FixedArray<N,T> result(value);
00701   return result %= x;
00702 }
00703 
00705 
00706 template<int N, typename T>
00707 inline
00708 FixedArray<N,T>
00709 operator%(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00710   FixedArray<N,T> result(x);
00711   return result %= y;
00712 }
00713 
00714 
00715 //
00716 // Mathematical Functions
00717 //
00718 
00720 
00721 template<int N, typename T>
00722 T
00723 computeSum(const FixedArray<N,T>& x);
00724     
00726 
00727 template<int N, typename T>
00728 T
00729 computeProduct(const FixedArray<N,T>& x);
00730 
00732 
00733 template<int N, typename T>
00734 T
00735 computeMinimum(const FixedArray<N,T>& x);
00736     
00738 
00739 template<int N, typename T>
00740 T
00741 computeMaximum(const FixedArray<N,T>& x);
00742 
00743 
00744 
00745 
00746 
00747 //
00748 // Element-wise functions.
00749 //
00750 
00752 
00753 template<int N, typename T>
00754 inline
00755 FixedArray<N,T>
00756 computeMaximum(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00757   FixedArray<N,T> z;
00758   for (int n = 0; n != N; ++n) {
00759     z[n] = std::max(x[n], y[n]);
00760   }
00761   return z;
00762 }
00763 
00764 
00766 
00767 template<int N, typename T>
00768 inline
00769 FixedArray<N,T>
00770 computeMinimum(const FixedArray<N,T>& x, const FixedArray<N,T>& y) {
00771   FixedArray<N,T> z;
00772   for (int n = 0; n != N; ++n) {
00773     z[n] = std::min(x[n], y[n]);
00774   }
00775   return z;
00776 }
00777 
00778 
00779 
00780 
00781 
00782 //---------------------------------------------------------------------------
00783 // Apply the standard math functions.
00784 //---------------------------------------------------------------------------
00785 
00787 
00788 template<int N, typename T>
00789 inline
00790 void
00791 applyAbs(FixedArray<N,T>* x) {
00792   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00793        ++i) {
00794     *i = std::abs(*i);
00795   }
00796 }
00797 
00799 
00800 template<int N, typename T>
00801 inline
00802 void
00803 applyAcos(FixedArray<N,T>* x) {
00804   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00805        ++i) {
00806     *i = std::acos(*i);
00807   }
00808 }
00809 
00811 
00812 template<int N, typename T>
00813 inline
00814 void
00815 applyAsin(FixedArray<N,T>* x) {
00816   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00817        ++i) {
00818     *i = std::asin(*i);
00819   }
00820 }
00821 
00823 
00824 template<int N, typename T>
00825 inline
00826 void
00827 applyAtan(FixedArray<N,T>* x) {
00828   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00829        ++i) {
00830     *i = std::atan(*i);
00831   }
00832 }
00833 
00835 
00836 template<int N, typename T>
00837 inline
00838 void
00839 applyCeil(FixedArray<N,T>* x) {
00840   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00841        ++i) {
00842     *i = std::ceil(*i);
00843   }
00844 }
00845 
00847 
00848 template<int N, typename T>
00849 inline
00850 void
00851 applyCos(FixedArray<N,T>* x) {
00852   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00853        ++i) {
00854     *i = std::cos(*i);
00855   }
00856 }
00857 
00859 
00860 template<int N, typename T>
00861 inline
00862 void
00863 applyCosh(FixedArray<N,T>* x) {
00864   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00865        ++i) {
00866     *i = std::cosh(*i);
00867   }
00868 }
00869 
00871 
00872 template<int N, typename T>
00873 inline
00874 void
00875 applyExp(FixedArray<N,T>* x) {
00876   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00877        ++i) {
00878     *i = std::exp(*i);
00879   }
00880 }
00881 
00883 
00884 template<int N, typename T>
00885 inline
00886 void
00887 applyFloor(FixedArray<N,T>* x) {
00888   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00889        ++i) {
00890     *i = std::floor(*i);
00891   }
00892 }
00893 
00895 
00896 template<int N, typename T>
00897 inline
00898 void
00899 applyLog(FixedArray<N,T>* x) {
00900   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00901        ++i) {
00902     *i = std::log(*i);
00903   }
00904 }
00905 
00907 
00908 template<int N, typename T>
00909 inline
00910 void
00911 applyLog10(FixedArray<N,T>* x) {
00912   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00913        ++i) {
00914     *i = std::log10(*i);
00915   }
00916 }
00917 
00919 
00920 template<int N, typename T>
00921 inline
00922 void
00923 applySin(FixedArray<N,T>* x) {
00924   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00925        ++i) {
00926     *i = std::sin(*i);
00927   }
00928 }
00929 
00931 
00932 template<int N, typename T>
00933 inline
00934 void
00935 applySinh(FixedArray<N,T>* x) {
00936   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00937        ++i) {
00938     *i = std::sinh(*i);
00939   }
00940 }
00941 
00943 
00944 template<int N, typename T>
00945 inline
00946 void
00947 applySqrt(FixedArray<N,T>* x) {
00948   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00949        ++i) {
00950     *i = std::sqrt(*i);
00951   }
00952 }
00953 
00955 
00956 template<int N, typename T>
00957 inline
00958 void
00959 applyTan(FixedArray<N,T>* x) {
00960   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00961        ++i) {
00962     *i = std::tan(*i);
00963   }
00964 }
00965 
00967 
00968 template<int N, typename T>
00969 inline
00970 void
00971 applyTanh(FixedArray<N,T>* x) {
00972   for (typename FixedArray<N,T>::iterator i = x->begin(); i != x->end(); 
00973        ++i) {
00974     *i = std::tanh(*i);
00975   }
00976 }
00977 
00978 
00979 
00980 //----------------------------------------------------------------------------
00981 // Standard math functions.
00982 //----------------------------------------------------------------------------
00983 
00985 
00986 template<int N, typename T>
00987 inline
00988 FixedArray<N,T>
00989 abs(FixedArray<N,T> x) {
00990   applyAbs(&x);
00991   return x;
00992 }
00993 
00995 
00996 template<int N, typename T>
00997 inline
00998 FixedArray<N,T>
00999 acos(FixedArray<N,T> x) {
01000   applyAcos(&x);
01001   return x;
01002 }
01003 
01005 
01006 template<int N, typename T>
01007 inline
01008 FixedArray<N,T>
01009 asin(FixedArray<N,T> x) {
01010   applyAsin(&x);
01011   return x;
01012 }
01013 
01015 
01016 template<int N, typename T>
01017 inline
01018 FixedArray<N,T>
01019 atan(FixedArray<N,T> x) {
01020   applyAtan(&x);
01021   return x;
01022 }
01023 
01025 
01026 template<int N, typename T>
01027 inline
01028 FixedArray<N,T>
01029 ceil(FixedArray<N,T> x) {
01030   applyCeil(&x);
01031   return x;
01032 }
01033 
01035 
01036 template<int N, typename T>
01037 inline
01038 FixedArray<N,T>
01039 cos(FixedArray<N,T> x) {
01040   applyCos(&x);
01041   return x;
01042 }
01043 
01045 
01046 template<int N, typename T>
01047 inline
01048 FixedArray<N,T>
01049 cosh(FixedArray<N,T> x) {
01050   applyCosh(&x);
01051   return x;
01052 }
01053 
01055 
01056 template<int N, typename T>
01057 inline
01058 FixedArray<N,T>
01059 exp(FixedArray<N,T> x) {
01060   applyExp(&x);
01061   return x;
01062 }
01063 
01065 
01066 template<int N, typename T>
01067 inline
01068 FixedArray<N,T>
01069 floor(FixedArray<N,T> x) {
01070   applyFloor(&x);
01071   return x;
01072 }
01073 
01075 
01076 template<int N, typename T>
01077 inline
01078 FixedArray<N,T>
01079 log(FixedArray<N,T> x) {
01080   applyLog(&x);
01081   return x;
01082 }
01083 
01085 
01086 template<int N, typename T>
01087 inline
01088 FixedArray<N,T>
01089 log10(FixedArray<N,T> x) {
01090   applyLog10(&x);
01091   return x;
01092 }
01093 
01095 
01096 template<int N, typename T>
01097 inline
01098 FixedArray<N,T>
01099 sin(FixedArray<N,T> x) {
01100   applySin(&x);
01101   return x;
01102 }
01103 
01105 
01106 template<int N, typename T>
01107 inline
01108 FixedArray<N,T>
01109 sinh(FixedArray<N,T> x) {
01110   applySinh(&x);
01111   return x;
01112 }
01113 
01115 
01116 template<int N, typename T>
01117 inline
01118 FixedArray<N,T>
01119 sqrt(FixedArray<N,T> x) {
01120   applySqrt(&x);
01121   return x;
01122 }
01123 
01125 
01126 template<int N, typename T>
01127 inline
01128 FixedArray<N,T>
01129 tan(FixedArray<N,T> x) {
01130   applyTan(&x);
01131   return x;
01132 }
01133 
01135 
01136 template<int N, typename T>
01137 inline
01138 FixedArray<N,T>
01139 tanh(FixedArray<N,T> x) {
01140   applyTanh(&x);
01141   return x;
01142 }
01143 
01144 
01145 //----------------------------------------------------------------------------
01146 // Equality Operators
01147 //----------------------------------------------------------------------------
01148 
01150 
01151 template<typename T1, typename T2, int N>
01152 inline
01153 bool
01154 operator==(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b);
01155 
01157 
01158 template<typename T1, typename T2, int N>
01159 inline
01160 bool
01161 operator!=(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b)
01162 { 
01163   return !(a == b); 
01164 }
01165 
01166 
01167 //
01168 // Comparison Operators
01169 //
01170 
01172 
01173 template<typename T1, typename T2, int N>
01174 bool
01175 operator<(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b);
01176 
01178 
01179 template<typename T1, typename T2, int N>
01180 inline
01181 bool
01182 operator>(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b)
01183 {
01184   return b < a;
01185 }
01186 
01188 
01189 template<typename T1, typename T2, int N>
01190 inline
01191 bool
01192 operator<=(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b)
01193 {
01194   return !(b < a);
01195 }
01196 
01198 
01199 template<typename T1, typename T2, int N>
01200 inline
01201 bool
01202 operator>=(const FixedArray<N,T1>& a, const FixedArray<N,T2>& b)
01203 {
01204   return !(a < b);
01205 }
01206 
01207 
01208 //
01209 // File I/O
01210 //
01211 
01213 
01214 template<int N, typename T>
01215 std::ostream&
01216 operator<<(std::ostream& out, const FixedArray<N,T>& p);
01217     
01219 
01220 template<int N, typename T>
01221 std::istream&
01222 operator>>(std::istream& in, FixedArray<N,T>& p);
01223 
01225 
01226 template<int N, typename T>
01227 void
01228 write_elements_binary(std::ostream& out, const FixedArray<N,T>& x);
01229     
01231 
01232 template<int N, typename T>
01233 void
01234 read_elements_binary(std::istream& in, FixedArray<N,T>& x);
01235 
01236 
01237 END_NAMESPACE_ADS
01238 
01239 #define __FixedArray_ipp__
01240 #include "FixedArray.ipp"
01241 #undef __FixedArray_ipp__
01242 
01243 #define __FixedArray0_h__
01244 #include "FixedArray0.h"
01245 #undef __FixedArray0_h__
01246 
01247 #define __FixedArray1_h__
01248 #include "FixedArray1.h"
01249 #undef __FixedArray1_h__
01250 
01251 #define __FixedArray2_h__
01252 #include "FixedArray2.h"
01253 #undef __FixedArray2_h__
01254 
01255 #define __FixedArray3_h__
01256 #include "FixedArray3.h"
01257 #undef __FixedArray3_h__
01258 
01259 #endif

Generated on Fri Aug 24 12:55:24 2007 for Algorithms and Data Structures Package by  doxygen 1.4.7