Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

IVector.h

Go to the documentation of this file.
00001  /**********************************************************************
00002   *                                                                    *
00003   * Copyright (c) 2002 Andreas Pfeiffer, CERN/IT                       *
00004   *                    <andreas.pfeiffer@cern.ch>                      *
00005   *                                                                    *
00006   * This library is free software; you can redistribute it and/or      *
00007   * modify it under the terms of the GNU Lesser General Public         *
00008   * License as published by the Free Software Foundation; either       *
00009   * version 2.1 of the License, or (at your option) any later version. *
00010   *                                                                    *
00011   * This library is distributed in the hope that it will be useful,    *
00012   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00013   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014   * Lesser General Public License for more details.                    *
00015   *                                                                    *
00016   * You should have received a copy of the GNU Lesser General Public   *
00017   * License along with this library (see file COPYING); if not, write  *
00018   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00019   * 330, Boston, MA 02111-1307 USA, or contact the author              *
00020   **********************************************************************/
00021 
00022 // 
00023 // header file for class IVector 
00024 // Created by: Andreas Pfeiffer  at Wed Sep  1 11:12:01 1999
00025 // 
00026 // Last update: 
00027 //              
00028 //   ap, 16-jan-01 : cleaned up std:: stuff 
00029 // 
00030 #ifndef INTERFACES_IVECTOR_H
00031 #define INTERFACES_IVECTOR_H 1
00032 
00033 #include <iostream>
00034 #include <vector>
00035 
00036 #ifdef AIDA_DONT_USE_STD
00037 typedef istream std_istream;
00038 #else
00039 typedef std::istream std_istream;
00040 #endif
00041 
00042 #ifndef ANAPHE_NO_NAMESPACE
00043 namespace Anaphe {
00044 #endif
00045 
00046   class IAnnotation;
00047 
00048 //-ap  class IHistogram1D;
00049 //-ap  class IHistogram2D;
00050 //-ap  class IProfileHistogram;
00051 
00052   class IScalar  { 
00053 
00054   public: 
00055     virtual ~IScalar() { /* nop */; }
00056 
00057   public:
00058     // for assignment and copyConstructor rely on compiler's version
00059 
00060   public:               // public methods
00061     virtual void   scale(double s) = 0;
00062     virtual void   shift(double s) = 0;
00063 
00064   public:               // public methods
00065     virtual double value()  const = 0;
00066     virtual double ePlus()  const = 0;
00067     virtual double eMinus() const = 0;
00068 
00069   public:               // public methods
00070     virtual void setValue (double val) = 0;
00071     virtual void setEPlus (double val) = 0;
00072     virtual void setEMinus(double val) = 0;
00073 
00074   public:
00075     virtual void fromAscii(std_istream &is) = 0;
00076 
00077   public:
00078     //
00079     // Arithmetic operations with other IScalars.
00080     // In order to avoid creating new objects (and problems with ownership)
00081     // the operations modify "this" like: "this" [+-*/]= "other" ...
00082     // The implementation has to correctly propagate the errors (assuming independence).
00083     // (this should be done using an external ErrorPropagationStrategy which can be
00084     // re-defined by the user).
00085     // Division by 0 sets this.value to 0, 
00086     // other.error == 0  sets  this.error = 0
00087     virtual void addScalar(const IScalar * other) = 0;
00088     virtual void subScalar(const IScalar * other) = 0;
00089     virtual void mulScalar(const IScalar * other) = 0;
00090     virtual void divScalar(const IScalar * other) = 0;
00091 
00092     // ... and with doubles (implemented using scale/shift)
00093     virtual void add(double val) = 0;
00094     virtual void sub(double val) = 0;
00095     virtual void mul(double val) = 0;
00096     virtual void div(double val) = 0;
00097 
00098     // merging with another scalar. This sets the value to the
00099     // weighted average of the two and the error to the combined error
00100     virtual void merge(const IScalar * other) = 0;
00101 
00102   }; 
00103 
00104   class IPoint  { 
00105 
00106   public: 
00107     virtual ~IPoint() { /* nop */; }
00108 
00109   public:
00110     // for assignment and copyConstructor rely on compiler's version
00111 
00112   public:               // public methods
00113     virtual int  dimension() const = 0;
00114 
00115     // set dimensionality (== # of axes). This call is ignored, if the Point has already 
00116     // been initialized, i.e., the coordinates have been set.
00117     virtual void setDimension(int dim) = 0; 
00118 
00119   public:               // public methods
00120     virtual double value()     const  = 0;
00121     virtual double vPlus()     const  = 0;
00122     virtual double vMinus()    const  = 0;
00123 
00124   public:
00125     virtual void scaleValue(double scale)  = 0;
00126     virtual void shiftValue(double scale)  = 0;
00127 
00128   public:
00129     virtual double coordinate(int index) const = 0;
00130     virtual double coordPlus (int index) const = 0;
00131     virtual double coordMinus(int index) const = 0;
00132 
00133     virtual void  scaleCoordinate(int index, double scale) = 0;
00134     virtual void  shiftCoordinate(int index, double scale) = 0;
00135 
00136   public:
00137     // reading from ASCII file. This will overwrite (== destroy) any information already stored.
00138     virtual void  fromAscii(std_istream &is) = 0;
00139 
00140     // modifiers ... (first, for SWIGification :-))
00141     virtual IScalar * coordScalar(int index) = 0;
00142     virtual IScalar * vScalar()  = 0;
00143 
00144     virtual const IScalar * coordScalar(int index) const = 0;
00145     virtual const IScalar * vScalar() const  = 0;
00146 
00147   public:
00148     //
00149     // Arithmetic operations with other IPoints, acting on the "value" only,
00150     // the coordinates are not updated.
00151     // In order to avoid creating new objects (and problems with ownership)
00152     // the operations modify "this" like: "this" [+-*/]= "other" ...
00153     // The implementation has to correctly propagate the errors (assuming independence).
00154     // These operations are only defined if the dimension (number of coordinates) is
00155     // equal. 
00156     // 
00157     virtual void addPoint(const IPoint * other) = 0;
00158     virtual void subPoint(const IPoint * other) = 0;
00159     virtual void mulPoint(const IPoint * other) = 0;
00160     virtual void divPoint(const IPoint * other) = 0;
00161 
00162     // ... and with doubles (implemented using scale/shift) acting on the "value"
00163     virtual void add(double val) = 0;
00164     virtual void sub(double val) = 0;
00165     virtual void mul(double val) = 0;
00166     virtual void div(double val) = 0;
00167   };
00168 
00169 
00170   class IVector  { 
00171 
00172   public: 
00173     virtual ~IVector()  { /* nop */; }
00174 
00175   public:
00176     // for assignment and copyConstructor rely on compiler's version
00177 
00178     virtual IVector * deepClone() = 0;          // return an independent copy of self
00179 
00180   public:
00181     virtual       IAnnotation * annotation()       = 0; 
00182     virtual const IAnnotation * annotation() const = 0;
00183 
00184   public:
00185     virtual int  dimension()          const = 0; // dimension = number of coordinate axes
00186 
00187     // set # of points along each of axes. This call is ignored, if the Vector has already
00188     // been "set", i.e., the points are already stored.
00189 #ifdef AIDA_DONT_USE_STD
00190     virtual void setPointsPerDim(     vector<int> vIn) = 0; 
00191 #else
00192     virtual void setPointsPerDim(std::vector<int> vIn) = 0; 
00193 #endif
00194 
00195     virtual int nPoints()             const = 0; // total number of Points in vector 
00196     virtual int nPoints(int index)    const = 0; // number of Points along dimension "index"
00197 
00198   public:
00199     // remove point specified by index in linear access (even for higher dimensions)
00200     virtual void removePoint(int index) = 0; 
00201 
00202     // add new point 
00203     virtual void addPoint(IPoint * newPoint) = 0; 
00204 
00205     // modifiers ... (first, for SWIGification :-))
00206     virtual IPoint * point(int index) = 0;                          // index by linear access (even for higher dimensions)
00207     virtual IPoint * point(int indexX, int indexY) = 0;             // index by x/y    access (for user conveniency)
00208     virtual IPoint * point(int indexX, int indexY, int indexZ) = 0; // index by x/y/z  access (for user conveniency)
00209 
00210     virtual const IPoint * point(int index) const = 0;                          // index by linear access (even for higher dimensions)
00211     virtual const IPoint * point(int indexX, int indexY) const = 0;             // index by x/y    access (for user conveniency)
00212     virtual const IPoint * point(int indexX, int indexY, int indexZ) const = 0; // index by x/y/z  access (for user conveniency)
00213     //-ap #ifdef AIDA_DONT_USE_STD
00214     //-ap       virtual IPoint * point(     vector<int> ijk) const = 0; // index by "array" access (for higher dims, validating dim)
00215     //-ap #else
00216     //-ap       virtual IPoint * point(std::vector<int> ijk) const = 0; // index by "array" access (for higher dims, validating dim)
00217     //-ap #endif
00218 
00219   public:
00220     virtual IPoint * maxValue() const = 0;
00221     virtual IPoint * minValue() const = 0;
00222 
00223   public:
00224     virtual void scaleV(double scale) = 0;
00225     virtual void shiftV(double shift) = 0;
00226 
00227     virtual void scaleCoordinate(int index, double scale) = 0;
00228     virtual void shiftCoordinate(int index, double shift) = 0;
00229 
00230   public:
00231 
00232     // writing the vector to an ASCII file. Format fixed at present, later XML.
00233     virtual void toAscii(const char * file)  = 0;
00234 
00235     // reading vector back from ASCII file (format fixed, later XML). This will 
00236     // overwrite (== destroy) any information already stored in the vector.
00237     virtual void fromAscii(const char *file) = 0;
00238 
00239 //-ap    virtual void fromHisto1D(IHistogram1D * hist) = 0;
00240 //-ap    virtual void fromHisto2D(IHistogram2D * hist) = 0;
00241 //-ap    virtual void fromProfile(IProfileHistogram * hist, const char * opt = 0) = 0;
00242 
00243     virtual void replaceFromFunction(int i, double val) = 0;
00244 
00245   public:
00246     //
00247     // Arithmetic operations with other IVectors, acting on the "value" only,
00248     // the coordinates are not updated.
00249     // In order to avoid creating new objects (and problems with ownership)
00250     // the operations modify "this" like: "this" [+-*/]= "other" ...
00251     // The implementation has to correctly propagate the errors (assuming independence).
00252     // These operations are only defined if the dimension (number of coordinates) is
00253     // equal. 
00254     // 
00255     virtual void addVector(const IVector * other) = 0;
00256     virtual void subVector(const IVector * other) = 0;
00257     virtual void mulVector(const IVector * other) = 0;
00258     virtual void divVector(const IVector * other) = 0;
00259 
00260     // ... and with doubles (implemented using scale/shift) acting on the "value"
00261     virtual void add(double val) = 0;
00262     virtual void sub(double val) = 0;
00263     virtual void mul(double val) = 0;
00264     virtual void div(double val) = 0;
00265   }; 
00266 
00267 #ifndef ANAPHE_NO_NAMESPACE
00268 }; // end namespace Anaphe
00269 #endif
00270 
00271 
00272 #endif /* INTERFACES_IVECTOR_H */ 


Anaphe documentation generated by Doxygen (www.doxygen.org)