00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef SUNDANCE_MULTIINDEX_H
00032 #define SUNDANCE_MULTIINDEX_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "Teuchos_Array.hpp"
00036 #include "Teuchos_XMLObject.hpp"
00037 #include <string>
00038 #include <stdexcept>
00039 
00040 namespace Sundance
00041 {
00042 using namespace Teuchos;
00043 
00044 
00045 
00046 
00047 
00048 class MultiIndex
00049 {
00050 public:
00051 
00052   MultiIndex();
00053 
00054   MultiIndex(int x, int y, int z);
00055 
00056 
00057   bool operator==(const MultiIndex& other) const ;
00058 
00059 
00060   bool operator<(const MultiIndex& other) const ;
00061 
00062 
00063   const int& operator[](int i) const {return m_[i];}
00064 
00065 
00066   int& operator[](int i) {return m_[i];}
00067 
00068 
00069   MultiIndex operator+(const MultiIndex& other) const ;
00070 
00071 
00072   MultiIndex operator-(const MultiIndex& other) const ;
00073 
00074 
00075   MultiIndex operator-() const ;
00076 
00077 
00078   std::string toString() const ;
00079 
00080 
00081   XMLObject toXML() const ;
00082 
00083 
00084   int order() const ;
00085 
00086 
00087   int firstOrderDirection() const ;
00088 
00089 
00090   static int maxDim() {return 3;}
00091 
00092 
00093   bool isValid() const ;
00094 
00095 
00096   std::string coordForm() const ;
00097 private:
00098   Array<int> m_;
00099 };
00100 }
00101 
00102 namespace Teuchos
00103 {
00104 
00105 
00106 inline std::string toString(const Sundance::MultiIndex& h)
00107 {return h.toString();}
00108 
00109 }
00110 
00111 namespace std
00112 {
00113 
00114 inline ostream& operator<<(std::ostream& os, 
00115   const Sundance::MultiIndex& h)
00116 {
00117   os << h.toString();
00118   return os;
00119 }
00120 }
00121 
00122 #endif