Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

MultiIndex.h

Go to the documentation of this file.
00001 #ifndef MULTIINDEX_H
00002 #define MULTIINDEX_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "TSFError.h"
00007 #include <string>
00008 #include "XMLObject.h"
00009 
00010 
00011 
00012 namespace Sundance
00013 {
00014 
00015   using namespace TSF;
00016   using std::string;
00017 
00018   using std::ostream;
00019 
00020   /** \ingroup LowLevelSymbolics
00021    * An integer vector representing a multivariate derivative.
00022    */
00023 
00024   class MultiIndex
00025     {
00026     public:
00027       /** \name Developer-only methods */
00028       //@{
00029       /** no detailed doc */
00030       MultiIndex();
00031       /** */
00032       MultiIndex(int x);
00033       /** */
00034       MultiIndex(int x, int y);
00035       /** */
00036       MultiIndex(int x, int y, int z);
00037       /** */
00038       MultiIndex(const MultiIndex& other);
00039       /** */
00040       MultiIndex& operator=(const MultiIndex& other);
00041 
00042       /** */
00043       bool operator==(const MultiIndex& other) const ;
00044       /** */
00045       bool operator<(const MultiIndex& other) const ;
00046 
00047       /** */
00048       int direction() const ;
00049       /** */
00050       int order() const ;
00051       /** */
00052       int order(int dir) const ;
00053       /** */
00054       int maxDim() const {return 3;}
00055       /** */
00056       void setFirstOrderDirection(int d) ;
00057 
00058       /** */
00059       MultiIndex& operator+=(const MultiIndex& other);
00060 
00061       /** */
00062       string toString() const ;
00063       /** */
00064       XMLObject toXML() const ;
00065       //@}
00066     private:
00067       int dx_[3];
00068       int order_;
00069       int firstOrderDirection_;
00070     };
00071 
00072 
00073 
00074   inline MultiIndex::MultiIndex()
00075     : order_(0), firstOrderDirection_(-1)
00076     {dx_[0]=0; dx_[1]=0; dx_[2]=0;}
00077 
00078   inline int MultiIndex::direction() const
00079     {
00080       if (order_==1) return firstOrderDirection_;
00081       return -1;
00082     }
00083 
00084   inline int MultiIndex::order() const
00085     {
00086       return order_;
00087     }
00088 
00089   inline int MultiIndex::order(int i) const
00090     {
00091 #ifndef NOBOUNDSCHECK
00092       if (i<0 || i>2) TSFError::raise("MultiIndex::order");
00093 #endif
00094       return dx_[i];
00095     }
00096 
00097   inline void MultiIndex::setFirstOrderDirection(int d)
00098     {
00099       dx_[d] = 1;
00100       order_ = 1;
00101       firstOrderDirection_ = d;
00102     }
00103 
00104   inline ostream& operator<<(ostream& os, const MultiIndex& d)
00105     {
00106       os << "(" << d.order(0) << ", " << d.order(1) << ", "
00107          << d.order(2) << ")";
00108       return os;
00109     }
00110 
00111   inline string toString(const MultiIndex& d)
00112     {
00113       return "(" + TSF::toString(d.order(0)) + ", "
00114         + TSF::toString(d.order(1)) + ", "
00115         + TSF::toString(d.order(2)) + ")";
00116     }
00117 
00118 }
00119 #endif

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by