Actual source code: taovec_ga.h

  1: /**************************************************************
  2: File: taovec_ga.h

  4: TAO/GA project

  6: Author: Limin Zhang, Ph.D.
  7:         Mathematics Department
  8:         Columbia Basin College
  9:         Pasco, WA 99301
 10:         Limin.Zhang@cbc2.org

 12: Mentor: Jarek Naplocha, Ph.D.
 13:         Environmental Molecular Science Laboratory
 14:         Pacific Northwest National Laboratory
 15:         Richland, WA 99352

 17: Date: 7/11/2002
 18: Revised: (1) 7/15/02
 19:          replace pv with this->pv  
 20:          introduce GAVec as int so that it looks like PetscVec
 21:          (2) 9/6/02
 22:          reformat it so that it has the same look as taovec.h. It also made clear
 23:          about which member functions have been inherited from the base class TaoVec defined in taovec.h

 25: Purpose:
 26:       to design and implement a tao/ga vector using 
 27:       global arrays.
 28: **************************************************************/



 32: #ifndef TAOVEC_GA_H
 33: #define TAOVEC_GA_H

 35: #include "taovec.h"
 36: #include "ga.h"        //to define GA lib
 37: #include "macdecls.h"  //to define GA constants like MT_C_DBL


 40: typedef int GAVec;  //GAVec is the native global array vector. In fact, it is the global array handle.
 41: typedef double GAScalar; //The only data we suppoort for the moment is double.

 43: class TaoVecGa: public TaoVec{

 45:  protected:

 47:    GAVec pv; //pv is the global array handle that means the pointer to the vector.
 48:  
 49:  public:

 51:   TaoVecGa( GAVec);
 52:   ~TaoVecGa(){ if (pv) GA_Destroy(pv);}; 

 54:   //void* VecObject; is inherited from TaoVec class.

 56:   inline GAVec GetVec(){return pv;}

 58:   virtual int Clone(TaoVec**);
 59:   //int CloneVecs(int, TaoVec***); is inherited from TaoVec class.
 60:   //int DestroyVecs(int, TaoVec**);is inherited from TaoVec class.

 62:   virtual int  Compatible (TaoVec *v, TaoTruth *flag);

 64:   /** Set all elements of this Tao Vector to zero. */
 65:   virtual int SetToZero();
 66:   /** Set all elements of this Tao Vector to the constant value c */
 67:   virtual int SetToConstant( TaoScalar );

 69:   /** Copy the elements of one vector to another */
 70:   virtual int CopyFrom( TaoVec* );

 72:   virtual int ScaleCopyFrom( TaoScalar, TaoVec* );

 74:   /** Return the norm of this Tao Vector. */  
 75:   virtual int NormInfinity(TaoScalar *);
 76:   virtual int Norm1(TaoScalar *);
 77:   virtual int Norm2(TaoScalar *);
 78:   virtual int Norm2squared(TaoScalar *);

 80:   /** Multiply the components of this Tao Vector by the components of v. */
 81:   virtual int PointwiseMultiply( TaoVec*, TaoVec* );

 83:   /** Divide the components of this Tao Vector by the components of v. */
 84:   virtual int PointwiseDivide( TaoVec*, TaoVec* ); 

 86:   /** Set the elements of one vector to the max/min of corresponding elements of two compatible vectors */
 87:   virtual int PointwiseMinimum( TaoVec*, TaoVec* );
 88:   virtual int PointwiseMaximum( TaoVec*, TaoVec* ); 

 90:   /** Set the elements of one vector to the median of corresponding elements of three compatible vectors */
 91:   virtual int Median( TaoVec* , TaoVec*, TaoVec* );

 93:   /** Calculate the fischer function (using billups composition) given
 94:       x, f, l, u
 95:   */
 96:   virtual int Fischer(TaoVec *, TaoVec *, TaoVec *, TaoVec *);
 97:   
 98:   /** Scale each element of this Tao Vector by the constant alpha */
 99:   virtual int Scale( TaoScalar );
100:    
101:   /** this += alpha * x */
102:   virtual int Axpy( TaoScalar, TaoVec* );
103:   
104:   /** this = alpha * this + x */
105:   virtual int Aypx  ( TaoScalar, TaoVec* );
106:   
107:   
108:   /*Adds a scalar multiple of a vector to a multiple of this vector. (this=alpha*xx + beta*this) */
109:   virtual int Axpby  ( TaoScalar , TaoVec*, TaoScalar  );

111:   /** this = alpha * x + beta *y */
112:   virtual int Waxpby  ( TaoScalar , TaoVec*, TaoScalar , TaoVec* );

114:   /** Take the absolute value of the elements */
115:   virtual int AbsoluteValue( );
116:  
117:   /** Take the minimum of the absolute value of the elements */
118:   virtual int MinElement(TaoScalar*);

120:   /** Add c to the elements of this Tao Vector */
121:   virtual int AddConstant( TaoScalar );
122:  
123:   /** Return the dot product of this Tao Vector with v */
124:   virtual int Dot( TaoVec*, TaoScalar *);

126:   /** Negate all the elements of this Tao Vector. */
127:   virtual int Negate();

129:   /** Invert (1/x) the elements of this Tao Vector. */
130:   virtual int Reciprocal();

132:   /* Replace each element with a -1, 0, or 1, depending on its sign.  */
133:   //  virtual int Sign();

135:   /** Get the dimension of the vector space */
136:   virtual int GetDimension(int *);

138:   /* View */
139:   virtual int View();

141:   /* stepMax */
142:   virtual int StepMax( TaoVec* , double* );
143:   virtual int StepMax2 (TaoVec *, TaoVec *, TaoVec *, TaoScalar *);
144:   virtual int StepBoundInfo(TaoVec* ,TaoVec*,TaoVec*,double*,double*,double*);
145:   virtual int BoundGradientProjection(TaoVec*,TaoVec*,TaoVec*, TaoVec*);

147:   /* Functionality for working in a reduced space */
148:   virtual int SetReducedVec(TaoVec*, TaoIndexSet*);
149:   virtual int ReducedCopyFromFull(TaoVec*, TaoIndexSet*);
150:   virtual int ReducedXPY(TaoVec*, TaoIndexSet*);
151:   virtual int CreateIndexSet(TaoIndexSet**S);

153:   /* Sets a pointer to the first element in the vector array on the local patch. */
154:   virtual int GetArray(TaoScalar **, int*);
155:  
156:   /* Returns a pointer to the first element in the vector array on the local patch.*/ 
157:   virtual int RestoreArray(TaoScalar **, int*);

159: };


162: int TaoWrapGaVec (GAVec V, TaoVecGa ** TV);
163: int TaoVecGetGaVec (TaoVec * TV, GAVec *V);

165: #endif