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_INTVEC_H
00032 #define SUNDANCE_INTVEC_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include "Teuchos_Array.hpp"
00036 #include "PlayaPrintable.hpp"
00037
00038 namespace Sundance
00039 {
00040 using Teuchos::Array;
00041 using Teuchos::tuple;
00042
00043
00044
00045
00046
00047
00048 class IntVec : public Playa::Printable
00049 {
00050 public:
00051
00052 IntVec(){}
00053
00054 IntVec(const Array<int>& d) : data_(d) {}
00055
00056 IntVec(int n);
00057
00058
00059 int size() const {return data_.size();}
00060
00061
00062 int operator[](int i) const {return data_[i];}
00063
00064
00065 int& operator[](int i) {return data_[i];}
00066
00067
00068 IntVec operator+(const IntVec& other) const ;
00069
00070
00071 IntVec operator*(int alpha) const ;
00072
00073
00074 int factorial() const ;
00075
00076
00077 int pow(const IntVec& other) const ;
00078
00079
00080 int abs() const ;
00081
00082
00083 int norm() const ;
00084
00085
00086 bool operator==(const IntVec& other) const ;
00087
00088
00089 bool operator<(const IntVec& other) const ;
00090
00091
00092 void print(std::ostream& os) const ;
00093
00094
00095
00096
00097
00098 void getPartitions(int M, Array<Array<IntVec> >& parts) const ;
00099
00100 private:
00101 Array<int> data_;
00102 };
00103
00104
00105
00106
00107 inline IntVec operator*(int a, const IntVec& x)
00108 {
00109 return x * a;
00110 }
00111
00112
00113 inline std::ostream& operator<<(std::ostream& os, const IntVec& v)
00114 {
00115 v.print(os);
00116 return os;
00117 }
00118
00119
00120 inline IntVec intVec(int a)
00121 {
00122 Array<int> dat = tuple(a);
00123 return dat;
00124 }
00125
00126
00127 inline IntVec intVec(int a, int b)
00128 {
00129 Array<int> dat = tuple(a, b);
00130 return dat;
00131 }
00132
00133
00134 inline IntVec intVec(int a, int b, int c)
00135 {
00136 Array<int> dat = tuple(a, b, c);
00137 return dat;
00138 }
00139
00140
00141 inline IntVec intVec(int a, int b, int c, int d)
00142 {
00143 Array<int> dat = tuple(a, b, c, d);
00144 return dat;
00145 }
00146
00147
00148 inline IntVec intVec(int a, int b, int c, int d, int e)
00149 {
00150 Array<int> dat = tuple(a, b, c, d, e);
00151 return dat;
00152 }
00153
00154
00155
00156 }
00157
00158
00159
00160
00161 #endif