00001 #ifndef _SHIFT_H_ 00002 #define _SHIFT_H_ 00003 #include "SPACE.H" 00004 #include "Point.H" 00005 #include <array> 00006 00007 using namespace std; 00008 /// A direction in space represented by a Point object. 00009 class Shift 00010 { 00011 public: 00012 /// Default Constructor 00013 inline Shift(){m_shift = getZeros();}; 00014 /// Construct a Shift using a Point 00015 inline Shift(Point a_pt){m_shift = a_pt;}; 00016 /// Defines the "*" operator between two Shift objects. 00017 /** 00018 The product of two Shifts results in a new Shift which is the sum of the two base objects' vectors. 00019 */ 00020 inline Shift operator*(Shift a_s){return Shift(m_shift + a_s.m_shift);}; 00021 00022 /// Retrieves the data in *this. 00023 inline Point getExp(){return m_shift;}; 00024 00025 /// Retrieves the data corresponding to direction dir in *this. 00026 inline int getExp(int dir){return m_shift[dir];}; 00027 00028 Point m_shift; ///< Direction of the Shift. 00029 00030 /// Print method. 00031 /** 00032 Calls Point.print() 00033 */ 00034 inline void print(){m_shift.print();}; 00035 }; 00036 00037 //// Implementation 00038 /// Creates a Shift with m_shift = (1,1,...,1) 00039 inline Shift getUnitShift(){return Shift(getOnes());}; 00040 00041 /// Creates an array of unit shift objects. 00042 /** 00043 The k'th component of the output array is a Shift object with m_shift(j) = \f$\delta_j^k\f$. 00044 */ 00045 inline array<Shift,DIM> getShiftVec() 00046 { 00047 array<Shift,DIM> ret; 00048 for (int dir = 0; dir < DIM; dir++) 00049 { 00050 ret[dir] = Shift(getUnitv(dir)); 00051 } 00052 return ret; 00053 }; 00054 00055 /// Produce a Shift equal to the sum of the elements of a_shiftvec, each weighted by the components of a_exp. 00056 inline Shift operator^(array<Shift,DIM> a_shiftvec,Point a_exp) 00057 { 00058 Shift ret; 00059 for (int dir = 0; dir < DIM; dir++) 00060 { 00061 ret = ret * Shift((a_shiftvec[dir].m_shift)*a_exp[dir]); 00062 } 00063 return ret; 00064 } 00065 #endif