Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:08

0001 // -*- C++ -*-
0002 // AID-GENERATED
0003 // =========================================================================
0004 // This class was generated by AID - Abstract Interface Definition          
0005 // DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it. 
0006 // =========================================================================
0007 #ifndef AIDA_IFUNCTION_H
0008 #define AIDA_IFUNCTION_H 1
0009 
0010 //  This file is part of the AIDA library
0011 //  Copyright (C) 2002 by the AIDA team.  All rights reserved.
0012 //  This library is free software and under the terms of the
0013 //  GNU Library General Public License described in the LGPL.txt 
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 namespace AIDA {
0019 
0020 class IAnnotation;
0021 
0022 /** @interface IFunction
0023  *
0024  * Principal user-level function interface. Function is a self
0025  * contained object, which remembers the current value of its parameters
0026  * which are simple doubles. IFunction may be directly plotted or fitted.
0027  *
0028  * The standard convention of referring to variables by name:
0029  * "x[0]" corresponds to variable number 0 etc.
0030  *
0031  * @author The AIDA team (http://aida.freehep.org/)
0032  *
0033  */
0034  
0035 class IFunction {
0036 
0037 public: 
0038     /// Destructor.
0039     virtual ~IFunction() { /* nop */; }
0040 
0041     /**
0042      * Get the Function's title.
0043      * @return The Function's title.
0044      *
0045      */
0046     virtual std::string title() const = 0;
0047 
0048     /**
0049      * Set   the histogram title.
0050      * @param title The title.
0051      * @return false If title cannot be changed.
0052      *
0053      */
0054     virtual bool setTitle(const std::string & title) = 0;
0055 
0056     /**
0057      * Scalar value of the function.
0058      */
0059     virtual double value(const std::vector<double>  & x) const = 0;
0060 
0061     /**
0062      * Dimensionality of the domain space.
0063      */
0064     virtual int dimension() const = 0;
0065 
0066     /**
0067      * Compare if functions are the same.
0068      * PENDING: define exactly what it means ;)
0069      */
0070     virtual bool isEqual(const IFunction & f) const = 0;
0071 
0072     /**
0073      * Gradient of the function.
0074      * The result is valid only if providesGradient()==true.
0075      * Otherwise the result is some default (empty) vector.
0076      */
0077     virtual const std::vector<double>  & gradient(const std::vector<double>  & x) const = 0;
0078 
0079     /**
0080      * Determine whether function is able to compute gradient.
0081      */
0082     virtual bool providesGradient() const = 0;
0083 
0084     /**
0085      * Get the symbolic name of i-th variable.
0086      */
0087     virtual std::string variableName(int i) const = 0;
0088 
0089     /**
0090      * Get all the names in a vector.
0091      */
0092     virtual std::vector<std::string>  variableNames() const = 0;
0093 
0094     /**
0095       * Set new vector of parameters.
0096       */
0097     virtual bool setParameters(const std::vector<double>  & params) = 0;
0098 
0099     /**
0100      * Retrieve current vector of parameters.
0101      */
0102     virtual const std::vector<double>  & parameters() const = 0;
0103 
0104     /**
0105      * Number of parameters.
0106      */
0107     virtual int numberOfParameters() const = 0;
0108 
0109     /**
0110      * Names of paramaters.
0111      * Names should be unique. Case-insensitive for comparison.
0112      * Case-sensitive for storage and output.
0113      * All or several names may be left blank "" if the implementation
0114      * does not want to provide them.
0115      */
0116     virtual std::vector<std::string>  parameterNames() const = 0;
0117 
0118     /**
0119      * Set parameter's value by name.
0120      * @param name The name of the parameter.
0121      * @param x    The new value of the parameter.
0122      * @return false If name does not correspond to a parameter.
0123      *
0124      */
0125     virtual bool setParameter(const std::string & name, double x) = 0;
0126 
0127     virtual double parameter(const std::string & name) const = 0;
0128 
0129   /**
0130    * Return -1 if parameter not found (name undefined).
0131    * Leave it because there are use cases - some users prefer to use numbers.
0132    */
0133     virtual int indexOfParameter(const std::string & name) const = 0;
0134 
0135     virtual IAnnotation & annotation() = 0;
0136 
0137     virtual const IAnnotation & annotation() const = 0;
0138 
0139   /**
0140    * String describing the metatype and implementation of the function.
0141    *
0142    * Generic format of the string:
0143    *
0144    * codelet:TYPE:LOCATION
0145    *
0146    * TYPE part contains only a 'typename' string
0147    * which is a metatype identifier (used in plugins and catalogues)
0148    *
0149    * LOCATION may be: 'file', 'verbatim', or 'catalogue'
0150    *
0151    * Detailed description:
0152    *
0153    * codelet:typename - no location specified (using 'catalogue')
0154    *
0155    * codelet:typename:file:/filename.cpp    -  a c++ source file
0156    * codelet:typename:file:/filename.py     -  a python source file
0157    * codelet:typename:file:/filename.so     -  a shared library
0158    *
0159    * codelet:typename:catalogue        - entry in a catalogue repository
0160    *
0161    * codelet:typename:verbatim:cpp \n  - c++ source file included verbatim
0162    *                                     after \n
0163    *
0164    * codelet:typename:verbatim:py  \n  - python source file included
0165    *                                     verbatim aftern \n
0166    *
0167    *
0168    * Comments:
0169    *
0170    * file:/filename is a relative path to $AIDA_FUNCTION_DEFAULT_DIR
0171    * file://filename is an absolute path
0172    *
0173    * Examples:
0174    *
0175    * codelet:G:catalogue
0176    * codelet:userSinus:verbatim:cpp \n { return sin(x); }
0177    */
0178     virtual std::string codeletString() const = 0;
0179 
0180   /**
0181    *  See IManagedObject for a description.
0182    * @param className The name of the class to cast on.
0183    * @return The right pointer. Return 0 if failure.
0184    */ 
0185     virtual void * cast(const std::string & className) const = 0;
0186 
0187     /** @link aggregation */
0188     /*#  IAnnotation lnkIAnnotation; */
0189 }; // class
0190 } // namespace AIDA
0191 #endif /* ifndef AIDA_IFUNCTION_H */