Commit b3b5be8c3de01e1627a1cf7aa67fd01a102e8b15
Merge branch 'hess' into comptel
Showing
412 changed files
with
12415 additions
and
8668 deletions
Too many changes.
To preserve performance only 100 of 412 files are displayed.
AUTHORS
ChangeLog
| 1 | +2012-10-14 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> | |
| 2 | + | |
| 3 | + * Version 0.7.0 released | |
| 4 | + ======================== | |
| 5 | + | |
| 6 | + Add base module for interface classes | |
| 7 | + Introduce GBase from which almost all classes derive | |
| 8 | + Add dependency tracking for Python interface | |
| 9 | + | |
| 1 | 10 | 2012-09-17 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> |
| 2 | 11 | |
| 3 | 12 | * Bug fix version 0.6.2 released | ... | ... |
NEWS
| 1 | -New Features and Important Changes in GammaLib 00-06-02 | |
| 1 | +New Features and Important Changes in GammaLib 00-07-00 | |
| 2 | 2 | |
| 3 | 3 | Author(s) : Juergen Knoedlseder |
| 4 | 4 | |
| 5 | -September, 17th, 2012 | |
| 5 | +October, 14th, 2012 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | 1. Introduction |
| ... | ... | @@ -13,42 +13,7 @@ changes made since the last release of GammaLib. |
| 13 | 13 | |
| 14 | 14 | 2. Configuration |
| 15 | 15 | ----------------- |
| 16 | -The clang++ compiler takes now only precedence over the g++ compiler | |
| 17 | -if the system on which compilation is performed is Mac OS X 10.7 or | |
| 18 | -later. | |
| 19 | - | |
| 20 | -If Python bindings are disabled we omit now all the Python related | |
| 21 | -checks during configuration. This includes detection of the Python | |
| 22 | -executable, detection of the swig executable, and the checks for the | |
| 23 | -presence of the Python wrapper files. | |
| 24 | - | |
| 25 | -The Apple gcc compiler requires the gomp_thread_attr global to be | |
| 26 | -defined when OpenMP functions are called without having any OpenMP | |
| 27 | -section in the code. This specific requirement is now detected in | |
| 28 | -the configure script using some dedicated test code, and the compile | |
| 29 | -definition HAVE_OPENMP_DARWIN_KLUGE is set that allows inclusion of | |
| 30 | -the appropriate code when needed. | |
| 31 | - | |
| 32 | -Furthermore, the OPENMP_LIB_LDFLAGS is not set to -lgomp on Darwin | |
| 33 | -anymore as this appears not to be needed. | |
| 34 | - | |
| 35 | -The MACOSX_DEPLOYMENT_TARGET environment variable is now only exported | |
| 36 | -when the --enable-universalsdk option is specified. This solved problems | |
| 37 | -related to uncatched exceptions in unit tests. Possibly, these uncatched | |
| 38 | -exceptions were due to weak linking, a feature that exists since Mac OS | |
| 39 | -X version 10.2. By not exporting MACOSX_DEPLOYMENT_TARGET, Mac OS X | |
| 40 | -version 10.1 is assumed. | |
| 41 | - | |
| 42 | -The Python bindings configuration has been improved to handle also | |
| 43 | -the MacPorts gcc compiler on Mac OS X. Static linking during unit | |
| 44 | -testing has been removed as this is no longer needed (don't ask me why). | |
| 45 | -The double compilation for unit check has also be removed. A static | |
| 46 | -link is used instead that allows adding of the wrapper directory to | |
| 47 | -the PYTHONPATH. | |
| 48 | - | |
| 49 | -The TEST_ENV_DIR environment variable is also added to the load | |
| 50 | -library path in the GammaLib setup script. This ensures the correct | |
| 51 | -loading of shared libraries in non-standard locations. | |
| 16 | +None | |
| 52 | 17 | |
| 53 | 18 | |
| 54 | 19 | 3. Application module |
| ... | ... | @@ -56,67 +21,80 @@ loading of shared libraries in non-standard locations. |
| 56 | 21 | None |
| 57 | 22 | |
| 58 | 23 | |
| 59 | -4. FITS I/O Interface | |
| 24 | +4. Base module | |
| 25 | +-------------- | |
| 26 | +This new module was introduced to implement interface classes that are | |
| 27 | +used to define standard interfaces for GammaLib classes. | |
| 28 | + | |
| 29 | +The basis of most classes is the GBase class. This class requires the | |
| 30 | +clear, clone, and print methods to be present. The ostream and GLog | |
| 31 | +functions are now also implement at the GBase level, hence classes do | |
| 32 | +not need to implement the output streamers anymore. Classes that do not | |
| 33 | +derive from GBase are essentially internal classes that are not expected | |
| 34 | +to be used by a GammaLib user. | |
| 35 | + | |
| 36 | + | |
| 37 | +5. FITS I/O Interface | |
| 60 | 38 | --------------------- |
| 61 | 39 | None |
| 62 | 40 | |
| 63 | 41 | |
| 64 | -5. Linear algebra module | |
| 42 | +6. Linear algebra module | |
| 65 | 43 | ------------------------ |
| 66 | 44 | None |
| 67 | 45 | |
| 68 | 46 | |
| 69 | -6. Model module | |
| 47 | +7. Model module | |
| 70 | 48 | --------------- |
| 71 | 49 | None |
| 72 | 50 | |
| 73 | 51 | |
| 74 | -7. Numerics module | |
| 52 | +8. Numerics module | |
| 75 | 53 | ------------------ |
| 76 | 54 | None |
| 77 | 55 | |
| 78 | 56 | |
| 79 | -8. Observation module | |
| 57 | +9. Observation module | |
| 80 | 58 | --------------------- |
| 81 | 59 | None |
| 82 | 60 | |
| 83 | 61 | |
| 84 | -9. Optimization module | |
| 85 | ----------------------- | |
| 62 | +10. Optimization module | |
| 63 | +----------------------- | |
| 86 | 64 | None |
| 87 | 65 | |
| 88 | 66 | |
| 89 | -10. Sky module | |
| 67 | +11. Sky module | |
| 90 | 68 | -------------- |
| 91 | 69 | None |
| 92 | 70 | |
| 93 | 71 | |
| 94 | -11. Support module | |
| 72 | +12. Support module | |
| 95 | 73 | ------------------ |
| 96 | 74 | None |
| 97 | 75 | |
| 98 | 76 | |
| 99 | -12. XML module | |
| 77 | +13. XML module | |
| 100 | 78 | -------------- |
| 101 | 79 | None |
| 102 | 80 | |
| 103 | 81 | |
| 104 | -13. Test module | |
| 82 | +14. Test module | |
| 105 | 83 | --------------- |
| 106 | 84 | None |
| 107 | 85 | |
| 108 | 86 | |
| 109 | -14. Multi-wavelength interface | |
| 87 | +15. Multi-wavelength interface | |
| 110 | 88 | ------------------------------ |
| 111 | 89 | None |
| 112 | 90 | |
| 113 | 91 | |
| 114 | -15. Fermi-LAT interface | |
| 92 | +16. Fermi-LAT interface | |
| 115 | 93 | ---------------------- |
| 116 | 94 | None |
| 117 | 95 | |
| 118 | 96 | |
| 119 | -16. CTA interface | |
| 97 | +17. CTA interface | |
| 120 | 98 | ----------------- |
| 121 | 99 | None |
| 122 | 100 | ... | ... |
configure.ac
| ... | ... | @@ -29,10 +29,12 @@ |
| 29 | 29 | ############################################################################# |
| 30 | 30 | # Initialisation # |
| 31 | 31 | ############################################################################# |
| 32 | -AC_INIT([gammalib], [0.6.2], [jurgen.knodlseder@irap.omp.eu], [gammalib]) | |
| 32 | +AC_INIT([gammalib], [0.7.0], [jurgen.knodlseder@irap.omp.eu], [gammalib]) | |
| 33 | 33 | AC_CONFIG_SRCDIR([src/support/GTools.cpp]) |
| 34 | 34 | AC_CONFIG_MACRO_DIR([m4]) |
| 35 | -AM_INIT_AUTOMAKE([gnu no-dependencies]) | |
| 35 | +#AM_INIT_AUTOMAKE([gnu no-dependencies]) | |
| 36 | +AM_INIT_AUTOMAKE([gnu no-dependencies -Wno-portability]) | |
| 37 | +#AM_INIT_AUTOMAKE([gnu -Wno-portability]) | |
| 36 | 38 | AM_CONFIG_HEADER([config.h]) |
| 37 | 39 | |
| 38 | 40 | |
| ... | ... | @@ -670,8 +672,8 @@ if test "x$openmp_ok" = "xyes" ; then |
| 670 | 672 | # dynamically |
| 671 | 673 | if test "$OPENMP_CXXFLAGS" = "-fopenmp" -a "$ac_sys_system" = "Linux"; then |
| 672 | 674 | AC_MSG_CHECKING(whether we can dynamically load libgomp) |
| 673 | - SAVED_LDFLAGS=$LDFLAGS | |
| 674 | - LDFLAGS="$LDFLAGS -ldl" | |
| 675 | + SAVED_LIBS=$LIBS | |
| 676 | + LIBS="-ldl" | |
| 675 | 677 | AC_TRY_RUN(AC_LANG_PROGRAM([#include <dlfcn.h>], |
| 676 | 678 | [if (dlopen("libgomp.so.1", RTLD_NOW) == 0) return 1;]), |
| 677 | 679 | [AC_MSG_RESULT(yes)], |
| ... | ... | @@ -679,7 +681,7 @@ if test "x$openmp_ok" = "xyes" ; then |
| 679 | 681 | AC_MSG_RESULT(no) |
| 680 | 682 | AC_MSG_WARN([OpenMP detected but shared libgomp.so.1 library cannot be dlopen()ed.]) |
| 681 | 683 | AC_MSG_WARN([If you use a gcc 4.2.x compiler, this is a known feature. Try to use gcc >= 4.3.])]) |
| 682 | - LDFLAGS=$SAVED_LDFLAGS | |
| 684 | + LIBS=$SAVED_LIBS | |
| 683 | 685 | fi |
| 684 | 686 | |
| 685 | 687 | # Special Darwin test to see whether OpenMP compiles without adding the |
| ... | ... | @@ -850,6 +852,7 @@ else |
| 850 | 852 | # Do we have Python wrappers |
| 851 | 853 | has_wrappers="yes" |
| 852 | 854 | AC_CHECK_FILES([pyext/gammalib/app_wrap.cpp pyext/gammalib/app.py |
| 855 | + pyext/gammalib/base_wrap.cpp pyext/gammalib/base.py | |
| 853 | 856 | pyext/gammalib/fits_wrap.cpp pyext/gammalib/fits.py |
| 854 | 857 | pyext/gammalib/linalg_wrap.cpp pyext/gammalib/linalg.py |
| 855 | 858 | pyext/gammalib/model_wrap.cpp pyext/gammalib/model.py |
| ... | ... | @@ -1196,7 +1199,7 @@ if [test "x$add_gammalib_prefix" = "xyes"]; then |
| 1196 | 1199 | fi |
| 1197 | 1200 | if [test "x$add_opt_local" = "xyes"]; then |
| 1198 | 1201 | LDFLAGS="$LDFLAGS -L/opt/local/lib" |
| 1199 | - TEST_ENV_DIR="$TEST_ENV_DIR:/opt/local/lib" | |
| 1202 | + #TEST_ENV_DIR="$TEST_ENV_DIR:/opt/local/lib" | |
| 1200 | 1203 | fi |
| 1201 | 1204 | if [test "x$add_usr_local" = "xyes"]; then |
| 1202 | 1205 | LDFLAGS="$LDFLAGS -L/usr/local/lib" |
| ... | ... | @@ -1223,6 +1226,7 @@ DX_INIT_DOXYGEN([GammaLib], [doc/Doxyfile], [doc/doxygen]) |
| 1223 | 1226 | ############################################################################# |
| 1224 | 1227 | AC_CONFIG_FILES([Makefile |
| 1225 | 1228 | src/Makefile |
| 1229 | + src/base/Makefile | |
| 1226 | 1230 | src/support/Makefile |
| 1227 | 1231 | src/linalg/Makefile |
| 1228 | 1232 | src/numerics/Makefile | ... | ... |
doc/Doxyfile
| ... | ... | @@ -31,7 +31,7 @@ PROJECT_NAME = GammaLib |
| 31 | 31 | # This could be handy for archiving the generated documentation or |
| 32 | 32 | # if some version control system is used. |
| 33 | 33 | |
| 34 | -PROJECT_NUMBER = 00-06-02 | |
| 34 | +PROJECT_NUMBER = 00-07-00 | |
| 35 | 35 | |
| 36 | 36 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) |
| 37 | 37 | # base path where the generated documentation will be put. | ... | ... |
doc/dev/coding/gammalib_coding.tex
| 1 | 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | -% GammaLib Coding conventions | |
| 2 | +% GammaLib Coding and Design Conventions | |
| 3 | 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 4 | 4 | |
| 5 | 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -7,12 +7,11 @@ |
| 7 | 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8 | 8 | \newcommand{\task}{\mbox{GammaLib}} |
| 9 | 9 | \newcommand{\this}{\mbox{\tt \task}} |
| 10 | -\newcommand{\shorttype}{\mbox{CCD}} | |
| 11 | -\newcommand{\doctype}{\mbox{Coding Conventions Document}} | |
| 10 | +\newcommand{\shorttype}{\mbox{CDC}} | |
| 11 | +\newcommand{\doctype}{\mbox{Coding and Design Conventions}} | |
| 12 | 12 | \newcommand{\version}{\mbox{draft}} |
| 13 | -\newcommand{\calendar}{\mbox{10 November 2011}} | |
| 13 | +\newcommand{\calendar}{\mbox{12 October 2012}} | |
| 14 | 14 | \newcommand{\auth}{\mbox{J\"urgen Kn\"odlseder}} |
| 15 | -\newcommand{\approv}{\mbox{J\"urgen Kn\"odlseder}} | |
| 16 | 15 | |
| 17 | 16 | |
| 18 | 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -35,10 +34,22 @@ |
| 35 | 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 | 35 | \section{Introduction} |
| 37 | 36 | |
| 38 | -The present document summarises the coding conventions that should be | |
| 39 | -followed in implementing the \this\ toolbox. | |
| 40 | -The respect of coherent coding conventions throughout the code | |
| 41 | -improves code readibility and enhances the portability of the code. | |
| 37 | +This document summarises the coding and design conventions that should be following for | |
| 38 | +the \this\ development. | |
| 39 | + | |
| 40 | +Respecting uniform and coherent coding and design conventions is crucial for software | |
| 41 | +development. | |
| 42 | +They improve code readability, ease code development and maintenance, ensure code | |
| 43 | +portability, and provide standards for the user interface. | |
| 44 | + | |
| 45 | +Coding and design conventions were introduced at a very early stage of the \this\ project, and | |
| 46 | +are followed as strictly as possible. | |
| 47 | +The choices that were made for \this\ were inspired by a large survey of existing C++ coding | |
| 48 | +rules, combined with the experience of the leading code developers. | |
| 49 | +Obviously, there is no single best way to code in C++, and the adopted conventions may not | |
| 50 | +meet the coding usage of individual developers. | |
| 51 | +They should nevertheless be respected strictly, as the \this\ code base is already very large, | |
| 52 | +and assuring uniformity and coherence is a primary goal of the project. | |
| 42 | 53 | |
| 43 | 54 | |
| 44 | 55 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -46,95 +57,590 @@ improves code readibility and enhances the portability of the code. |
| 46 | 57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 47 | 58 | \section{General coding rules} |
| 48 | 59 | |
| 49 | -The following general rules should be followed: | |
| 50 | -\begin{itemize} | |
| 51 | -\item[R1] Each function and/or method terminates with a {\tt return} statement. | |
| 52 | -\item[R2] Each function and/or method has only a single exit point (i.e. a single {\tt return} statement). | |
| 53 | -\item[R3] Put a blank line at the end of each file. | |
| 54 | -\item[R4] Use {\tt explicit} for constructors to avoid use of the constructor for unintended | |
| 55 | -type conversion. | |
| 56 | -\item[R5] Do not use tabs to make code formating independent of editor configurations. | |
| 57 | -\item[R6] Blocks are indented by 4 characters. | |
| 58 | -\end{itemize} | |
| 59 | - | |
| 60 | +This section provides lists of general coding rules for the \this\ development. | |
| 60 | 61 | |
| 61 | 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 62 | -% Coding style | |
| 63 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 64 | -\section{Coding style} | |
| 63 | +\subsection{C++ rules} | |
| 65 | 64 | |
| 66 | 65 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 67 | -\subsection{Code configuration} | |
| 68 | - | |
| 69 | -The code configuration is controlled via an include file that has to be added on top of | |
| 70 | -each source file. | |
| 71 | -Each source file should start with: | |
| 66 | +\paragraph{Code format} | |
| 72 | 67 | |
| 68 | +\begin{itemize} | |
| 69 | +\item Blocks are indented by 4 characters. | |
| 70 | +\item Do not use tabs (code formatting should be independent of editor configurations). | |
| 71 | +\item Do not exceed a line length of 80 characters (a few more characters are in exceptional cases acceptable). | |
| 72 | +\item Put a blank line at the end of each file (this is required by some compilers). | |
| 73 | +\item Each function starts with a curly bracket in the line following the function name. | |
| 74 | +The return type is in the same line as the function name. Example: | |
| 73 | 75 | \begin{verbatim} |
| 74 | -/* __ Includes ___________________________________________________________ */ | |
| 75 | -#ifdef HAVE_CONFIG_H | |
| 76 | -#include <config.h> | |
| 77 | -#endif | |
| 76 | +void function(void) | |
| 77 | +{ | |
| 78 | + int = 0; | |
| 79 | + return; | |
| 80 | +} | |
| 81 | +\end{verbatim} | |
| 82 | +\item Each block should be encompassed in curly brackets, even if the block consists only | |
| 83 | +of a single line. | |
| 84 | +\item The opening curly bracket of a block starts in the same line as the related statement. | |
| 85 | +Example: | |
| 86 | +\begin{verbatim} | |
| 87 | +for (int i = 0; i < 10; ++i) { | |
| 88 | + sum += i; | |
| 89 | +} | |
| 90 | +\end{verbatim} | |
| 91 | +\item Use spaces between code elements (see above example). | |
| 92 | +\item Align successive similar lines on common elements. | |
| 93 | +Example illustrating the alignment on the {\tt =} symbol: | |
| 94 | +\begin{verbatim} | |
| 95 | +m_max = par.m_max; | |
| 96 | +m_prompt = par.m_prompt; | |
| 97 | +sum += par.m_sum; | |
| 78 | 98 | \end{verbatim} |
| 99 | +Example illustrating the alignment in a class definition on the member function name: | |
| 100 | +\begin{verbatim} | |
| 101 | +void log10GeV(const double& eng); | |
| 102 | +void log10TeV(const double& eng); | |
| 103 | +std::string print(void) const; | |
| 104 | +\end{verbatim} | |
| 105 | +\end{itemize} | |
| 79 | 106 | |
| 80 | -Note that the {\tt config.h} file should {\bf not be included in header files}, since header file | |
| 81 | -are used by the outside world for which a different {\tt config.h} include file may exist. | |
| 82 | 107 | |
| 83 | -One of the most common options used throughout \this\ is range checking. | |
| 84 | -Range checking is particularily important during code development since it allows to catch | |
| 85 | -memory leaks. | |
| 86 | -However, range checking is time consuming and thus leads to somewhat slower code. | |
| 87 | -Range checking can thus be disable during installation of \this\ by using | |
| 88 | -{\tt ./configure --disable-range-check} during library installation. | |
| 89 | -Within the code, the following instruction adds range checking that dependens on | |
| 90 | -the library configuration: | |
| 108 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 109 | +\paragraph{Code semantics} | |
| 91 | 110 | |
| 111 | +\begin{itemize} | |
| 112 | +\item Each function and/or method terminates with a {\tt return} statement. | |
| 113 | +\item Each function and/or method has only a single exit point (i.e. a single {\tt return} statement). | |
| 114 | +\item Use {\tt explicit} for constructors with arguments to prevent unintended type conversions. | |
| 115 | +The only exception to this rule is the copy constructor or type conversion constructors. | |
| 116 | +\item Specify {\tt void} for function definitions without arguments. | |
| 117 | +\item Use pre incrementation in loops (pre incrementation is faster than post incrementation). | |
| 118 | +Example: | |
| 92 | 119 | \begin{verbatim} |
| 93 | -#if defined(G_RANGE_CHECK) | |
| 94 | -if (inx < 0 || inx >= m_num) | |
| 95 | - throw GException::out_of_range("GVector::operator(int)", inx, m_num); | |
| 96 | -#endif | |
| 120 | +for (int i = 0; i < 10; ++i) { | |
| 121 | + sum += i; | |
| 122 | +} | |
| 97 | 123 | \end{verbatim} |
| 124 | +\item Where possible (and appropriate), use {\tt std::vector} containers instead of | |
| 125 | +allocating memory. In other words: avoid direct memory allocation. | |
| 126 | +\item Provide comments, comments, comments!!! | |
| 127 | +\end{itemize} | |
| 98 | 128 | |
| 99 | -Range checking is provided if the {\tt G\_RANGE\_CHECK} macro is defined. | |
| 129 | + | |
| 130 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 131 | +\paragraph{Language features} | |
| 132 | + | |
| 133 | +\begin{itemize} | |
| 134 | +\item Do not use templates. | |
| 135 | +\item Do not use macros. | |
| 136 | +\item Do not use namespaces. | |
| 137 | +\item Do not use {\tt \#define} directives for the declaration of constants. Use {\tt const} instead. | |
| 138 | +\item Do not use {\tt std::strncpy}, {\tt std::memcpy} or similar as these functions are corrupted on | |
| 139 | +some systems. | |
| 140 | +\item If possible, pass arguments by reference. | |
| 141 | +\item Use C++ (std::string) instead of C-style (char*) strings. | |
| 142 | +\item Use C++ casts instead of C-style casts. | |
| 143 | +\end{itemize} | |
| 100 | 144 | |
| 101 | 145 | |
| 102 | 146 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 103 | -\subsection{Header inclusions} | |
| 147 | +% Coding conventions | |
| 148 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 149 | +\section{Coding conventions} | |
| 150 | + | |
| 151 | +The style summarizes coding conventions for the \this\ development. | |
| 152 | + | |
| 153 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 154 | +\subsection{C++ classes} | |
| 155 | + | |
| 156 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 157 | +\subsubsection{General rules} | |
| 158 | + | |
| 159 | +Each class should be defined in a pair of individual files: | |
| 160 | +\begin{itemize} | |
| 161 | +\item a header file that defines the class interface (with filename suffix {\tt .hpp}) | |
| 162 | +\item a source code file that implements the class (with filename suffix {\tt .cpp}) | |
| 163 | +\end{itemize} | |
| 164 | +In addition, a SWIG interface file should be provided for the Python bindings (with filename suffix {\tt .i}). | |
| 104 | 165 | |
| 105 | 166 | Each file should contain the {\tt \#include} directives that are necessary for compilation of |
| 106 | 167 | the specific file. |
| 107 | -Only {\tt \#include} directives that are already given by the corresponding header file can | |
| 108 | -be omitted. | |
| 109 | - | |
| 110 | -As \this\ is written in C++, the C++ style headers should be used instead of the C style | |
| 111 | -headers to ensure maximum portability. | |
| 112 | -Examples of common C++ style headers are | |
| 113 | -{\tt <cstdio>} (instead of {\tt <stdio.h>}), | |
| 114 | -{\tt <cmath>} (instead of {\tt <math.h>}), | |
| 115 | -{\tt <cstring>} (instead of {\tt <string.h>}), etc. | |
| 116 | -Functions and types should then be prefixed by {\tt std::}. | |
| 168 | +{\tt \#include} directives that are specified in the header file can be omitted in the source code | |
| 169 | +file, provided that the header file is include in the source code file. | |
| 170 | + | |
| 171 | +The C++ style header files should be used instead of the C style header files to ensure | |
| 172 | +maximum portability. | |
| 173 | +The following table provides the correspondence between C++ and C header files for | |
| 174 | +headers commonly used in \this. | |
| 175 | + | |
| 176 | +%%% Header files correspondence %%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 177 | +\begin{center} | |
| 178 | +\begin{tabular}{lll} | |
| 179 | +\hline | |
| 180 | +\hline | |
| 181 | +\noalign{\smallskip} | |
| 182 | +C++ & C & Function examples \\ | |
| 183 | +\noalign{\smallskip} | |
| 184 | +\hline | |
| 185 | +\noalign{\smallskip} | |
| 186 | +{\tt <cctype>} & & \\ | |
| 187 | +{\tt <cmath>} & {\tt <math.h>} & {\tt std::abs}, {\tt std::cos} \\ | |
| 188 | +{\tt <cfloat>} & & \\ | |
| 189 | +{\tt <cstdio>} & {\tt <stdio.h>} & {\tt std::fopen}, {\tt std::fgets}, {\tt std::fclose}, {\tt std::fprintf}, {\tt std::sprintf} \\ | |
| 190 | +{\tt <cstdlib>} & & \\ | |
| 191 | +{\tt <cstring>} & {\tt <string.h>} & {\tt std::strlen} \\ | |
| 192 | +\noalign{\smallskip} | |
| 193 | +\hline | |
| 194 | +\end{tabular} | |
| 195 | +\end{center} | |
| 196 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 197 | + | |
| 198 | +Note that functions and types should be prefixed by {\tt std::}. | |
| 117 | 199 | For example, |
| 118 | 200 | {\tt cos} becomes {\tt std::cos}, |
| 119 | 201 | {\tt time\_t} becomes {\tt std::time\_t}, etc. |
| 120 | -One significant change is that {\tt fabs} becomes {\tt std::abs} since | |
| 202 | +One significant change between C and C++ is that {\tt fabs} becomes {\tt std::abs} since | |
| 121 | 203 | the C style {\tt abs} function only applies to integers. |
| 122 | 204 | Here, the {\tt std::} prefix is crucial to distinguish the C++ function (which is |
| 123 | 205 | also defined for doubles) from the C function. |
| 124 | 206 | |
| 125 | -Note also that some compilers are more tolerant in omitting {\tt \#include} directives, such | |
| 126 | -as {\tt <cstdio>} or {\tt <cstring>}, so these directives should also be included for compatibility, | |
| 127 | -even if they seem not to be required on specific systems. | |
| 128 | -Examples of include directives needed by common functions are: | |
| 207 | + | |
| 208 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 209 | +\subsubsection{Header file structure} | |
| 210 | +\label{sec:header} | |
| 211 | + | |
| 212 | +The header file defines the interface of the class. | |
| 213 | +Here is an example of a header file. | |
| 214 | +\begin{verbatim} | |
| 215 | +/*************************************************************************** | |
| 216 | + * GClass.hpp - My nice class * | |
| 217 | + * ----------------------------------------------------------------------- * | |
| 218 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 219 | + * ----------------------------------------------------------------------- * | |
| 220 | + * * | |
| 221 | + * This program is free software: you can redistribute it and/or modify * | |
| 222 | + * it under the terms of the GNU General Public License as published by * | |
| 223 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 224 | + * (at your option) any later version. * | |
| 225 | + * * | |
| 226 | + * This program is distributed in the hope that it will be useful, * | |
| 227 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 228 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 229 | + * GNU General Public License for more details. * | |
| 230 | + * * | |
| 231 | + * You should have received a copy of the GNU General Public License * | |
| 232 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 233 | + * * | |
| 234 | + ***************************************************************************/ | |
| 235 | +/** | |
| 236 | + * @file GClass.hpp | |
| 237 | + * @brief Definition of my nice class interface | |
| 238 | + * @author Juergen Knoedlseder | |
| 239 | + */ | |
| 240 | + | |
| 241 | +#ifndef GCLASS_HPP | |
| 242 | +#define GCLASS_HPP | |
| 243 | + | |
| 244 | +/* __ Includes ___________________________________________________________ */ | |
| 245 | +#include <string> | |
| 246 | +#include <iostream> | |
| 247 | +#include "GLog.hpp" | |
| 248 | + | |
| 249 | + | |
| 250 | +/***********************************************************************//** | |
| 251 | + * @class GClass | |
| 252 | + * | |
| 253 | + * @brief Illustration of a GammaLib class | |
| 254 | + * | |
| 255 | + * My nice class illustrates how a GammaLib class should be defined. | |
| 256 | + ***************************************************************************/ | |
| 257 | +class GClass { | |
| 258 | + | |
| 259 | + // I/O friends | |
| 260 | + friend std::ostream& operator<< (std::ostream& os, const GClass& c); | |
| 261 | + friend GLog& operator<< (GLog& log, const GClass& c); | |
| 262 | + | |
| 263 | +public: | |
| 264 | + // Constructors and destructors | |
| 265 | + GClass(void); | |
| 266 | + GClass(const GClass& c); | |
| 267 | + virtual ~GClass(void); | |
| 268 | + | |
| 269 | + // Operators | |
| 270 | + GClass& operator= (const GClass& c); | |
| 271 | + | |
| 272 | + // Methods | |
| 273 | + void clear(void); | |
| 274 | + GClass* clone(void) const; | |
| 275 | + std::string print(void) const; | |
| 276 | + | |
| 277 | +protected: | |
| 278 | + // Protected methods | |
| 279 | + void init_members(void); | |
| 280 | + void copy_members(const GClass& c); | |
| 281 | + void free_members(void); | |
| 282 | + | |
| 283 | + // Protected data members | |
| 284 | + std::string m_name; //!< Name | |
| 285 | +}; | |
| 286 | + | |
| 287 | +#endif /* GCLASS_HPP */ | |
| 288 | +\end{verbatim} | |
| 289 | + | |
| 290 | +The header file starts with a comment containing the file name and class purpose, the | |
| 291 | +copyright information and the license text. | |
| 292 | +The years in the copyright information should cover the years over which the file has been | |
| 293 | +modified, the author is the person who initially created the file. | |
| 294 | + | |
| 295 | +Following the header comment is a comment that provides file information to the | |
| 296 | +Doxygen documentation system. | |
| 297 | + | |
| 298 | +The subsequent | |
| 299 | +\begin{verbatim} | |
| 300 | + #ifndef GCLASS_HPP | |
| 301 | + #define GCLASS_HPP | |
| 302 | +\end{verbatim} | |
| 303 | +declarations together with the | |
| 304 | +\begin{verbatim} | |
| 305 | + #endif /* GCLASS_HPP */ | |
| 306 | +\end{verbatim} | |
| 307 | +declaration at the end protect the file from multiple inclusions of the header. | |
| 308 | +This is a crucial feature needed for proper compilation of the code. | |
| 309 | + | |
| 310 | +Now all header files are included. | |
| 311 | +Standard header files are included using the {\tt < >} brackets, \this\ header files are included | |
| 312 | +using {\tt " "}. | |
| 313 | +A 80 character long separator precedes the header inclusion. | |
| 314 | +Further 80 character long separators may be added for additional sections, such as | |
| 315 | +constants, type definitions, forward declarations, etc. | |
| 316 | +Use one separator to precede each additional section. | |
| 317 | + | |
| 318 | +The class definition is preceded by a comment block that will be used by the Doxygen system | |
| 319 | +to extract the class definition. | |
| 320 | +Provide here the class name, a brief one line description of the class, and an extended | |
| 321 | +detailed description of the class purpose. | |
| 322 | + | |
| 323 | +The class definition is structured in several sections: | |
| 324 | +\begin{itemize} | |
| 325 | +\item Declaration of friend functions | |
| 326 | +\item Definition of public constructors | |
| 327 | +\item Definition of public operators | |
| 328 | +\item Definition of public methods | |
| 329 | +\item Definition of protected methods | |
| 330 | +\item Definition of protected members | |
| 331 | +\end{itemize} | |
| 332 | +The definition of pure virtual methods should be done in a section that is separate from the | |
| 333 | +methods that are implemented. | |
| 334 | +Output stream and logging operators should be implemented for every class as friend | |
| 335 | +operators. | |
| 336 | + | |
| 337 | +Here any illustration of the expected structure, based on the {\tt GObservation} class: | |
| 338 | +\begin{verbatim} | |
| 339 | +class GObservation { | |
| 340 | + | |
| 341 | + // Friend classes | |
| 342 | + friend std::ostream& operator<< (std::ostream& os, const GObservation& obs); | |
| 343 | + friend GLog& operator<< (GLog& log, const GObservation& obs); | |
| 344 | + | |
| 345 | +public: | |
| 346 | + // Constructors and destructors | |
| 347 | + GObservation(void); | |
| 348 | + GObservation(const GObservation& obs); | |
| 349 | + virtual ~GObservation(void); | |
| 350 | + | |
| 351 | + // Operators | |
| 352 | + virtual GObservation& operator= (const GObservation& obs); | |
| 353 | + | |
| 354 | + // Pure virtual methods | |
| 355 | + virtual void clear(void) = 0; | |
| 356 | + virtual GObservation* clone(void) const = 0; | |
| 357 | + | |
| 358 | + // Virtual methods | |
| 359 | + virtual double model(const GModels& models, const GEvent& event, | |
| 360 | + GVector* gradient = NULL) const; | |
| 361 | + virtual double npred(const GModels& models, GVector* gradient = NULL) const; | |
| 362 | + | |
| 363 | + // Implemented methods | |
| 364 | + void name(const std::string& name); | |
| 365 | + void id(const std::string& id); | |
| 366 | + | |
| 367 | +protected: | |
| 368 | + // Protected methods | |
| 369 | + void init_members(void); | |
| 370 | + void copy_members(const GObservation& obs); | |
| 371 | + void free_members(void); | |
| 372 | + | |
| 373 | + // Protected data area | |
| 374 | + std::string m_name; //!< Name of observation | |
| 375 | + std::string m_id; //!< Observation identifier | |
| 376 | + std::string m_statistics; //!< Optimizer statistics (default=poisson) | |
| 377 | + GEvents* m_events; //!< Pointer to event container | |
| 378 | +}; | |
| 379 | +\end{verbatim} | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 384 | +\subsubsection{Source code file structure} | |
| 385 | +\label{sec:sourcecode} | |
| 386 | + | |
| 387 | +The source code file implements the code of the class. | |
| 388 | +Here is an example of the start of a source code file. | |
| 389 | +\begin{verbatim} | |
| 390 | +/*************************************************************************** | |
| 391 | + * GClass.cpp - My nice class * | |
| 392 | + * ----------------------------------------------------------------------- * | |
| 393 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 394 | + * ----------------------------------------------------------------------- * | |
| 395 | + * * | |
| 396 | + * This program is free software: you can redistribute it and/or modify * | |
| 397 | + * it under the terms of the GNU General Public License as published by * | |
| 398 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 399 | + * (at your option) any later version. * | |
| 400 | + * * | |
| 401 | + * This program is distributed in the hope that it will be useful, * | |
| 402 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 403 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 404 | + * GNU General Public License for more details. * | |
| 405 | + * * | |
| 406 | + * You should have received a copy of the GNU General Public License * | |
| 407 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 408 | + * * | |
| 409 | + ***************************************************************************/ | |
| 410 | +/** | |
| 411 | + * @file GClass.cpp | |
| 412 | + * @brief Implementation of my nice class | |
| 413 | + * @author Juergen Knoedlseder | |
| 414 | + */ | |
| 415 | + | |
| 416 | +/* __ Includes ___________________________________________________________ */ | |
| 417 | +#ifdef HAVE_CONFIG_H | |
| 418 | +#include <config.h> | |
| 419 | +#endif | |
| 420 | +#include "GClass.hpp" | |
| 421 | +#include "GTools.hpp" | |
| 422 | + | |
| 423 | +/* __ Method name definitions ____________________________________________ */ | |
| 424 | +#define G_CLEAR "GClass::clear()" | |
| 425 | +#define G_CLONE "GClass::clone() const" | |
| 426 | +#define G_PRINT "GClass::print() const" | |
| 427 | + | |
| 428 | +/* __ Compile options ____________________________________________________ */ | |
| 429 | +#define G_USE_MY_OPTION | |
| 430 | + | |
| 431 | +/* __ Debug options ______________________________________________________ */ | |
| 432 | +#define G_DEBUG_PRINT | |
| 433 | + | |
| 434 | +/* __ Constants __________________________________________________________ */ | |
| 435 | +const double pi = 3.14; | |
| 436 | +\end{verbatim} | |
| 437 | + | |
| 438 | +The include section starts with a conditional include of the code configuration header file | |
| 439 | +(see section \ref{sec:configure}). | |
| 440 | +This makes \this\ compile options available to the source code. | |
| 441 | + | |
| 442 | +The include section is followed by the declaration of method names. | |
| 443 | +These method names will be used in exceptions (see section \ref{sec:exceptions}). | |
| 444 | +Define the method names at the top of the file eases the maintainability of the code, | |
| 445 | +as changes in method names or interfaces need only to be implemented in a single | |
| 446 | +place. | |
| 447 | +Method names need only be defined for methods throwing exceptions. | |
| 448 | + | |
| 449 | +Compile options are used to control which parts of the code should be compiled. | |
| 450 | +Such options may be used, for example, to compare different algorithms or computation | |
| 451 | +methods. | |
| 452 | +They can also be used during development, allowing an easy switch between the new and | |
| 453 | +the old code for comparison. | |
| 454 | + | |
| 455 | +Debug options are compile options that are used to add additional code for debugging. | |
| 456 | +Often, these are print statements that allow to trace the execution of the code. | |
| 457 | +For code checked into the repository, all debug options should be commented out. | |
| 458 | + | |
| 459 | + | |
| 460 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 461 | +\subsection{Python classes} | |
| 462 | +\label{sec:pyhton} | |
| 463 | + | |
| 464 | +The Python interface for C++ classes is defined by a so-called SWIG interface file. | |
| 465 | +SWIG uses these interface files to build Python wrapper files, which are C files | |
| 466 | +that define the interface between \this\ and Python. | |
| 467 | +The structure of the SWIG interface file follows closely that of the header file, with | |
| 468 | +a few exceptions. | |
| 469 | +Here an example: | |
| 470 | +\begin{verbatim} | |
| 471 | +/*************************************************************************** | |
| 472 | + * GClass.i - My nice class * | |
| 473 | + * ----------------------------------------------------------------------- * | |
| 474 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 475 | + * ----------------------------------------------------------------------- * | |
| 476 | + * * | |
| 477 | + * This program is free software: you can redistribute it and/or modify * | |
| 478 | + * it under the terms of the GNU General Public License as published by * | |
| 479 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 480 | + * (at your option) any later version. * | |
| 481 | + * * | |
| 482 | + * This program is distributed in the hope that it will be useful, * | |
| 483 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 484 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 485 | + * GNU General Public License for more details. * | |
| 486 | + * * | |
| 487 | + * You should have received a copy of the GNU General Public License * | |
| 488 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 489 | + * * | |
| 490 | + ***************************************************************************/ | |
| 491 | +/** | |
| 492 | + * @file GClass.i | |
| 493 | + * @brief Python interface of my nice class | |
| 494 | + * @author Juergen Knoedlseder | |
| 495 | + */ | |
| 496 | +%{ | |
| 497 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 498 | +#include "GClass.hpp" | |
| 499 | +#include "GTools.hpp" | |
| 500 | +%} | |
| 501 | + | |
| 502 | + | |
| 503 | +/***********************************************************************//** | |
| 504 | + * @class GClass | |
| 505 | + * | |
| 506 | + * @brief Illustration of a GammaLib class | |
| 507 | + * | |
| 508 | + * My nice class illustrates how a GammaLib class should be defined. | |
| 509 | + ***************************************************************************/ | |
| 510 | +class GClass { | |
| 511 | +public: | |
| 512 | + // Constructors and destructors | |
| 513 | + GClass(void); | |
| 514 | + GClass(const GClass& c); | |
| 515 | + virtual ~GClass(void); | |
| 516 | + | |
| 517 | + // Methods | |
| 518 | + void clear(void); | |
| 519 | + GClass* clone(void) const; | |
| 520 | +}; | |
| 521 | + | |
| 522 | + | |
| 523 | +/***********************************************************************//** | |
| 524 | + * @brief GClass class extension | |
| 525 | + ***************************************************************************/ | |
| 526 | +%extend GClass { | |
| 527 | + char *__str__() { | |
| 528 | + return tochar(self->print()); | |
| 529 | + } | |
| 530 | + GClass copy() { | |
| 531 | + return (*self); | |
| 532 | + } | |
| 533 | +}; | |
| 534 | +\end{verbatim} | |
| 535 | + | |
| 536 | +The code starts with a section that is enclosed in {\tt \%\{ \%\}} brackets. | |
| 537 | +In this section, all header files are specified that are needed to compile the SWIG wrapper | |
| 538 | +file. | |
| 539 | + | |
| 540 | +Then follows the class definition, with the following differences with respect to the | |
| 541 | +definition in the header file: | |
| 129 | 542 | \begin{itemize} |
| 130 | -\item[] {\tt <cstdio>} contains {\tt std::fopen}, {\tt std::fgets}, {\tt std::fclose}, {\tt std::fprintf}, {\tt std::sprintf} | |
| 131 | -\item[] {\tt <cstring>} contains {\tt std::strncpy}, {\tt std::memcpy} | |
| 543 | +\item it does not include the assignment operator | |
| 544 | +\item it does not include any access operator (these have to be implemented specifically, see below) | |
| 545 | +\item it does not include the {\tt print()} method (see below) | |
| 546 | +\item it does not include protected or private members | |
| 132 | 547 | \end{itemize} |
| 133 | 548 | |
| 134 | -If possible, however, {\tt std::strncpy} and {\tt std::memcpy} should be avoided at all as these | |
| 135 | -functions happend to have some compatibility problems in the past. | |
| 549 | +Finally, there is a section with extension to the C++ class. | |
| 550 | +Here, methods are implement that do not exist in the actual C++ class, but that will | |
| 551 | +exist in the Python interface. | |
| 552 | +In this example, the {\tt\_\_str\_\_()} method is the generic Python conversion operator that | |
| 553 | +converts an object into a string. | |
| 554 | +It can be seen that this method calls the class's @print()@ method. | |
| 555 | +By providing the conversion method, the class becomes "printable", and one | |
| 556 | +my specify | |
| 557 | +\begin{verbatim} | |
| 558 | +>>> GClass c | |
| 559 | +>>> print c | |
| 560 | +\end{verbatim} | |
| 561 | +to print out the class (i.e. to invoke the print() method of the class). | |
| 562 | + | |
| 563 | +In case that an access operator needs to be implement, the {\tt\_\_getitem\_\_()} and {\tt\_\_setitem\_\_()} | |
| 564 | +methods need to be added to the class extensions. | |
| 136 | 565 | |
| 137 | 566 | |
| 567 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 568 | +% Design conventions | |
| 569 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 570 | +\section{Design conventions} | |
| 571 | + | |
| 572 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 573 | +\subsection{Code configuration} | |
| 574 | +\label{sec:configure} | |
| 575 | + | |
| 576 | +The code configuration is controlled via the {\tt config.h} header file that is created during the | |
| 577 | +configuration step of \this. | |
| 578 | +To make configuration options available the following code has to be added to the | |
| 579 | +source code file: | |
| 580 | +\begin{verbatim} | |
| 581 | +/* __ Includes ___________________________________________________________ */ | |
| 582 | +#ifdef HAVE_CONFIG_H | |
| 583 | +#include <config.h> | |
| 584 | +#endif | |
| 585 | +\end{verbatim} | |
| 586 | +Note that the {\tt config.h} file should {\bf not be included in header files}, since header files | |
| 587 | +are used by the outside world without any knowledge about {\tt config.h}. | |
| 588 | + | |
| 589 | +One of the most commonly used configuration options used throughout \this\ is related to | |
| 590 | +range checking. | |
| 591 | +Range checks are usually performed when accessing array elements, assuring that no | |
| 592 | +elements outside the valid range are accessed. | |
| 593 | +Range checking, however, is time consuming, in particular if many elements are | |
| 594 | +accessed subsequently. | |
| 595 | +\this\ therefore allows to disable range checks. | |
| 596 | +This can be done by specifying {\tt ./configure --disable-range-check} when configuring | |
| 597 | +\this\ for compilation. | |
| 598 | +The {\tt --disable-range-check} option undefines {\tt G\_RANGE\_CHECK}, and optional | |
| 599 | +range checking is thus achieved by adding for example | |
| 600 | +\begin{verbatim} | |
| 601 | +#if defined(G_RANGE_CHECK) | |
| 602 | +if (inx < 0 || inx >= m_num) { | |
| 603 | + throw GException::out_of_range("GVector::operator(int)", inx, m_num); | |
| 604 | +} | |
| 605 | +#endif | |
| 606 | +\end{verbatim} | |
| 607 | +to the code. | |
| 608 | + | |
| 609 | +The following table gives a list of important configuration options that are available in | |
| 610 | +{\tt config.h} and that can be used to tune the code: | |
| 611 | + | |
| 612 | +%%% Configuration options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 613 | +\begin{center} | |
| 614 | +\begin{tabular}{lll} | |
| 615 | +\hline | |
| 616 | +\hline | |
| 617 | +\noalign{\smallskip} | |
| 618 | +Definition & Option & Usage \\ | |
| 619 | +\noalign{\smallskip} | |
| 620 | +\hline | |
| 621 | +\noalign{\smallskip} | |
| 622 | +{\tt G\_DEBUG} & {\tt --enable-debug} & Code debugging \\ | |
| 623 | +{\tt G\_PROFILE} & {\tt --enable-profiling} & Code profiling \\ | |
| 624 | +{\tt G\_RANGE\_CHECK} & {\tt --enable-range-check} & Performs range checking \\ | |
| 625 | +{\tt G\_NAN\_CHECK} & {\tt --enable-nan-check} & Check for NaN and Inf values \\ | |
| 626 | +{\tt G\_SMALL\_MEMORY} & {\tt --enable-small-memory} & Optimizes for small memory \\ | |
| 627 | +{\tt HAVE\_OPENMP} &{\tt --enable-openmp} & Has OpenMP multi-threading support \\ | |
| 628 | +{\tt HAVE\_LIBREADLINE} & {\tt --with-readline} & Has readline library \\ | |
| 629 | +{\tt HAVE\_LIBCFITSIO} & {\tt --with-cfitsio} & Has cfitsio library \\ | |
| 630 | +{\tt HAVE\_PYTHON} & {\tt --enable-python-binding} & Has Python bindings \\ | |
| 631 | +{\tt PACKAGE} & n.a. & {\tt gammalib} \\ | |
| 632 | +{\tt PACKAGE\_PREFIX} & n.a. & Installation location (e.g. {\tt /usr/local/gamma}) \\ | |
| 633 | +{\tt PACKAGE\_STRING} & n.a. & Full name and version of \this\ \\ | |
| 634 | +{\tt PACKAGE\_VERSION} & n.a. & Version of \this\ (format: x.y.z) \\ | |
| 635 | +\noalign{\smallskip} | |
| 636 | +\hline | |
| 637 | +\end{tabular} | |
| 638 | +\end{center} | |
| 639 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 640 | + | |
| 641 | +Note that {\tt enable} may be replaced by {\tt disable} and {\tt with} by {\tt without} for switching off | |
| 642 | +an option. | |
| 643 | + | |
| 138 | 644 | |
| 139 | 645 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 140 | 646 | \subsection{C++ classes} |
| ... | ... | @@ -149,10 +655,10 @@ Members should be prefixed by {\tt m\_} and should be in lower case. |
| 149 | 655 | For long member names, additional underscores may be added. |
| 150 | 656 | Examples of valid member names are |
| 151 | 657 | \begin{verbatim} |
| 152 | - m_num | |
| 153 | - m_response | |
| 154 | - m_grid_length | |
| 155 | - m_axis_dir_qual | |
| 658 | +m_num | |
| 659 | +m_response | |
| 660 | +m_grid_length | |
| 661 | +m_axis_dir_qual | |
| 156 | 662 | \end{verbatim} |
| 157 | 663 | |
| 158 | 664 | Initialisation, copying and deleting of class members should be gathered in a single |
| ... | ... | @@ -164,8 +670,8 @@ methods for memory management: |
| 164 | 670 | initial values. The class should be fully operational and consistent with these initial |
| 165 | 671 | values. All pointers that will hold dynamically allocated memory should be |
| 166 | 672 | initialised to {\tt NULL}. |
| 167 | -\item {\tt copy\_members(const \&A a)} copies all members from one instance {\tt a} | |
| 168 | -to the {\tt this} instance. | |
| 673 | +\item {\tt copy\_members(const \&A a)} copies all members from an instance {\tt a} | |
| 674 | +into the class. | |
| 169 | 675 | \item {\tt free\_members()} frees all memory that has been allocated by the class. |
| 170 | 676 | Memory pointers should be set to {\tt NULL} after the memory was deleted to signal |
| 171 | 677 | that no valid memory is associated to the pointer. |
| ... | ... | @@ -207,6 +713,30 @@ void GEbounds::free_members(void) |
| 207 | 713 | return; |
| 208 | 714 | } |
| 209 | 715 | \end{verbatim} |
| 716 | +In this example, on may probably want to add a {\tt alloc\_members()} method for memory allocation: | |
| 717 | +\begin{verbatim} | |
| 718 | +void GEbounds::alloc_members(const int& num) | |
| 719 | +{ | |
| 720 | + if (num > 0) { | |
| 721 | + m_min = new GEnergy[num]; | |
| 722 | + m_max = new GEnergy[num]; | |
| 723 | + for (int i = 0; i < num; ++i) { | |
| 724 | + m_min[i] = 0.0; | |
| 725 | + m_max[i] = 0.0; | |
| 726 | + } | |
| 727 | + m_num = num; | |
| 728 | + } | |
| 729 | + return; | |
| 730 | +} | |
| 731 | +\end{verbatim} | |
| 732 | +This example illustrates several design conventions: | |
| 733 | +\begin{itemize} | |
| 734 | +\item Always check if a pointer is not {\tt NULL} before de-allocating memory. | |
| 735 | +\item After de-allocation, always set the pointer immediately to {\tt NULL}. | |
| 736 | +\item Never allocate zero elements (check if the number of elements to be allocated is positive). | |
| 737 | +\item Always initialise allocated memory to well defined values (do not expect that the compiler | |
| 738 | +will do this for your). | |
| 739 | +\end{itemize} | |
| 210 | 740 | |
| 211 | 741 | |
| 212 | 742 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -248,19 +778,79 @@ GEbounds& GEbounds::operator= (const GEbounds& ebds) |
| 248 | 778 | return *this; |
| 249 | 779 | } |
| 250 | 780 | \end{verbatim} |
| 251 | -Note that for a derived class, the assignment operator will have the form: | |
| 781 | + | |
| 782 | + | |
| 783 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 784 | +\subsubsection{Inheritance} | |
| 785 | + | |
| 786 | +Class inheritance is central feature of the C++ language, and is largely used throughout \this. | |
| 787 | +Multiple inheritance is not used at the moment in \this. | |
| 788 | +Because of the added complexity of multiple inheritance in C++ in python there would have to | |
| 789 | +be very good reasons to use it in \this. | |
| 790 | + | |
| 791 | +Although the inheritance philosophy may differ from class to class, the following guidelines | |
| 792 | +should be respected as far as possible: | |
| 793 | +\begin{itemize} | |
| 794 | +\item The base class and derived class destructors should be declared {\tt virtual}. | |
| 795 | +\item Avoid overloading of base class methods by derived class methods. | |
| 796 | +Preferentially, define base class methods as pure virtual. | |
| 797 | +\item All base class methods that should be implemented in the derived class should | |
| 798 | +be declared {\tt virtual}. | |
| 799 | +Exceptions are the {\tt init\_members()}, the {\tt copy\_members()} and the {\tt free\_members()} | |
| 800 | +methods that will be implemented in the base class and the derived class. | |
| 801 | +\item Base classes manage base class members, derived classes manage derived class | |
| 802 | +members. | |
| 803 | +By managing we mean here in particular memory allocation and de-allocation, | |
| 804 | +but also proper initialization. | |
| 805 | +\item Derived class constructors should invoke base class constructors for proper | |
| 806 | +base class initialization. A void constructor should look like | |
| 807 | +\begin{verbatim} | |
| 808 | +GEventList::GEventList(void) : GEvents() | |
| 809 | +{ | |
| 810 | + init_members(); | |
| 811 | + return; | |
| 812 | +} | |
| 813 | +\end{verbatim} | |
| 814 | +and a copy constructor should look like | |
| 252 | 815 | \begin{verbatim} |
| 253 | -GEventCube& GEventCube::operator= (const GEventCube& cube) | |
| 816 | +GEventList::GEventList(const GEventList& list) : GEvents(list) | |
| 254 | 817 | { |
| 255 | - if (this != &cube) { | |
| 256 | - this->GEvents::operator=(cube); // Copy base class members | |
| 818 | + init_members(); | |
| 819 | + copy_members(list); | |
| 820 | + return; | |
| 821 | +} | |
| 822 | +\end{verbatim} | |
| 823 | +\item Derived class operators should invoke base class operators, as illustrated | |
| 824 | +by the following example: | |
| 825 | +\begin{verbatim} | |
| 826 | +GEventList& GEventList::operator=(const GEventList& list) | |
| 827 | +{ | |
| 828 | + if (this != &list) { | |
| 829 | + this->GEvents::operator=(list); | |
| 257 | 830 | free_members(); |
| 258 | 831 | init_members(); |
| 259 | - copy_members(cube); | |
| 832 | + copy_members(list); | |
| 260 | 833 | } |
| 261 | 834 | return *this; |
| 262 | 835 | } |
| 263 | 836 | \end{verbatim} |
| 837 | +\item The {\tt clear()} method of a derived class show invoke the {\tt free\_members()} method | |
| 838 | +of the base class, as illustrated by the following example: | |
| 839 | +\begin{verbatim} | |
| 840 | +void GCTAEventList::clear(void) | |
| 841 | +{ | |
| 842 | + free_members(); | |
| 843 | + this->GEventList::free_members(); | |
| 844 | + this->GEvents::free_members(); | |
| 845 | + this->GEvents::init_members(); | |
| 846 | + this->GEventList::init_members(); | |
| 847 | + init_members(); | |
| 848 | + return; | |
| 849 | +} | |
| 850 | +\end{verbatim} | |
| 851 | +\item Avoid as far as possible methods that are only defined in the derived class. | |
| 852 | +\end{itemize} | |
| 853 | + | |
| 264 | 854 | Also note that {\bf for a derived class, {\tt init\_members()}, {\tt copy\_members(const \&A a)} |
| 265 | 855 | and {\tt free\_members()} should only act on derived class members but not on |
| 266 | 856 | base class members}. |
| ... | ... | @@ -269,35 +859,35 @@ the source of memory leaks. |
| 269 | 859 | |
| 270 | 860 | |
| 271 | 861 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 272 | -\subsubsection{Inheritence} | |
| 273 | - | |
| 274 | -Class inheritence is heavily used in \this\ to implement instrument specific functionnalities | |
| 275 | -that satisfy a generic interface. | |
| 276 | - | |
| 277 | -Derived classes should never set explicitely base class members. | |
| 278 | -Base class members should be set by proper constructors, and base class constructors are | |
| 279 | -to to be invoked in derived class constructors. | |
| 280 | - | |
| 281 | - | |
| 282 | - | |
| 283 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 284 | -\subsubsection{Methods} | |
| 862 | +\subsubsection{Method naming conventions} | |
| 285 | 863 | |
| 286 | 864 | Uniform {\tt public} method names should be provided throughout \this\ for all classes. |
| 287 | 865 | Unless the {\tt public} method names are very long (which should be avoided), names |
| 288 | 866 | should not comprise underscores as separators. |
| 289 | 867 | {\tt Public} method names are all lowercase. |
| 290 | 868 | |
| 291 | -{\tt Private} or {\tt protected} may differ from this since they are hidden within the class. | |
| 869 | +{\tt Private} or {\tt protected} method name may differ from this since they are hidden within | |
| 870 | +the class. | |
| 292 | 871 | Yet also here, all method names should be lowercase, and the use of underscores |
| 293 | 872 | should be limited. |
| 294 | - | |
| 295 | -In addition, the following {\tt public} method names should be used: | |
| 873 | + | |
| 874 | +Methods that set or retrieve class attributes should be named after the attribute. | |
| 875 | +Here an example for the attribute {\tt m\_name}: | |
| 876 | +\begin{verbatim} | |
| 877 | +public: | |
| 878 | + void name(const std::string& name); | |
| 879 | + std::string name(void) const; | |
| 880 | +protected: | |
| 881 | + m_name; | |
| 882 | +\end{verbatim} | |
| 883 | + | |
| 884 | +A method name that is used in multiple classes should always perform an equivalent action. | |
| 885 | +Here is a list of method names that are widely used in \this, together with their typical usage. | |
| 886 | +The last column specifies where these methods are used. | |
| 887 | +Note that {\bf the {\tt clear()}, {\tt clone()}, and {\tt print()} methods should be implemented for all | |
| 888 | +classes}. | |
| 296 | 889 | |
| 297 | 890 | %%% Naming conventions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 298 | -\begin{table}[!h] | |
| 299 | -\caption{Naming conventions for class methods. | |
| 300 | -\label{tab:naming}} | |
| 301 | 891 | \begin{center} |
| 302 | 892 | \begin{tabular}{lll} |
| 303 | 893 | \hline |
| ... | ... | @@ -308,19 +898,34 @@ Method & Usage & Implementation \\ |
| 308 | 898 | \hline |
| 309 | 899 | \noalign{\smallskip} |
| 310 | 900 | {\tt clear()} & Set object to initial empty state & all classes \\ |
| 901 | +{\tt clone()} & Provides a deep copy of the class & all classes \\ | |
| 311 | 902 | {\tt print()} & Print object into string & all classes (see section \ref{sec:output}) \\ |
| 312 | -{\tt append()} & Append element to list of elements & container classes \\ | |
| 313 | -{\tt size()} & Return number of elements in object & container classes \\ | |
| 903 | +\noalign{\smallskip} | |
| 904 | +\hline | |
| 905 | +\noalign{\smallskip} | |
| 906 | +{\tt append()} & Append element to list of elements & container classes (see section \ref{sec:containers}) \\ | |
| 907 | +{\tt extend()} & Append container elements to list of elements & container classes (see section \ref{sec:containers}) \\ | |
| 908 | +{\tt insert()} & Insert element to list of elements & container classes (see section \ref{sec:containers}) \\ | |
| 909 | +{\tt pop()} & Remove element from list of elements & container classes (see section \ref{sec:containers}) \\ | |
| 910 | +\noalign{\smallskip} | |
| 911 | +\hline | |
| 912 | +\noalign{\smallskip} | |
| 314 | 913 | {\tt load()} & Load data from file (open, read, close) & if applicable \\ |
| 315 | 914 | {\tt save()} & Save data into file (open, write, close) & if applicable \\ |
| 915 | +{\tt open()} & Open file & if applicable \\ | |
| 316 | 916 | {\tt read()} & Read data from open file & if applicable \\ |
| 317 | 917 | {\tt write()} & Write data into open file & if applicable \\ |
| 918 | +{\tt close()} & Close file & if applicable \\ | |
| 318 | 919 | {\tt name()} & Name of object & if applicable \\ |
| 920 | +{\tt type()} & Type of object & if applicable \\ | |
| 921 | +{\tt size()} & Size of object & if applicable \\ | |
| 922 | +{\tt real()} & Returns {\tt double} precision value & if applicable \\ | |
| 923 | +{\tt integer()} & Returns {\tt int} value & if applicable \\ | |
| 924 | +{\tt string()} & Returns {\tt std::string} value & if applicable \\ | |
| 319 | 925 | \noalign{\smallskip} |
| 320 | 926 | \hline |
| 321 | 927 | \end{tabular} |
| 322 | 928 | \end{center} |
| 323 | -\end{table} | |
| 324 | 929 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 325 | 930 | |
| 326 | 931 | Note the difference between {\tt load()} and {\tt read()} and between {\tt save()} and {\tt write()}. |
| ... | ... | @@ -332,77 +937,224 @@ Typically, these methods take a {\tt GFits*} or a {\tt GFitsHDU*} pointer as arg |
| 332 | 937 | |
| 333 | 938 | Methods that perform checks should return a {\tt bool} type and should start with the |
| 334 | 939 | prefix {\tt is} or {\tt has}. |
| 335 | - | |
| 336 | -Valid examples are: | |
| 940 | +Examples are: | |
| 337 | 941 | \begin{verbatim} |
| 338 | - islong() | |
| 339 | - isin() | |
| 340 | - hasedisp() | |
| 942 | +islong() | |
| 943 | +isin() | |
| 944 | +hasedisp() | |
| 341 | 945 | \end{verbatim} |
| 342 | 946 | |
| 343 | -Method arguments should be generally passed as {\tt const} and by reference. | |
| 344 | 947 | |
| 345 | -Numeric argument types should be typically {\tt int} and {\tt double}. | |
| 346 | -Unless absolutely required, {\tt short int}, {\tt long}, and {\tt float} should be avoided. | |
| 347 | -True/false checks should always be done using {\tt bool}. | |
| 948 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 949 | +\subsubsection{Method const declarations} | |
| 950 | + | |
| 951 | +All methods that do not alter accessible class members should be declared {\tt const}. | |
| 952 | +With accessible we mean here class members that can be read or written in some | |
| 953 | +way by one of the methods. | |
| 954 | +Non-accessible class members would be members that are only used internally, and | |
| 955 | +for which no consistent state has to be preserved for the outside world. | |
| 956 | +These could for example be members that hold pre-computed values. | |
| 957 | + | |
| 958 | +Methods that do not alter accessible members, but that modify non-accessible | |
| 959 | +members, should also be declared {\tt const}. | |
| 960 | +The non-accessible class members need then to be declared {\tt mutable} to avoid | |
| 961 | +compiler errors. | |
| 962 | +Alternatively, the {\tt const\_cast} declaration can be used to allow member modifications | |
| 963 | +within a {\tt const} method. | |
| 964 | + | |
| 965 | +As example we show here part of the definition of {\tt GModelSpectralPlaw2}: | |
| 966 | +\begin{verbatim} | |
| 967 | +class GModelSpectralPlaw2 : public GModelSpectral { | |
| 968 | +public: | |
| 969 | + virtual double eval(const GEnergy& srcEng) const; | |
| 970 | + virtual void read(const GXmlElement& xml); | |
| 971 | +protected: | |
| 972 | + // Protected members | |
| 973 | + GModelPar m_integral; //!< Integral flux | |
| 974 | + GModelPar m_index; //!< Spectral index | |
| 975 | + GModelPar m_emin; //!< Lower energy limit (MeV) | |
| 976 | + GModelPar m_emax; //!< Upper energy limit (MeV) | |
| 977 | + | |
| 978 | + // Cached members used for pre-computations | |
| 979 | + mutable double m_log_emin; //!< Log(emin) | |
| 980 | + mutable double m_log_emax; //!< Log(emax) | |
| 981 | + mutable double m_pow_emin; //!< emin^(index+1) | |
| 982 | + mutable double m_pow_emax; //!< emax^(index+1) | |
| 983 | + mutable double m_norm; //!< Power-law normalization (for pivot energy 1 MeV) | |
| 984 | + mutable double m_g_norm; //!< Power-law normalization gradient | |
| 985 | + mutable double m_power; //!< Power-law factor | |
| 986 | + mutable double m_last_integral; //!< Last integral flux | |
| 987 | + mutable double m_last_index; //!< Last spectral index (MeV) | |
| 988 | + mutable double m_last_emin; //!< Last lower energy limit (MeV) | |
| 989 | + mutable double m_last_emax; //!< Last upper energy limit (MeV) | |
| 990 | + mutable GEnergy m_last_energy; //!< Last source energy | |
| 991 | + mutable double m_last_value; //!< Last function value | |
| 992 | + mutable double m_last_g_integral; //!< Last integral flux gradient | |
| 993 | + mutable double m_last_g_index; //!< Last spectral index gradient | |
| 994 | +\end{verbatim} | |
| 995 | +This class has an internal cache for precomputation, which is potentially updated when | |
| 996 | +{\tt eval} is called. | |
| 997 | +Here the corresponding code: | |
| 998 | +\begin{verbatim} | |
| 999 | +double GModelSpectralPlaw2::eval(const GEnergy& srcEng) const | |
| 1000 | +{ | |
| 1001 | + // Update precomputed values | |
| 1002 | + update(srcEng); | |
| 348 | 1003 | |
| 349 | -Methods should be declared as {\tt const} if they do not alter class members. | |
| 350 | -In some classes, pre-computations are done to speed up calculations, and these | |
| 351 | -pre-computations will alter class members. | |
| 352 | -If these pre-computation are not supposed to alter the content of a class, | |
| 353 | -methods that perform pre-computations should also be declared as {\tt const}. | |
| 354 | -Internally, they have to circumvent const correctness by casting the pointer to | |
| 355 | -non {\tt const} or by using the {\tt mutable} attribute in the declaration of the members | |
| 356 | -that hold the pre-computed values (the latter option is preferred). | |
| 1004 | + // Compute function value | |
| 1005 | + double value = integral() * m_norm * m_power; | |
| 1006 | + | |
| 1007 | + // Return | |
| 1008 | + return value; | |
| 1009 | +} | |
| 1010 | +\end{verbatim} | |
| 1011 | +As the pre-computation cache is not exposed to the external world but fully handled within | |
| 1012 | +the class, {\tt eval()} is declared {\tt const} as it does not modify any of the model parameters | |
| 1013 | +(which are {\tt m\_integral}, {\tt m\_index}, {\tt m\_emin}, and {\tt m\_emax}). | |
| 1014 | +It may however modified some of the cache members, that's why these members are | |
| 1015 | +declared {\tt mutable}. | |
| 1016 | +As there is however no way to access these cache values from the outside (no method exists | |
| 1017 | +to access them), the {\tt eval()} method does not modify any {\em observable} property of the class, | |
| 1018 | +hence it is declared {\tt const}. | |
| 357 | 1019 | |
| 358 | 1020 | |
| 359 | 1021 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 360 | 1022 | \subsubsection{Method arguments and return values} |
| 361 | 1023 | |
| 362 | -Arguments to methods should in general be passed by reference to reduce function | |
| 363 | -overhead. | |
| 364 | -In addition, arguments that are not intended to be changed by a method call should | |
| 365 | -be passed as {\tt const}. | |
| 366 | -Return values should also be passed by reference. | |
| 367 | -To assure that the return values will not change class members inadvertably, return | |
| 368 | -values passed by reference should also be declared as {\tt const}. | |
| 369 | - | |
| 370 | -If the class member is a pointer, the argument should also be a pointer to allow | |
| 371 | -setting the pointer to {\tt NULL}. | |
| 372 | -The exception to this are container classes which in general do not contain | |
| 373 | -{\tt NULL} pointers in the container. | |
| 374 | - | |
| 375 | -Return values should be passed by reference if they concern class members. | |
| 376 | - | |
| 377 | -If the class member is a pointer, and if the pointer may be {\tt NULL}, it should be | |
| 378 | -returned as a pointer. | |
| 379 | -Again, the pointer should be declared {\tt const} to avoid inadvertable changes of | |
| 380 | -the class members. | |
| 381 | -The exception to this are container classes which in general do not contain | |
| 382 | -{\tt NULL} pointers in the container. | |
| 383 | -Container classes should return references to container elements. | |
| 384 | - | |
| 385 | -An example is given by the following excerpt of the {\tt GObservation} class. | |
| 386 | -Note that in general there are two distinct methods to set and to return a | |
| 387 | -class member. | |
| 1024 | +%True/false checks should always be done using {\tt bool}. | |
| 1025 | + | |
| 1026 | +If possible, method arguments should always be passed by reference. | |
| 1027 | +To protect references from changes by the method, {\bf arguments passed by reference | |
| 1028 | +should always be declared {\tt const}}. | |
| 1029 | +Pointers should only be used as arguments if {\tt NULL} should be a possible | |
| 1030 | +argument value. | |
| 1031 | +Also pointers should always be declared {\tt const}. | |
| 1032 | +Here an example based on the definition of {\tt GObservation}: | |
| 388 | 1033 | \begin{verbatim} |
| 389 | - void obsname(const std::string& obsname); | |
| 390 | - void ebounds(const GEbounds& ebounds); | |
| 391 | - void gti(const GGti& gti); | |
| 392 | - void roi(const GRoi* roi); | |
| 393 | - void events(const GEvents* events); | |
| 394 | - void statistics(const std::string& statistics); | |
| 395 | - const std::string& obsname(void) const; | |
| 396 | - GTime tstart(void) const { return m_gti.tstart(); } // no class member | |
| 397 | - GTime tstop(void) const { return m_gti.tstop(); } // no class member | |
| 398 | - GEnergy emin(void) const { return m_ebounds.emin(); } // no class member | |
| 399 | - GEnergy emax(void) const { return m_ebounds.emax(); } // no class member | |
| 400 | - const GEbounds& ebounds(void) const; | |
| 401 | - const GGti& gti(void) const; | |
| 402 | - const GRoi* roi(void) const; | |
| 403 | - const GEvents* events(void) const; | |
| 404 | - const std::string& statistics(void) const; | |
| 1034 | +class GObservation { | |
| 1035 | +public: | |
| 1036 | + void events(const GEvents* events); | |
| 1037 | + void statistics(const std::string& statistics); | |
| 1038 | +protected: | |
| 1039 | + std::string m_statistics; //!< Optimizer statistics (default=poisson) | |
| 1040 | + GEvents* m_events; //!< Pointer to event container | |
| 1041 | +}; | |
| 405 | 1042 | \end{verbatim} |
| 1043 | +The {\tt statictics} value is passed by reference because the class will hold the actual | |
| 1044 | +value, while {\tt events} is passed as a pointer because the class will hold the | |
| 1045 | +pointer. | |
| 1046 | + | |
| 1047 | +Numeric argument types should be either {\tt int} or {\tt double}. | |
| 1048 | +Unless absolutely necessary, avoid {\tt short int}, {\tt long}, and {\tt float}. | |
| 1049 | + | |
| 1050 | +If a method returns a class member, the return value should be passed by reference. | |
| 1051 | +Unless we explicitly want to modify a class member through the method call, | |
| 1052 | +return values passed by reference should be declared {\tt const}. | |
| 1053 | + | |
| 1054 | +If a method returns a base class object, a pointer should be returned. | |
| 1055 | +{\bf Do never return base class objects by reference, as this will lead to | |
| 1056 | +code slicing if the method is used for object assignment.} | |
| 1057 | +Unless we explicitly want to modify a class member through the method call, | |
| 1058 | +the returned pointer should be declared {\tt const}. | |
| 1059 | + | |
| 1060 | +Here an example based on the definition of {\tt GObservation}: | |
| 1061 | +\begin{verbatim} | |
| 1062 | +class GObservation { | |
| 1063 | +public: | |
| 1064 | + virtual double ontime(void) const = 0; | |
| 1065 | + const GEvents* events(void) const; | |
| 1066 | + const std::string& statistics(void) const { return m_statistics; } | |
| 1067 | +protected: | |
| 1068 | + std::string m_statistics; //!< Optimizer statistics (default=poisson) | |
| 1069 | + GEvents* m_events; //!< Pointer to event container | |
| 1070 | +}; | |
| 1071 | +\end{verbatim} | |
| 1072 | +The {\tt ontime()} method does return a double by value as the ontime property is not | |
| 1073 | +stored explicitly in the class (hence no reference can be returned to it). | |
| 1074 | +On the other hand, the {\tt statistics()} method returns by reference as the statistics | |
| 1075 | +property is stored as a data member (hence a reference can be returned). | |
| 1076 | +Although we could have returned a reference to the event container, this would lead | |
| 1077 | +to code slicing. | |
| 1078 | +Therefore, the {\tt events()} method returns a pointer. | |
| 1079 | +All returned references or pointers are declared {\tt const} to prevent modification of | |
| 1080 | +class members. | |
| 1081 | + | |
| 1082 | + | |
| 1083 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1084 | +\subsubsection{Container classes} | |
| 1085 | +\label{sec:containers} | |
| 1086 | + | |
| 1087 | +Container classes are classes that contain list of elements. | |
| 1088 | +Two cases are distinguished here: containers holding objects, and containers holding | |
| 1089 | +pointers to objects. | |
| 1090 | + | |
| 1091 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1092 | +\paragraph{Containers holding objects} | |
| 1093 | + | |
| 1094 | +Containers holding objects should have element access operators {\tt operator[]} implemented | |
| 1095 | +that return container elements by reference. | |
| 1096 | +A non-const and a const version of the operator should exist. | |
| 1097 | +Eventually, {\tt at()} methods could be added that always perform range checking. | |
| 1098 | +Here is a list of mandatory methods for container classes holding objects: | |
| 1099 | + | |
| 1100 | +%%% Mandatory methods for container classes %%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1101 | +\begin{center} | |
| 1102 | +\begin{tabular}{ll} | |
| 1103 | +\hline | |
| 1104 | +\hline | |
| 1105 | +\noalign{\smallskip} | |
| 1106 | +Method & Usage \\ | |
| 1107 | +\noalign{\smallskip} | |
| 1108 | +\hline | |
| 1109 | +\noalign{\smallskip} | |
| 1110 | +{\tt e\& operator[](const int\&)} & Element access operator \\ | |
| 1111 | +{\tt const e\& operator[](const int\&) const} & Element access operator \\ | |
| 1112 | +{\tt void clear()} & Delete all objects in container \\ | |
| 1113 | +{\tt void size()} & Return number of elements in container \\ | |
| 1114 | +{\tt void append(const e\&)} & Append an element to the container \\ | |
| 1115 | +{\tt void insert(const int\&, const e\&)} & Insert an element into the container \\ | |
| 1116 | +{\tt void extend(const C\&)} & Append another container to the container \\ | |
| 1117 | +{\tt void pop(const int\&)} & Removes an element from the container \\ | |
| 1118 | +{\tt std::string print()} & Print container (see section \ref{sec:output}) \\ | |
| 1119 | +\noalign{\smallskip} | |
| 1120 | +\hline | |
| 1121 | +\end{tabular} | |
| 1122 | +\end{center} | |
| 1123 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1124 | + | |
| 1125 | + | |
| 1126 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1127 | +\paragraph{Containers holding pointers} | |
| 1128 | + | |
| 1129 | +Containers holding pointers different from those holding objects in that their {\tt operator[]} | |
| 1130 | +operators return a pointer, and in that they implement a {\tt set()} method for value setting. | |
| 1131 | +Here is a list of mandatory methods for container classes holding pointers: | |
| 1132 | + | |
| 1133 | +%%% Mandatory methods for container classes %%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1134 | +\begin{center} | |
| 1135 | +\begin{tabular}{ll} | |
| 1136 | +\hline | |
| 1137 | +\hline | |
| 1138 | +\noalign{\smallskip} | |
| 1139 | +Method & Usage \\ | |
| 1140 | +\noalign{\smallskip} | |
| 1141 | +\hline | |
| 1142 | +\noalign{\smallskip} | |
| 1143 | +{\tt e* operator[](const int\&)} & Element access operator \\ | |
| 1144 | +{\tt const e* operator[](const int\&) const} & Element access operator \\ | |
| 1145 | +{\tt void set(const int\&, const e\&)} & Set an element of the container \\ | |
| 1146 | +{\tt void clear()} & Delete all objects in container \\ | |
| 1147 | +{\tt void size()} & Return number of elements in container \\ | |
| 1148 | +{\tt void append(const e\&)} & Append an element to the container \\ | |
| 1149 | +{\tt void insert(const int\&, const e\&)} & Insert an element into the container \\ | |
| 1150 | +{\tt void extend(const C\&)} & Append another container to the container \\ | |
| 1151 | +{\tt void pop(const int\&)} & Removes an element from the container \\ | |
| 1152 | +{\tt std::string print()} & Print container (see section \ref{sec:output}) \\ | |
| 1153 | +\noalign{\smallskip} | |
| 1154 | +\hline | |
| 1155 | +\end{tabular} | |
| 1156 | +\end{center} | |
| 1157 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 406 | 1158 | |
| 407 | 1159 | |
| 408 | 1160 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -410,16 +1162,7 @@ class member. |
| 410 | 1162 | \label{sec:output} |
| 411 | 1163 | |
| 412 | 1164 | Output stream and logging operators should be implemented for every class as friend |
| 413 | -operators. | |
| 414 | -An example is: | |
| 415 | -\begin{verbatim} | |
| 416 | -#include <iostream> | |
| 417 | -#include "GLog.hpp" | |
| 418 | -class GFits { | |
| 419 | - friend std::ostream& operator<< (std::ostream& os, const GFits& fits); | |
| 420 | - friend GLog& operator<< (GLog& log, const GFits& fits); | |
| 421 | - ... | |
| 422 | -\end{verbatim} | |
| 1165 | +operators (see section \ref{sec:header}). | |
| 423 | 1166 | The usage of friend operators (instead of member operators) allows for correct handling |
| 424 | 1167 | of code such as |
| 425 | 1168 | \begin{verbatim} |
| ... | ... | @@ -446,63 +1189,38 @@ GLog& operator<< (GLog& log, const GFits& fits) |
| 446 | 1189 | |
| 447 | 1190 | |
| 448 | 1191 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 449 | -\subsubsection{Container classes} | |
| 1192 | +\subsubsection{Exceptions} | |
| 1193 | +\label{sec:exceptions} | |
| 450 | 1194 | |
| 451 | -Container classes are classes that contain list of elements. | |
| 1195 | +Exceptions are largely used in \this\ to handle the occurrence of unexpected events. | |
| 1196 | +\this\ exceptions are implement by the {\tt GException} class. | |
| 1197 | +For each new exception type, a new exception subclass is added. | |
| 452 | 1198 | |
| 453 | -Each container class should have element access operators {\tt operator[]} implemented, | |
| 454 | -returning either a reference or a pointer to the class elements. | |
| 455 | -A non-const and a const version of the operator should exist. | |
| 1199 | +Each exception returns the method name in which the exception occurs and an exception | |
| 1200 | +message. | |
| 1201 | +The exception message is generally build from values that are passed as arguments to the | |
| 1202 | +exception constructor. | |
| 456 | 1203 | |
| 457 | -Similar to the C++ template classes, {\tt at()} methods could also be implemented that | |
| 458 | -perform range checking. | |
| 1204 | +Below a list of conventions for implementing and using exceptions: | |
| 1205 | +\begin{itemize} | |
| 1206 | +\item Re-use existing exceptions as far as possible. | |
| 1207 | +\item Pass exception arguments by reference. | |
| 1208 | +\item Use exceptions only for events that cannot be handled by a method. | |
| 1209 | +Do not use exceptions to check a value or a state. Implement appropriate methods instead. | |
| 1210 | +\item Never use exceptions in a destructor. | |
| 1211 | +\item De-allocate all memory that is not de-allocated by the destructor before throwing an | |
| 1212 | +exception. | |
| 1213 | +\item Always catch exceptions by reference. | |
| 1214 | +\end{itemize} | |
| 459 | 1215 | |
| 460 | 1216 | |
| 461 | 1217 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 462 | -% Documentation | |
| 463 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 464 | -\section{Documentation} | |
| 465 | - | |
| 466 | -Code documentation should be done within the source files using Doxygen | |
| 467 | -compliant annotations. | |
| 468 | - | |
| 469 | -The following rules apply. | |
| 1218 | +%\subsection{Python classes} | |
| 470 | 1219 | |
| 1220 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1221 | +%\subsubsection{Container classes} | |
| 471 | 1222 | |
| 472 | -\subsection{File descriptor} | |
| 473 | - | |
| 474 | -Put a 80 character wide header comment on top of {\bf each file} | |
| 475 | -(header, source code, templates, etc.). | |
| 476 | -The header contains | |
| 477 | -the file name, | |
| 478 | -a brief description of the file content, | |
| 479 | -the development period and the name of the person which {\bf initially} | |
| 480 | -created the file, and | |
| 481 | -a standard GNU Public License statement. | |
| 482 | -The header comment is immediately followed by a Doxygen compliant | |
| 483 | -file description that provides | |
| 484 | -the file name, | |
| 485 | -a brief description of the file content, and | |
| 486 | -the name of the person which {\bf initially} created the file. | |
| 487 | -\begin{verbatim} | |
| 488 | -/*************************************************************************** | |
| 489 | - * GMatrix.cpp - matrix class * | |
| 490 | - * ----------------------------------------------------------------------- * | |
| 491 | - * copyright (C) 2006-2010 by Jurgen Knodlseder * | |
| 492 | - * ----------------------------------------------------------------------- * | |
| 493 | - * * | |
| 494 | - * This program is free software; you can redistribute it and/or modify * | |
| 495 | - * it under the terms of the GNU General Public License as published by * | |
| 496 | - * the Free Software Foundation; either version 2 of the License, or * | |
| 497 | - * (at your option) any later version. * | |
| 498 | - * * | |
| 499 | - ***************************************************************************/ | |
| 500 | -/** | |
| 501 | - * @file GMatrix.cpp | |
| 502 | - * @brief GVector class implementation. | |
| 503 | - * @author J. Knodlseder | |
| 504 | - */ | |
| 505 | -\end{verbatim} | |
| 1223 | +%TBW | |
| 506 | 1224 | |
| 507 | 1225 | |
| 508 | 1226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... | @@ -516,29 +1234,24 @@ the name of the person which {\bf initially} created the file. |
| 516 | 1234 | \this\ applies a three-number version numbering scheme: |
| 517 | 1235 | {\tt major\_revision-minor\_revision-patch}. |
| 518 | 1236 | |
| 519 | -A {\tt major\_revision} of {\tt 00} designates the development version of \this. | |
| 520 | -At this level, external interfaces of \this\ may change constantly, hence no | |
| 1237 | +A {\tt major\_revision} of {\tt 00} indicates that the \this\ design is not yet frozen. | |
| 1238 | +At this level, external interfaces of \this\ may change without notification, and no | |
| 521 | 1239 | interface control system is implemented. |
| 522 | -The {\tt minor\_revision} tag will be incremented once new major features become | |
| 523 | -available. | |
| 524 | -The {\tt patch} tag will be incremented after adding minor features and code corrections. | |
| 525 | - | |
| 526 | -Once the development phase is finished the release phase is entred. | |
| 527 | -At this moment the {\tt major\_revision} number will be incremented to {\tt 01}. | |
| 528 | - | |
| 529 | -During release phase, external interfaces of \this\ will be under configuration control. | |
| 530 | -If modifications of existing external interfaces will be done, the {\tt major\_revision} | |
| 531 | -number will be incremented. | |
| 532 | -At the same time, the {\tt libtool} version number of the \this\ will also change. | |
| 533 | - | |
| 534 | -The {\tt minor\_revision} number will be incremented in the release phase when | |
| 535 | -extensions of the existing interfaces get implemented. | |
| 536 | -Extensions should always be backward compatible, i.e. any existing software should | |
| 537 | -not break due to the add of extensions. | |
| 538 | - | |
| 539 | -The {\tt patch} number will be incremented in the release phase after bug corrections | |
| 540 | -or code improvements. | |
| 541 | -The corresponding modifications should not change the functionality of the library. | |
| 1240 | +The {\tt minor\_revision} tag will be incremented for each new release, signaling | |
| 1241 | +that new features have become available. | |
| 1242 | +The {\tt patch} tag will be incremented after correcting bugs that were reported | |
| 1243 | +on releases. | |
| 1244 | + | |
| 1245 | +Once the \this\ design is frozen, the {\tt major\_revision} number will be incremented | |
| 1246 | +to {\tt 01}. | |
| 1247 | +From this moment on, external interfaces of \this\ will be under configuration control. | |
| 1248 | +If existing external interfaces will be modified, the {\tt major\_revision} number will be | |
| 1249 | +incremented. | |
| 1250 | +At the same time, the {\tt libtool} version number of the \this\ will also be incremented. | |
| 1251 | +The {\tt minor\_revision} number will be incremented if modifications and extensions | |
| 1252 | +are backward compatible | |
| 1253 | +As before, the {\tt patch} number will be incremented after correcting bugs that were | |
| 1254 | +reported on releases. | |
| 542 | 1255 | |
| 543 | 1256 | \end{document} |
| 544 | 1257 | ... | ... |
doc/dev/coding/manual.sty
| 1 | 1 | %% |
| 2 | 2 | %% "manual.sty" provides definitions for the gammalib documentation |
| 3 | 3 | %% |
| 4 | -%% Copyright (C) 2009 Jurgen Knodlseder | |
| 4 | +%% Copyright (C) 2009-2012 Juergen Knoedlseder | |
| 5 | 5 | %% |
| 6 | 6 | \NeedsTeXFormat{LaTeX2e} |
| 7 | -\ProvidesPackage{manual}[2009/10/07 gammalib ducomentation] | |
| 7 | +\ProvidesPackage{manual}[2012/09/22 gammalib documentation] | |
| 8 | 8 | |
| 9 | 9 | % |
| 10 | 10 | % The page dimensions |
| ... | ... | @@ -73,7 +73,6 @@ |
| 73 | 73 | % Author |
| 74 | 74 | \rm |
| 75 | 75 | Author: \auth\ \\ |
| 76 | -Approved by: \approv\ \\ | |
| 77 | 76 | |
| 78 | 77 | % Affiliation |
| 79 | 78 | \vspace*{1cm} |
| ... | ... | @@ -97,13 +96,6 @@ FRANCE |
| 97 | 96 | \vspace{200mm} |
| 98 | 97 | \centerline{This page intentionally left blank} |
| 99 | 98 | \vspace{3mm} |
| 100 | -%This software has been written to analyse data of the SPI | |
| 101 | -%telescope onboard INTEGRAL. | |
| 102 | -%Particular care has been taken in making the software user friendly | |
| 103 | -%and well documented. | |
| 104 | -%If you appreciated this effort, and if this software and User Manual | |
| 105 | -%were useful for your scientific work, the author would appreciate a | |
| 106 | -%corresponding acknowledgment in your published work. | |
| 107 | 99 | } |
| 108 | 100 | \end{center} |
| 109 | 101 | ... | ... |
doc/gammalib_um.tex deleted
| 1 | -%---------------------------------------------------------------------------- | |
| 2 | -% GammaLib User Manual | |
| 3 | -% | |
| 4 | -% Version: 0.4 | |
| 5 | -% Last modification: 30 November 2010 | |
| 6 | -%---------------------------------------------------------------------------- | |
| 7 | - | |
| 8 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 9 | -% Definitions for manual package | |
| 10 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 11 | -\newcommand{\task}{\mbox{GammaLib}} | |
| 12 | -\newcommand{\this}{\mbox{\tt \task}} | |
| 13 | -\newcommand{\version}{\mbox{0.4}} | |
| 14 | -\newcommand{\calendar}{\mbox{30 November 2010}} | |
| 15 | - | |
| 16 | - | |
| 17 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 18 | -% Document definition | |
| 19 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 20 | -\documentclass{article}[12pt,a4] | |
| 21 | -\usepackage{epsfig} | |
| 22 | -\usepackage{manual} | |
| 23 | - | |
| 24 | - | |
| 25 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 26 | -% Begin of document body | |
| 27 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 28 | -\begin{document} | |
| 29 | -\frontpage | |
| 30 | - | |
| 31 | - | |
| 32 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 33 | -% Introduction | |
| 34 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 35 | -\section{Introduction} | |
| 36 | - | |
| 37 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 38 | -\subsection{Overview} | |
| 39 | - | |
| 40 | -\this\ is a machine-independent library of C++ classes for analysing gamma-ray astronomy | |
| 41 | -data. | |
| 42 | -The core of \this\ implements an abstract interface to gamma-ray observations, | |
| 43 | -provides services for reading and writing the data, | |
| 44 | -enables the analysis of multi-mission data, | |
| 45 | -and implements support for building ftools like analysis executables. | |
| 46 | -On top of this core library, instrument specific C++ classes implement the interfaces to | |
| 47 | -handle data and response functions of specific gamma-ray instruments. | |
| 48 | - | |
| 49 | -The development of \this\ has been initiated by scientists from IRAP (Institut de Recherche | |
| 50 | -en Astrophysique et Plan\'etologie), an astrophysics laboratory of CNRS and of the University | |
| 51 | -Paul Sabatier situated in Toulouse, France. | |
| 52 | -\this\ is based on past experience gained in developing software for gamma-ray space | |
| 53 | -missions, such as | |
| 54 | -the COMPTEL telescope aboard {\em CGRO}, | |
| 55 | -the SPI telescope aboard {\em INTEGRAL}, | |
| 56 | -and the LAT telescope aboard {\em Fermi}. | |
| 57 | -Initial elements of \this\ can be found in the {\tt spi\_toolslib} that is part of the | |
| 58 | -Off-line Science Analysis (OSA) software distributed by ISDC for the science analysis | |
| 59 | -of {\em INTEGRAL} data. | |
| 60 | -The development of \this\ is nowadays mainly driven by the advances in | |
| 61 | -ground-based gamma-ray astronomy, and in particular by the development of the | |
| 62 | -CTA observatory. | |
| 63 | - | |
| 64 | - | |
| 65 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 66 | -\subsection{Getting \this} | |
| 67 | - | |
| 68 | -The latest version of the \this\ source code, documentation, and example programs are | |
| 69 | -available on the World-Wide Web from: | |
| 70 | -\begin{verbatim} | |
| 71 | - https://sourceforge.net/projects/gammalib/ | |
| 72 | -\end{verbatim} | |
| 73 | -Any questions, bug reports, or suggested enhancements related to \this\ should be submitted | |
| 74 | -via the {\em Tracker} or the | |
| 75 | -\begin{verbatim} | |
| 76 | - gammalib-users@lists.sourceforge.net | |
| 77 | -\end{verbatim} | |
| 78 | -mailing list. | |
| 79 | - | |
| 80 | - | |
| 81 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 82 | -\subsection{Prerequisites} | |
| 83 | - | |
| 84 | -\this\ should compile on every modern Unix system without any need to install any | |
| 85 | -specific library. | |
| 86 | - | |
| 87 | -To enable support for FITS file handling, however, the {\tt cfitsio} library from HEASARC | |
| 88 | -needs to be installed. | |
| 89 | -{\tt cfitsio} can be downloaded from | |
| 90 | -\begin{verbatim} | |
| 91 | - http://heasarc.gsfc.nasa.gov/fitsio | |
| 92 | -\end{verbatim} | |
| 93 | -and detailed installation instructions can be found there. | |
| 94 | -If {\tt cfitsio} does not already exist on your system, we recommend installation of {\tt cfitsio} | |
| 95 | -in the default \this\ install directory as a shared library by typing: | |
| 96 | -\begin{verbatim} | |
| 97 | -> ./configure --prefix=/usr/local/gamma | |
| 98 | -> make shared | |
| 99 | -> make install | |
| 100 | -\end{verbatim} | |
| 101 | - | |
| 102 | -\this\ can also benefit from the presence of the {\tt readline} library that provides line-editing | |
| 103 | -and history capabilities for text input (\this\ offers however also full functionality without having | |
| 104 | -{\tt readline} installed). | |
| 105 | -{\tt readline} can be downloaded from | |
| 106 | -\begin{verbatim} | |
| 107 | - http://ftp.gnu.org/gnu/readline/ | |
| 108 | -\end{verbatim} | |
| 109 | - | |
| 110 | - | |
| 111 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 112 | -\subsection{Installing \this} | |
| 113 | - | |
| 114 | -\this\ is built on Unix systems by typing: | |
| 115 | -\begin{verbatim} | |
| 116 | -> ./autogen.sh | |
| 117 | -> ./configure | |
| 118 | -> make | |
| 119 | -> make install | |
| 120 | -\end{verbatim} | |
| 121 | -at the operating system prompt. | |
| 122 | -The configuration command customizes the Makefiles for the particular system, | |
| 123 | -the {\tt make} command compiles the source files and builds the library, and | |
| 124 | -the {\tt make install} command installs the library in the install directory. | |
| 125 | -Type {\tt ./configure} and not simply {\tt configure} to ensure that the configuration | |
| 126 | -script in the current directory is run and not some other system-wide configuration | |
| 127 | -script. | |
| 128 | -By default, the install directory is set to | |
| 129 | -{\tt /usr/local/gamma}. | |
| 130 | -To change the install directory an optional {\tt --prefix} argument should be given, | |
| 131 | -for example: | |
| 132 | -\begin{verbatim} | |
| 133 | -> ./configure --prefix=/usr/local | |
| 134 | -\end{verbatim} | |
| 135 | -A full list of configuration options can be found using | |
| 136 | -\begin{verbatim} | |
| 137 | -> ./configure --help | |
| 138 | -\end{verbatim} | |
| 139 | - | |
| 140 | - | |
| 141 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 142 | -\subsection{Testing \this} | |
| 143 | - | |
| 144 | -\this\ should be tested by typing: | |
| 145 | -\begin{verbatim} | |
| 146 | -> make check | |
| 147 | -\end{verbatim} | |
| 148 | -This will execute an extensive testing suite that should terminate with | |
| 149 | -\begin{verbatim} | |
| 150 | -=================== | |
| 151 | -All 14 tests passed | |
| 152 | -=================== | |
| 153 | -\end{verbatim} | |
| 154 | -If an older version of \this\ exists already on the system one has to make sure that the | |
| 155 | -library in installed using {\tt make install} before executing the tests. | |
| 156 | - | |
| 157 | - | |
| 158 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 159 | -\subsection{Getting started with \this} | |
| 160 | - | |
| 161 | -In order to effectively use \this\ it is recommended that new users begin by reading the | |
| 162 | -\this\ Quick Start Guide. | |
| 163 | -It contains all basic information needed to write programs to analyse gamma-ray data. | |
| 164 | -{\bf TBW ...} | |
| 165 | - | |
| 166 | - | |
| 167 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 168 | -\subsection{Example program} | |
| 169 | - | |
| 170 | -{\bf TBD: Give a short example program here ...} | |
| 171 | - | |
| 172 | - | |
| 173 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 174 | -% Programming Guidelines | |
| 175 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 176 | -\section{Programming guidelines} | |
| 177 | - | |
| 178 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 179 | -\subsection{\this\ definitions} | |
| 180 | - | |
| 181 | - | |
| 182 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 183 | -% GammaLib components | |
| 184 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 185 | -\section{\this\ components} | |
| 186 | - | |
| 187 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 188 | -\subsection{Observations} | |
| 189 | - | |
| 190 | -The primary user interface for the analysis of gamma-ray data is implemented by | |
| 191 | -the container class {\tt GObservations}. | |
| 192 | -{\tt GObservations} collects a list of gamma-ray observations which are the basic | |
| 193 | -entity used | |
| 194 | - | |
| 195 | -The basic entity used for analysis of gamma-ray data is an observation. | |
| 196 | -{\bf TBW: Define what an observation is: single instrument, specific response function}. | |
| 197 | - | |
| 198 | -An observation is implemented by the abstract {\tt GObservation} class that provides | |
| 199 | -the instrument independent interface to the data. | |
| 200 | - | |
| 201 | -To combine several observation for an analysis, a list of {\tt GObservation} objects is | |
| 202 | -gather by the container class {\tt GObservations} | |
| 203 | - | |
| 204 | - | |
| 205 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 206 | -\subsection{Models} | |
| 207 | - | |
| 208 | - | |
| 209 | - | |
| 210 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 211 | -\subsection{Optimizers} | |
| 212 | - | |
| 213 | - | |
| 214 | - | |
| 215 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 216 | -\subsection{Applications} | |
| 217 | - | |
| 218 | - | |
| 219 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 220 | -\subsection{Interfaces} | |
| 221 | - | |
| 222 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 223 | -\subsubsection{FITS interface} | |
| 224 | - | |
| 225 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 226 | -\subsubsection{XML interface} | |
| 227 | - | |
| 228 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 229 | -\subsubsection{Parameter interface} | |
| 230 | - | |
| 231 | - | |
| 232 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 233 | -\subsection{Numerics} | |
| 234 | - | |
| 235 | - | |
| 236 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 237 | -\subsection{Linear algebra} | |
| 238 | - | |
| 239 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 240 | -\subsubsection{Vectors} | |
| 241 | - | |
| 242 | -%---------------------------------------------------------------------------- | |
| 243 | -\paragraph{General} | |
| 244 | - | |
| 245 | -A vector is a one-dimensional array of successive {\tt double} type values. | |
| 246 | -Vectors are handled in \this\ by {\tt GVector} objects. | |
| 247 | -On construction, the dimension of the vector has to be specified. | |
| 248 | -In other words | |
| 249 | -\begin{verbatim} | |
| 250 | - GVector vector; // WRONG: constructor needs dimension | |
| 251 | -\end{verbatim} | |
| 252 | -is not allowed. | |
| 253 | -The minimum dimension of a vector is 1, i.e. there is no such thing | |
| 254 | -like an empty vector: | |
| 255 | -\begin{verbatim} | |
| 256 | - GVector vector(0); // WRONG: empty vector not allowed | |
| 257 | -\end{verbatim} | |
| 258 | -The correct allocation of a vector is done using | |
| 259 | -\begin{verbatim} | |
| 260 | - GVector vector(10); // Allocates a vector with 10 elements | |
| 261 | -\end{verbatim} | |
| 262 | -On allocation, all elements of a vector are set to 0. | |
| 263 | -Vectors may also be allocated by copying from another vector | |
| 264 | -\begin{verbatim} | |
| 265 | - GVector vector(10); // Allocates a vector with 10 elements | |
| 266 | - GVector another = vector; // Allocates another vector with 10 elements | |
| 267 | -\end{verbatim} | |
| 268 | -or by using | |
| 269 | -\begin{verbatim} | |
| 270 | - GVector vector = GVector(10); // Allocates a vector with 10 elements | |
| 271 | -\end{verbatim} | |
| 272 | - | |
| 273 | -Vector elements are accessed using the {\tt ( )} operator: | |
| 274 | -\begin{verbatim} | |
| 275 | - GVector vector(10); // Allocates a vector with 10 elements | |
| 276 | - for (int i = 0; i < 10; ++i) | |
| 277 | - vector(i) = (i+1)*10.0; // Set elements 10, 20, ..., 100 | |
| 278 | - for (int i = 0; i < 10; ++i) | |
| 279 | - cout << vector(i) << endl; // Dump all elements, one by row | |
| 280 | -\end{verbatim} | |
| 281 | -The content of a vector may also be dumped using | |
| 282 | -\begin{verbatim} | |
| 283 | - cout << vector << endl; // Dump entire vector | |
| 284 | -\end{verbatim} | |
| 285 | -which in the above example will put the sequence | |
| 286 | -\begin{verbatim} | |
| 287 | - 10 20 30 40 50 60 70 80 90 100 | |
| 288 | -\end{verbatim} | |
| 289 | -on the screen. | |
| 290 | - | |
| 291 | - | |
| 292 | -%---------------------------------------------------------------------------- | |
| 293 | -\paragraph{Vector arithmetics} | |
| 294 | - | |
| 295 | -Vectors can be very much handled like {\tt double} type variables | |
| 296 | -with the difference that operations are performed on each element of | |
| 297 | -the vector. | |
| 298 | -The complete list of fundamental vector operators is: | |
| 299 | -\begin{verbatim} | |
| 300 | - c = a + b; // Vector + Vector addition | |
| 301 | - c = a + s; // Vector + Scalar addition | |
| 302 | - c = s + b; // Scalar + Vector addition | |
| 303 | - c = a - b; // Vector - Vector subtraction | |
| 304 | - c = a - s; // Vector - Scalar subtraction | |
| 305 | - c = s - b; // Scalar - Vector subtraction | |
| 306 | - s = a * b; // Vector * Vector multiplication (dot product) | |
| 307 | - c = a * s; // Vector * Scalar multiplication | |
| 308 | - c = s * b; // Scalar * Vector multiplication | |
| 309 | - c = a / s; // Vector * Scalar division | |
| 310 | -\end{verbatim} | |
| 311 | -where {\tt a}, {\tt b} and {\tt c} are of type {\tt GVector} and | |
| 312 | -{\tt s} is of type {\tt double}. | |
| 313 | -Note in particular the combination of {\tt GVector} and {\tt double} | |
| 314 | -type objects in addition, subtraction, multiplication and division. | |
| 315 | -In these cases the specified operation is applied to each of the | |
| 316 | -vector elements. | |
| 317 | -It is also obvious that only vector of identicial dimension can occur | |
| 318 | -in vector operations. | |
| 319 | -Dimension errors can be catched by the {\tt try} - {\tt catch} | |
| 320 | -functionality: | |
| 321 | -\begin{verbatim} | |
| 322 | - try { | |
| 323 | - GVector a(10); | |
| 324 | - GVector b(11); | |
| 325 | - GVector c = a + b; // WRONG: Vectors have incompatible dimensions | |
| 326 | - } | |
| 327 | - catch (GVector::vector_mismatch &e) { | |
| 328 | - cout << e.what() << endl; // Dimension exception is catched here | |
| 329 | - throw; | |
| 330 | - } | |
| 331 | -\end{verbatim} | |
| 332 | -Further vector operations are | |
| 333 | -\begin{verbatim} | |
| 334 | - c = a; // Vector assignment | |
| 335 | - c = s; // Scalar assignment | |
| 336 | - s = c(index); // Vector element access | |
| 337 | - c += a; // c = c + a; | |
| 338 | - c -= a; // c = c - a; | |
| 339 | - c += s; // c = c + s; | |
| 340 | - c -= s; // c = c - s; | |
| 341 | - c *= s; // c = c * s; | |
| 342 | - c /= s; // c = c / s; | |
| 343 | - c = -a; // Vector negation | |
| 344 | -\end{verbatim} | |
| 345 | -Finally, the comparison operators | |
| 346 | -\begin{verbatim} | |
| 347 | - int equal = (a == b); // True if all elements equal | |
| 348 | - int unequal = (a != b); // True if at least one elements unequal | |
| 349 | -\end{verbatim} | |
| 350 | -allow to compare all elements of a vector. If all elements are | |
| 351 | -identical, the {\tt ==} operator returns true, otherwise false. | |
| 352 | -If at least one element differs, the {\tt !=} operator returns true, | |
| 353 | -is all elements are identical it returns false. | |
| 354 | - | |
| 355 | -In addition to the operators, the following mathematical functions | |
| 356 | -can be applied to vectors: | |
| 357 | -\begin{verbatim} | |
| 358 | - acos atan exp sin tanh | |
| 359 | - acosh atanh fabs sinh | |
| 360 | - asin cos log sqrt | |
| 361 | - asinh cosh log10 tan | |
| 362 | -\end{verbatim} | |
| 363 | -Again, these functions should be understood to be applied element wise. | |
| 364 | -They all take a vector as argument and produce a vector as result. | |
| 365 | -For example | |
| 366 | -\begin{verbatim} | |
| 367 | - c = sin(a); | |
| 368 | -\end{verbatim} | |
| 369 | -attributes the sine of each element of vector {\tt a} to vector | |
| 370 | -{\tt c}. | |
| 371 | -Additional implemented functions are | |
| 372 | -\begin{verbatim} | |
| 373 | - c = cross(a, b); // Vector cross product (for 3d only) | |
| 374 | - s = norm(a); // Vector norm |a| | |
| 375 | - s = min(a); // Minimum element of vector | |
| 376 | - s = max(a); // Maximum element of vector | |
| 377 | - s = sum(a); // Sum of vector elements | |
| 378 | -\end{verbatim} | |
| 379 | -Finally, a small number of vector methods have been implemented: | |
| 380 | -\begin{verbatim} | |
| 381 | - int n = a.size(); // Returns dimension of vector | |
| 382 | - int n = a.non_zeros(); // Returns number of non-zero elements in vector | |
| 383 | -\end{verbatim} | |
| 384 | - | |
| 385 | - | |
| 386 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 387 | -\subsubsection{Matrixes} | |
| 388 | - | |
| 389 | -%---------------------------------------------------------------------------- | |
| 390 | -\paragraph{General} | |
| 391 | - | |
| 392 | -A matrix is a two-dimensional array of {\tt double} type values, | |
| 393 | -arranged in rows and columns. | |
| 394 | -Matrixes are handled in \this\ by {\tt GMatrix} objects and the | |
| 395 | -derived classes {\tt GSymMatrix} and {\tt GSparseMatrix} (see section | |
| 396 | -\ref{sec:matrix:storage}). | |
| 397 | -On construction, the dimension of the matrix has to be specified: | |
| 398 | -\begin{verbatim} | |
| 399 | - GMatrix matrix(10,20); // Allocates 10 rows and 20 columns | |
| 400 | -\end{verbatim} | |
| 401 | -Similar to vectors, there is no such thing as a matrix without | |
| 402 | -dimensions in \this. | |
| 403 | - | |
| 404 | - | |
| 405 | -%---------------------------------------------------------------------------- | |
| 406 | -\paragraph{Matrix storage classes} | |
| 407 | -\label{sec:matrix:storage} | |
| 408 | - | |
| 409 | -In the most general case, the {\tt rows} and {\tt columns} of a | |
| 410 | -matrix are stored in a continuous array of | |
| 411 | -${\tt rows} \times {\tt columns}$ | |
| 412 | -memory locations. | |
| 413 | -This storage type is referred to as a {\em full matrix}, and is | |
| 414 | -implemented by the class {\tt GMatrix}. | |
| 415 | -Operations on full matrixes are in general relatively fast, but | |
| 416 | -memory requirements may be important to hold all the elements. | |
| 417 | -In general matrixes are stored by \this\ column-wise (or in | |
| 418 | -column-major format). | |
| 419 | -For example, the matrix | |
| 420 | -\begin{verbatim} | |
| 421 | - 1 2 3 4 5 | |
| 422 | - 6 7 8 9 10 | |
| 423 | - 11 12 13 14 15 | |
| 424 | -\end{verbatim} | |
| 425 | -is stored in memory as | |
| 426 | -\begin{verbatim} | |
| 427 | - | 1 6 11 | 2 7 12 | 3 8 13 | 4 9 14 | 5 10 15 | | |
| 428 | -\end{verbatim} | |
| 429 | - | |
| 430 | -Many physical or mathematical problems treat with a subclass of | |
| 431 | -matrixes that is symmetric, i.e. for which the element | |
| 432 | -{\tt (row,col)} is identical to the element {\tt (col,row)}. | |
| 433 | -In this case, the duplicated elements need not to be stored. | |
| 434 | -The derived class {\tt GSymMatrix} implements such a storage type. | |
| 435 | -{\tt GSymMatrix} stores the lower-left triangle of the matrix in | |
| 436 | -column-major format. | |
| 437 | -For illustration, the matrix | |
| 438 | -\begin{verbatim} | |
| 439 | - 1 2 3 4 | |
| 440 | - 2 5 6 7 | |
| 441 | - 3 6 8 9 | |
| 442 | - 4 7 9 10 | |
| 443 | -\end{verbatim} | |
| 444 | -is stored in memory as | |
| 445 | -\begin{verbatim} | |
| 446 | - | 1 2 3 4 | 5 6 7 | 8 9 | 10 | | |
| 447 | -\end{verbatim} | |
| 448 | -This divides the storage requirements to hold the matrix elements by | |
| 449 | -almost a factor of two. | |
| 450 | - | |
| 451 | -Finally, quite often one has to deal with matrixes that contain a | |
| 452 | -large number of zeros. | |
| 453 | -Such matrixes are called {\em sparse matrixes}. | |
| 454 | -If only the non-zero elements of a sparse matrix are stored the memory | |
| 455 | -requirements are considerably reduced. | |
| 456 | -This goes however at the expense of matrix element access, which has | |
| 457 | -become now more complex. | |
| 458 | -In particular, filling efficiently a sparse matrix is a non-trivial | |
| 459 | -problem (see section \ref{sec:matrix:filling}). | |
| 460 | -Sparse matrix storage is implemented in \this\ by the derived class | |
| 461 | -{\tt GSparseMatrix}. | |
| 462 | -A {\tt GSparseMatrix} object contains three one-dimensional arrays to | |
| 463 | -store the matrix elements: | |
| 464 | -a {\tt double} type array that contains in continuous column-major order | |
| 465 | -all non-zero elements, | |
| 466 | -an {\tt int} type array that contains for each non-zero element the | |
| 467 | -row number of its location, and | |
| 468 | -an {\tt int} type array that contains the storage location of the | |
| 469 | -first non-zero element for each matrix column. | |
| 470 | -To illustrate this storage format, the matrix | |
| 471 | -\begin{verbatim} | |
| 472 | - 1 0 0 7 | |
| 473 | - 2 5 0 0 | |
| 474 | - 3 0 6 0 | |
| 475 | - 4 0 0 8 | |
| 476 | -\end{verbatim} | |
| 477 | -is stored in memory as | |
| 478 | -\begin{verbatim} | |
| 479 | - | 1 2 3 4 | 5 | 6 | 7 8 | Matrix elements | |
| 480 | - | 0 1 2 3 | 1 | 2 | 0 3 | Row indices for all elements | |
| 481 | - | 0 | 4 | 5 | 6 | Storage location of first element of each column | |
| 482 | -\end{verbatim} | |
| 483 | -This example is of course not very economic, since the total number of | |
| 484 | -Bytes used to store the matrix is | |
| 485 | -$8 \times 8 + (8 + 4) \times 4 = 112$ Bytes, while a full $4 \times 4$ | |
| 486 | -matrix is stored in | |
| 487 | -$(4 \times 4) \times 8 = 128$ Bytes (recall: a {\tt double} type | |
| 488 | -values takes 8 Bytes, an {\tt int} type value takes 4 Bytes). | |
| 489 | -For realistic large systems, however, the gain in memory space can be | |
| 490 | -dramatical. | |
| 491 | - | |
| 492 | -The usage of the {\tt GMatrix}, {\tt GSymMatrix} and {\tt GSparseMatrix} | |
| 493 | -classes is analoguous in that they implement basically all functions | |
| 494 | -and methods in an identical way. | |
| 495 | -So from the semantics the user has not to worry about the storage | |
| 496 | -class. | |
| 497 | -However, matrix element access speeds are not identical for all | |
| 498 | -storage types, and if performance is an issue (as it certainly always | |
| 499 | -will be), the user has to consider matrix access more carefully | |
| 500 | -(see section \ref{sec:matrix:filling}). | |
| 501 | - | |
| 502 | -Matrix allocation is performed using the constructors: | |
| 503 | -\begin{verbatim} | |
| 504 | - GMatrix A(10,20); // Full 10 x 20 matrix | |
| 505 | - GSymMatrix B(10,10); // Symmetric 10 x 10 matrix | |
| 506 | - GSparseMatrix C(1000,10000); // Sparse 1000 x 10000 matrix | |
| 507 | - | |
| 508 | - GMatrix A(0,0); // WRONG: empty matrix not allowed | |
| 509 | - GSymMatrix B(20,22); // WRONG: symmetric matrix requested | |
| 510 | -\end{verbatim} | |
| 511 | -In the constructor, the first argument specifies the number of rows, | |
| 512 | -the second the number of columns: {\tt A(row,column)}. | |
| 513 | -A symmetric matrix needs of course an equal number of rows and columns. | |
| 514 | -And an empty matrix is not allowed. | |
| 515 | -All matrix elements are initialised to 0 by the matrix allocation. | |
| 516 | - | |
| 517 | -Matrix elements are accessed by the {\tt A(row,col)} function, | |
| 518 | -where {\tt row} and {\tt col} start from 0 for the first row or column | |
| 519 | -and run up to the number of rows or columns minus 1: | |
| 520 | -\begin{verbatim} | |
| 521 | - for (int row = 0; row < n_rows; ++row) { | |
| 522 | - for (int col = 0; col < n_cols; ++col) | |
| 523 | - A(row,col) = (row+col)/2.0; // Set value of matrix element | |
| 524 | - } | |
| 525 | - ... | |
| 526 | - double sum2 = 0.0; | |
| 527 | - for (int row = 0; row < n_rows; ++row) { | |
| 528 | - for (int col = 0; col < n_cols; ++col) | |
| 529 | - sum2 *= A(row,col) * A(row,col); // Get value of matrix element | |
| 530 | - } | |
| 531 | -\end{verbatim} | |
| 532 | - | |
| 533 | -The content of a matrix can be visualised using | |
| 534 | -\begin{verbatim} | |
| 535 | - cout << A << endl; // Dump matrix | |
| 536 | -\end{verbatim} | |
| 537 | - | |
| 538 | - | |
| 539 | -%---------------------------------------------------------------------------- | |
| 540 | -\paragraph{Matrix arithmetics} | |
| 541 | - | |
| 542 | -The following description of matrix arithmetics applies to all storage | |
| 543 | -classes (see section \ref{sec:matrix:storage}). | |
| 544 | -The following matrix operators have been implemented in \this: | |
| 545 | -\begin{verbatim} | |
| 546 | - C = A + B; // Matrix Matrix addition | |
| 547 | - C = A - B; // Matrix Matrix subtraction | |
| 548 | - C = A * B; // Matrix Matrix multiplication | |
| 549 | - C = A * v; // Matrix Vector multiplication | |
| 550 | - C = A * s; // Matrix Scalar multiplication | |
| 551 | - C = s * A; // Scalar Matrix multiplication | |
| 552 | - C = A / s; // Matrix Scalar division | |
| 553 | - C = -A; // Negation | |
| 554 | - A += B; // Matrix inplace addition | |
| 555 | - A -= B; // Matrix inplace subtraction | |
| 556 | - A *= B; // Matrix inplace multiplications | |
| 557 | - A *= s; // Matrix inplace scalar multiplication | |
| 558 | - A /= s; // Matrix inplace scalar division | |
| 559 | -\end{verbatim} | |
| 560 | -The comparison operators | |
| 561 | -\begin{verbatim} | |
| 562 | - int equal = (A == B); // True if all elements equal | |
| 563 | - int unequal = (A != B); // True if at least one elements unequal | |
| 564 | -\end{verbatim} | |
| 565 | -allow to compare all elements of a matrix. | |
| 566 | -If all elements are identical, the {\tt ==} operator returns true, | |
| 567 | -otherwise false. | |
| 568 | -If at least one element differs, the {\tt !=} operator returns true, | |
| 569 | -is all elements are identical it returns false. | |
| 570 | - | |
| 571 | - | |
| 572 | -%---------------------------------------------------------------------------- | |
| 573 | -\paragraph{Matrix methods and functions} | |
| 574 | - | |
| 575 | -A number of methods has been implemented to manipulate matrixes. | |
| 576 | -The method | |
| 577 | -\begin{verbatim} | |
| 578 | - A.clear(); // Set all elements to 0 | |
| 579 | -\end{verbatim} | |
| 580 | -sets all elements to 0. | |
| 581 | -The methods | |
| 582 | -\begin{verbatim} | |
| 583 | - int rows = A.rows(); // Returns number of rows in matrix | |
| 584 | - int cols = A.cols(); // Returns number of columns in matrix | |
| 585 | -\end{verbatim} | |
| 586 | -provide access to the matrix dimensions, the methods | |
| 587 | -\begin{verbatim} | |
| 588 | - double sum = A.sum(); // Sum of all elements in matrix | |
| 589 | - double min = A.min(); // Returns minimum element of matrix | |
| 590 | - double max = A.max(); // Returns maximum element of matrix | |
| 591 | -\end{verbatim} | |
| 592 | -inform about some matrix properties. | |
| 593 | -The methods | |
| 594 | -\begin{verbatim} | |
| 595 | - GVector v_row = A.extract_row(row); // Puts row in vector | |
| 596 | - GVector v_column = A.extract_col(col); // Puts column in vector | |
| 597 | -\end{verbatim} | |
| 598 | -extract entire rows and columns from a matrix. | |
| 599 | -Extraction of lower or upper triangle parts of a matrix into another | |
| 600 | -is performed using | |
| 601 | -\begin{verbatim} | |
| 602 | - B = A.extract_lower_triangle(); // B holds lower triangle | |
| 603 | - B = A.extract_upper_triangle(); // B holds upper triangle | |
| 604 | -\end{verbatim} | |
| 605 | -{\tt B} is of the same storage class as {\tt A}, except for the case | |
| 606 | -that {\tt A} is a {\tt GSymMatrix} object. | |
| 607 | -In this case, {\tt B} will be a full matrix of type {\tt GMatrix}. | |
| 608 | - | |
| 609 | -The methods | |
| 610 | -\begin{verbatim} | |
| 611 | - A.insert_col(v_col,col); // Puts vector in column | |
| 612 | - A.add_col(v_col,col); // Add vector to column | |
| 613 | -\end{verbatim} | |
| 614 | -inserts or adds the elements of a vector into a matrix column. | |
| 615 | -Note that no row insertion routines have been implemented (so far) | |
| 616 | -since they would be less efficient (recall that all matrix types are | |
| 617 | -stored in column-major format). | |
| 618 | - | |
| 619 | -Conversion from one storage type to another is performed using | |
| 620 | -\begin{verbatim} | |
| 621 | - B = A.convert_to_full(); // Converts A -> GMatrix | |
| 622 | - B = A.convert_to_sym(); // Converts A -> GSymMatrix | |
| 623 | - B = A.convert_to_sparse(); // Converts A -> GSparseMatrix | |
| 624 | -\end{verbatim} | |
| 625 | -Note that {\tt convert\_to\_sym()} can only be applied to a matrix that | |
| 626 | -is indeed symmetric. | |
| 627 | - | |
| 628 | -The transpose of a matrix can be obtained by using one of | |
| 629 | -\begin{verbatim} | |
| 630 | - A.transpose(); // Transpose method | |
| 631 | - B = transpose(A); // Transpose function | |
| 632 | -\end{verbatim} | |
| 633 | - | |
| 634 | -The absolute value of a matrix is provided by | |
| 635 | -\begin{verbatim} | |
| 636 | - B = fabs(A); // B = |A| | |
| 637 | -\end{verbatim} | |
| 638 | - | |
| 639 | - | |
| 640 | -%---------------------------------------------------------------------------- | |
| 641 | -\paragraph{Matrix factorisations} | |
| 642 | - | |
| 643 | -A general tool of numeric matrix calculs is factorisation. | |
| 644 | - | |
| 645 | -Solve linear equation {\tt Ax = b}. | |
| 646 | -Inverse a matrix (by solving successively {\tt Ax = e}, where {\tt e} | |
| 647 | -are the unit vectors for all dimensions). | |
| 648 | - | |
| 649 | -For symmetric and positive definite matrices the most efficient | |
| 650 | -factorisation is the Cholesky decomposition. | |
| 651 | -The following code fragment illustrates the usage: | |
| 652 | -\begin{verbatim} | |
| 653 | - GMatrix A(n_rows, n_cols}; | |
| 654 | - GVector x(n_rows}; | |
| 655 | - GVector b(n_rows}; | |
| 656 | - ... | |
| 657 | - A.cholesky_decompose(); // Perform Cholesky factorisation | |
| 658 | - x = A.cholesky_solver(b); // Solve Ax=b for x | |
| 659 | -\end{verbatim} | |
| 660 | -Note that once the function {\tt A.cholesky\_decompose()} has been | |
| 661 | -applied, the original matrix content has been replaced by its Cholesky | |
| 662 | -decomposition. | |
| 663 | -Since the Cholesky decomposition can be performed inplace (i.e. | |
| 664 | -without the allocation of additional memory to hold the result), the | |
| 665 | -matrix replacement is most memory economic. | |
| 666 | -In case that the original matrix should be kept, one may either copy | |
| 667 | -it before into another {\tt GMatrix} object or use the function | |
| 668 | -\begin{verbatim} | |
| 669 | - GMatrix L = cholesky_decompose(A); | |
| 670 | - x = L.cholesky_solver(b); | |
| 671 | -\end{verbatim} | |
| 672 | - | |
| 673 | -A symmetric and positif definite matrix can be inverted using the | |
| 674 | -Cholesky decomposition using | |
| 675 | -\begin{verbatim} | |
| 676 | - A.cholesky_invert(); // Inverse matrix using Cholesky fact. | |
| 677 | -\end{verbatim} | |
| 678 | -Alternatively, the function | |
| 679 | -\begin{verbatim} | |
| 680 | - GMatrix A_inv = cholesky_invert(A); | |
| 681 | -\end{verbatim} | |
| 682 | -may be used. | |
| 683 | - | |
| 684 | -The Cholesky decomposition, solver and inversion | |
| 685 | -routines may also be applied to matrices that contain rows or | |
| 686 | -columns that are filled by zeros. | |
| 687 | -In this case the functions provide the option to (logically) | |
| 688 | -compress the matrices by skipping the zero rows and columns during | |
| 689 | -the calculation. | |
| 690 | - | |
| 691 | -For compressed matrix Cholesky factorisation, only the non-zero rows | |
| 692 | -and columns have to be symmetric and positive definite. | |
| 693 | -In particular, the full matrix may even be non-symmetric. | |
| 694 | - | |
| 695 | - | |
| 696 | -%---------------------------------------------------------------------------- | |
| 697 | -\paragraph{Sparse matrixes} | |
| 698 | - | |
| 699 | -The only exception that does not work is | |
| 700 | -\begin{verbatim} | |
| 701 | - GSparseMatrix A(10,10); | |
| 702 | - A(0,0) = A(1,1) = A(2,2) = 1.0; // WRONG: Cannot assign multiple at once | |
| 703 | -\end{verbatim} | |
| 704 | -In this case the value {\tt 1.0} is only assigned to the last | |
| 705 | -element, i.e. {\tt A(2,2)}, the other elements will remain | |
| 706 | -{\tt 0}. | |
| 707 | -This feature has to do with the way how the compiler translates | |
| 708 | -the code and how \this\ implements sparse matrix filling. | |
| 709 | -{\tt GSparseMatrix} provides a pointer for a new element to be | |
| 710 | -filled. | |
| 711 | -Since there is only one such {\em fill pointer}, only one element can | |
| 712 | -be filled at once in a statement. | |
| 713 | -{\bf So it is strongly advised to avoid multiple matrix element | |
| 714 | -assignment in a single row.} | |
| 715 | -Better write the above code like | |
| 716 | -\begin{verbatim} | |
| 717 | - GSparseMatrix A; | |
| 718 | - A(0,0) = 1.0; | |
| 719 | - A(1,1) = 1.0; | |
| 720 | - A(2,2) = 1.0; | |
| 721 | -\end{verbatim} | |
| 722 | -This way, element assignment works fine. | |
| 723 | - | |
| 724 | -Inverting a sparse matrix produces in general a full matrix, so the | |
| 725 | -inversion function should be used with caution. | |
| 726 | -Note that a full matrix that is stored in sparse format takes roughly | |
| 727 | -twice the memory than a normal {\tt GMatrix} object. | |
| 728 | -If nevertheless the inverse of a sparse matrix should be examined, it | |
| 729 | -is recommended to perform the analysis column-wise: | |
| 730 | -\begin{verbatim} | |
| 731 | - GSparseMatrix A(rows,cols); // Allocate sparse matrix | |
| 732 | - GVector unit(rows); // Allocate vector | |
| 733 | - ... | |
| 734 | - A.cholesky_decompose(); // Factorise matrix | |
| 735 | - | |
| 736 | - // Column-wise solving the matrix equation | |
| 737 | - for (int col = 0; col < cols; ++col) { | |
| 738 | - unit(col) = 1.0; // Set unit vector | |
| 739 | - GVector x = cholesky_solver(unit); // Get column x of inverse | |
| 740 | - ... | |
| 741 | - unit(col) = 0.0; // Clear unit vector for next round | |
| 742 | - } | |
| 743 | -\end{verbatim} | |
| 744 | - | |
| 745 | - | |
| 746 | -%---------------------------------------------------------------------------- | |
| 747 | -\paragraph{Filling sparse matrixes} | |
| 748 | -\label{sec:matrix:filling} | |
| 749 | - | |
| 750 | -The filling of a sparse matrix is a tricky issue since the storage | |
| 751 | -of the elements depends on their distribution in the matrix. | |
| 752 | -If one would know beforehand this distribution, sparse matrix filling | |
| 753 | -would be easy and fast. | |
| 754 | -In general, however, the distribution is not known a priori, and | |
| 755 | -matrix filling may become a quite time consuming task. | |
| 756 | - | |
| 757 | -If a matrix has to be filled element by element, the access through | |
| 758 | -the operator | |
| 759 | -\begin{verbatim} | |
| 760 | - m(row,col) = value; | |
| 761 | -\end{verbatim} | |
| 762 | -may be mandatory. | |
| 763 | -In principle, if a new element is inserted into a matrix a new memory | |
| 764 | -cell has to be allocated for this element, and other elements may be | |
| 765 | -moved. | |
| 766 | -Memory allocation is quite time consuming, and to reduce the overhead, | |
| 767 | -{\tt GSparseMatrix} can be configured to allocate memory in bunches. | |
| 768 | -By default, each time more matrix memory is needed, {\tt GSparseMatrix} | |
| 769 | -allocates 512 cells at once (or 6144 Bytes since each element requires | |
| 770 | -a {\tt double} and a {\tt int} storage location). | |
| 771 | -If this amount of memory is not adequat one may change this value by | |
| 772 | -using | |
| 773 | -\begin{verbatim} | |
| 774 | - m.set_mem_block(size); | |
| 775 | -\end{verbatim} | |
| 776 | -where {\tt size} is the number of matrix elements that should be | |
| 777 | -allocated at once (corresponding to a total memory of | |
| 778 | -$12 \times {\tt size}$ Bytes). | |
| 779 | - | |
| 780 | -Alternatively, a matrix may be filled column-wise using the functions | |
| 781 | -\begin{verbatim} | |
| 782 | - m.insert_col(vector,col); // Insert a vector in column | |
| 783 | - m.add_col(vector,col); // Add content of a vector to column | |
| 784 | -\end{verbatim} | |
| 785 | -While {\tt insert\_col} sets the values of column {\tt col} (deleting | |
| 786 | -thus any previously existing entries), {\tt add\_col} adds the content | |
| 787 | -of {\tt vector} to all elements of column {\tt col}. | |
| 788 | -Using these functions is considerably more rapid than filling individual | |
| 789 | -values. | |
| 790 | - | |
| 791 | -Still, if the matrix is big (i.e. severeal thousands of rows and | |
| 792 | -columns), filling individual columns may still be slow. | |
| 793 | -To speed-up dynamical matrix filling, an internal fill-stack has been | |
| 794 | -implemented in {\tt GSparseMatrix}. | |
| 795 | -Instead of inserting values column-by-column, the columns are stored | |
| 796 | -in a stack and filled into the matrix once the stack is full. | |
| 797 | -This reduces the number of dynamic memory allocations to let the | |
| 798 | -matrix grow as it is built. | |
| 799 | -By default, the internal stack is disabled. | |
| 800 | -The stack can be enabled and used as follows: | |
| 801 | -\begin{verbatim} | |
| 802 | - m.stack_init(size, entries); // Initialise stack | |
| 803 | - ... | |
| 804 | - m.add_col(vector,col); // Add columns | |
| 805 | - ... | |
| 806 | - m.stack_destroy(); // Flush and destory stack | |
| 807 | -\end{verbatim} | |
| 808 | -The method {\tt stack\_init} initialises a stack with a number of | |
| 809 | -{\tt size} elements and a maximum of {\tt entries} columns. | |
| 810 | -The larger the values {\tt size} and {\tt entries} are chosen, the | |
| 811 | -more efficient the stack works. | |
| 812 | -The total amount of memory of the stack can be estimated as | |
| 813 | -$12 \times {\tt size} + 8 \times {\tt entries}$ Bytes. | |
| 814 | -If a rough estimate of the total number of non-zero elements is | |
| 815 | -available it is recommended to set {\tt size} to this value. | |
| 816 | -As a rule of thumb, {\tt size} should be at least of the dimension of | |
| 817 | -either the number of rows or the number of columns of the matrix | |
| 818 | -(take the maximum of both). | |
| 819 | -{\tt entries} is best set to the number of columns of the matrix. | |
| 820 | -If memory limits are an issue smaller values may be set, but if the | |
| 821 | -values are too small, the speed increase may become negligible (or | |
| 822 | -stack-filling may even become slower than normal filling). | |
| 823 | - | |
| 824 | -Stack-filling only works with the method {\tt add\_col}. | |
| 825 | -Note also that filling sub-sequently the same column leads to stack | |
| 826 | -flushing. | |
| 827 | -In the code | |
| 828 | -\begin{verbatim} | |
| 829 | - for (int col = 0; col < 100; ++col) { | |
| 830 | - column = 0.0; // Reset column | |
| 831 | - column(col) = col; // Set column | |
| 832 | - m.add_col(column,col); // Add column | |
| 833 | - } | |
| 834 | -\end{verbatim} | |
| 835 | -stack flushing occurs in each loop, and consequently, the | |
| 836 | -stack-filling approach will be not very efficient (it | |
| 837 | -would probably be even slover than normal filling). | |
| 838 | -If successive operations are to be performed on columns, | |
| 839 | -it is better to perform them before adding. | |
| 840 | -The code | |
| 841 | -\begin{verbatim} | |
| 842 | - column = 0.0; // Reset column | |
| 843 | - for (int col = 0; col < 100; ++col) | |
| 844 | - column(col) = col; // Set column | |
| 845 | - m.add_col(column,col); // Add column | |
| 846 | -\end{verbatim} | |
| 847 | -would be far more efficient. | |
| 848 | - | |
| 849 | -A avoidable overhead occurs for the case that the column to be added | |
| 850 | -is sparse. | |
| 851 | -The vector may contain many zeros, and {\tt GSparseMatrix} has to | |
| 852 | -filter them out. | |
| 853 | -If the sparsity of the column is known, this overhead can be avoided | |
| 854 | -by directly passing a compressed array to {\tt add\_col}: | |
| 855 | -\begin{verbatim} | |
| 856 | - int number = 5; // 5 elements in array | |
| 857 | - double* values = new double[number]; // Allocate values | |
| 858 | - int* rows = new int[number]; // Allocate row index | |
| 859 | - ... | |
| 860 | - m.stack_init(size, entries); // Initialise stack | |
| 861 | - ... | |
| 862 | - for (int i = 0; i < number; ++i) { // Initialise array | |
| 863 | - values[i] = ... // ... set values | |
| 864 | - rows[i] = ... // ... set row indices | |
| 865 | - } | |
| 866 | - ... | |
| 867 | - m.add_col(values,rows,number,col); // Add array | |
| 868 | - ... | |
| 869 | - m.stack_destroy(); // Flush and destory stack | |
| 870 | - ... | |
| 871 | - delete [] values; // Free array | |
| 872 | - delete [] rows; | |
| 873 | -\end{verbatim} | |
| 874 | - | |
| 875 | -The method {\tt add\_col} calls the method {\tt stack\_push\_column} | |
| 876 | -for stack filling. | |
| 877 | -{\tt add\_col} is more general than {\tt stack\_push\_column} in that | |
| 878 | -it decides which of stack- or direct filling is more adequate. | |
| 879 | -In particular, {\tt stack\_push\_column} may refuse pushing a column | |
| 880 | -onto the stack if there is not enough space. | |
| 881 | -In that case, {\tt stack\_push\_column} returns a non-zero value that | |
| 882 | -corresponds to the number of non-zero elements in the vector that | |
| 883 | -should be added. | |
| 884 | -However, it is recommended to not use {\tt stack\_push\_column} and | |
| 885 | -call instead {\tt add\_col}. | |
| 886 | - | |
| 887 | -The method {\tt stack\_destroy} is used to flush and destroy the | |
| 888 | -stack. | |
| 889 | -After this call the stack memory is liberated. | |
| 890 | -If the stack should be flushed without destroying it, the method | |
| 891 | -{\tt stack\_flush} may be used: | |
| 892 | -\begin{verbatim} | |
| 893 | - m.stack_init(size, entries); // Initialise stack | |
| 894 | - ... | |
| 895 | - m.add_col(vector,col); // Add columns | |
| 896 | - ... | |
| 897 | - m.stack_flush(); // Simply flush stack | |
| 898 | -\end{verbatim} | |
| 899 | -Once flushed, the stack can be filled anew. | |
| 900 | - | |
| 901 | -Note that stack flushing is not automatic! | |
| 902 | -This means, if one trys to use a matrix for calculs without flushing, | |
| 903 | -the calculs may be wrong. | |
| 904 | -{\bf If a stack is used for filling, always flush the stack before using | |
| 905 | -the matrix.} | |
| 906 | - | |
| 907 | - | |
| 908 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 909 | -% Code reference | |
| 910 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 911 | -\clearpage | |
| 912 | -\section{Code reference} | |
| 913 | - | |
| 914 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 915 | -\subsection{{\tt GApplication}} | |
| 916 | - | |
| 917 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 918 | -\subsection{{\tt GEbounds}} | |
| 919 | - | |
| 920 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 921 | -\subsection{{\tt GEnergy}} | |
| 922 | - | |
| 923 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 924 | -\subsection{{\tt GEvent} \small[abstract]} | |
| 925 | -{\tt GEvent} implements the abstract interface for a gamma-ray event. | |
| 926 | -It handles both event atoms (\ref{GEventAtom}) and event bins (\ref{GEventBin}). | |
| 927 | -\begin{verbatim} | |
| 928 | - /* Constructors */ | |
| 929 | - GEvent(void); | |
| 930 | - GEvent(const GEvent& event); | |
| 931 | - | |
| 932 | - /* Operators */ | |
| 933 | - GEvent& operator= (const GEvent& event); | |
| 934 | - | |
| 935 | - /* Methods */ | |
| 936 | - void clear(void); // Clear event | |
| 937 | - GEvent* clone(void) const; // Clone event | |
| 938 | - double size(void) const; // Returns size of event bin | |
| 939 | - const GInstDir& dir(void) const; // Returns event's instrument direction | |
| 940 | - const GEnergy& energy(void) const; // Returns event energy | |
| 941 | - const GTime& time(void) const; // Returns event time | |
| 942 | - double counts(void) const; // Returns number of counts in event | |
| 943 | - double error(void) const; // Returns uncertainty in number of counts in event | |
| 944 | - bool isatom(void) const; // Event is an atom | |
| 945 | - bool isbin(void) const; // Event is a bin | |
| 946 | -\end{verbatim} | |
| 947 | - | |
| 948 | - | |
| 949 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 950 | -\subsection{{\tt GEventAtom} \small[abstract]} | |
| 951 | -\label{GEventAtom} | |
| 952 | -{\tt GEventAtom} derives from {GEvent} and implements the abstract interface for an event | |
| 953 | -atom. | |
| 954 | -Each atom is characterised by an instrument direction, an energy and an event arrival time. | |
| 955 | -\begin{verbatim} | |
| 956 | - /* Constructors */ | |
| 957 | - GEventAtom(void); | |
| 958 | - GEventAtom(const GEventAtom& atom); | |
| 959 | - | |
| 960 | - /* Operators */ | |
| 961 | - GEventAtom& operator= (const GEventAtom& atom); | |
| 962 | - | |
| 963 | - /* Methods */ | |
| 964 | - void clear(void); // Clear event | |
| 965 | - GEventAtom* clone(void) const; // Clone event | |
| 966 | - double size(void) const; // Returns 1.0 | |
| 967 | - const GInstDir& dir(void) const; // Returns event's instrument direction | |
| 968 | - const GEnergy& energy(void) const; // Returns event energy | |
| 969 | - const GTime& time(void) const; // Returns event time | |
| 970 | - double counts(void) const; // Returns 1.0 | |
| 971 | - double error(void) const; // Returns 0.0 | |
| 972 | - bool isatom(void) const; // Returns true | |
| 973 | - bool isbin(void) const; // Returns false | |
| 974 | -\end{verbatim} | |
| 975 | - | |
| 976 | - | |
| 977 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 978 | -\subsection{{\tt GEventBin} \small[abstract]} | |
| 979 | -\label{GEventBin} | |
| 980 | -{\tt GEventBin} derives from {GEvent} and implements the abstract interface for an event | |
| 981 | -bin. | |
| 982 | -Each bin is characterised by a mean instrument direction, a mean energy and a | |
| 983 | -mean event arrival time. | |
| 984 | -The size of the event bin is the solid angle subtended by the event bin times the energy | |
| 985 | -width times the time interval that is covered. | |
| 986 | -Multiplication of the event occurence probability with the bin size provides the expected | |
| 987 | -number of counts in a bin. | |
| 988 | -\begin{verbatim} | |
| 989 | - /* Constructors */ | |
| 990 | - GEventBin(void); | |
| 991 | - GEventBin(const GEventBin& bin); | |
| 992 | - | |
| 993 | - /* Operators */ | |
| 994 | - GEventBin& operator= (const GEventBin& bin); | |
| 995 | - | |
| 996 | - /* Methods */ | |
| 997 | - void clear(void); // Clear event bin | |
| 998 | - GEventBin* clone(void) const; // Clone event bin | |
| 999 | - double size(void) const; // Returns size of event bin | |
| 1000 | - const GInstDir& dir(void) const; // Returns bin's mean instrument direction | |
| 1001 | - const GEnergy& energy(void) const; // Returns mean bin energy | |
| 1002 | - const GTime& time(void) const; // Returns mean bin time | |
| 1003 | - double counts(void) const; // Returns number of events in bin | |
| 1004 | - double error(void) const; // Returns uncertainty in number of events in bin | |
| 1005 | - bool isatom(void) const; // Returns false | |
| 1006 | - bool isbin(void) const; // Returns true | |
| 1007 | -\end{verbatim} | |
| 1008 | - | |
| 1009 | - | |
| 1010 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1011 | -\subsection{{\tt GEvents} \small[abstract]} | |
| 1012 | -Events are collected in the abstract container class {\tt GEvents}. | |
| 1013 | -This class handles both event lists (\ref{GEventList}) and event cubes (\ref{GEventCube}). | |
| 1014 | -\begin{verbatim} | |
| 1015 | - /* Constructors */ | |
| 1016 | - GEvents(void); | |
| 1017 | - GEvents(const GEvents& events); | |
| 1018 | - | |
| 1019 | - /* Operators */ | |
| 1020 | - GEvents& operator= (const GEvents& events); | |
| 1021 | - | |
| 1022 | - /* Methods */ | |
| 1023 | - void clear(void); // Clear events | |
| 1024 | - GEvents* clone(void) const; // Clone events | |
| 1025 | - int size(void) const; // Returns number of atoms or bins | |
| 1026 | - void load(const std::string& filename); // Load events from file | |
| 1027 | - GEvent* pointer(int index); // Returns pointer on atom or bin | |
| 1028 | - int number(void) const; // Returns number of events | |
| 1029 | - bool islist(void) const; // Object is event list | |
| 1030 | - bool iscube(void) const; // Object is event cube | |
| 1031 | - iterator begin(void); // Returns iterator on first atom or bin | |
| 1032 | - iterator end(void); // Returns iterator on last atom or bin | |
| 1033 | -\end{verbatim} | |
| 1034 | -{\tt GEvents} implements an event iterator as a nested class | |
| 1035 | -{\tt GEvents::iterator} with the following definition: | |
| 1036 | -\begin{verbatim} | |
| 1037 | - /* Constructor */ | |
| 1038 | - iterator(void); | |
| 1039 | - iterator(GEvents *events); | |
| 1040 | - | |
| 1041 | - /* Operators */ | |
| 1042 | - iterator& operator++(void); | |
| 1043 | - iterator operator++(int junk); | |
| 1044 | - bool operator==(const iterator& it) const; | |
| 1045 | - bool operator!=(const iterator& it) const; | |
| 1046 | - GEvent& operator*(void); | |
| 1047 | - GEvent* operator->(void); | |
| 1048 | -\end{verbatim} | |
| 1049 | - | |
| 1050 | - | |
| 1051 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1052 | -\subsection{{\tt GEventList} \small[abstract]} | |
| 1053 | -\label{GEventList} | |
| 1054 | -{\tt GEventList} is an abstract container class for event atoms. | |
| 1055 | -\begin{verbatim} | |
| 1056 | - /* Constructors */ | |
| 1057 | - GEventList(void); | |
| 1058 | - GEventList(const GEventList& list); | |
| 1059 | - | |
| 1060 | - /* Operators */ | |
| 1061 | - GEventList& operator= (const GEventList& list); | |
| 1062 | - | |
| 1063 | - /* Methods */ | |
| 1064 | - void clear(void); // Clear event list | |
| 1065 | - GEventList* clone(void) const; // Clone event list | |
| 1066 | - int size(void) const; // Returns number of events in list | |
| 1067 | - void load(const std::string& filename); // Load list from file | |
| 1068 | - GEventAtom* pointer(int index); // Returns pointer on event atom | |
| 1069 | - int number(void) const; // Returns number of events in list | |
| 1070 | - bool islist(void) const; // Returns true | |
| 1071 | - bool iscube(void) const; // Returns false | |
| 1072 | - | |
| 1073 | - /* Friends */ | |
| 1074 | - std::ostream& operator<< (std::ostream& os, const GEventList& list); | |
| 1075 | -\end{verbatim} | |
| 1076 | - | |
| 1077 | - | |
| 1078 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1079 | -\subsection{{\tt GEventCube} \small[abstract]} | |
| 1080 | -\label{GEventCube} | |
| 1081 | -{\tt GEventCube} is an abstract container class for event bins. | |
| 1082 | -\begin{verbatim} | |
| 1083 | - /* Constructors */ | |
| 1084 | - GEventCube(void); | |
| 1085 | - GEventCube(const GEventCube& cube); | |
| 1086 | - | |
| 1087 | - /* Operators */ | |
| 1088 | - GEventCube& operator= (const GEventCube& cube); | |
| 1089 | - | |
| 1090 | - /* Methods */ | |
| 1091 | - void clear(void); // Clear event cube | |
| 1092 | - GEventCube* clone(void) const; // Clone event cube | |
| 1093 | - int size(void) const; // Returns number of bins in cube | |
| 1094 | - void load(const std::string& filename); // Load cube from file | |
| 1095 | - GEventBin* pointer(int index); // Returns pointer on bin | |
| 1096 | - int number(void) const; // Returns number of events in cube | |
| 1097 | - int dim(void) const; // Returns dimension of cube | |
| 1098 | - int naxis(int axis) const; // Returns dimension of cube axis | |
| 1099 | - bool islist(void) const; // Returns false | |
| 1100 | - bool iscube(void) const; // Returns true | |
| 1101 | - | |
| 1102 | - /* Friends */ | |
| 1103 | - std::ostream& operator<< (std::ostream& os, const GEventCube& cube); | |
| 1104 | -\end{verbatim} | |
| 1105 | - | |
| 1106 | - | |
| 1107 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1108 | -\subsection{{\tt GFits}} | |
| 1109 | - | |
| 1110 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1111 | -\subsection{{\tt GGti}} | |
| 1112 | - | |
| 1113 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1114 | -\subsection{{\tt GInstDir}} | |
| 1115 | - | |
| 1116 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1117 | -\subsection{{\tt GIntegral}} | |
| 1118 | - | |
| 1119 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1120 | -\subsection{{\tt GIntegrand}} | |
| 1121 | - | |
| 1122 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1123 | -\subsection{{\tt GLog}} | |
| 1124 | - | |
| 1125 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1126 | -\subsection{{\tt GMatrix}} | |
| 1127 | - | |
| 1128 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1129 | -\newpage | |
| 1130 | -\subsection{{\tt GModel}} | |
| 1131 | - | |
| 1132 | -\paragraph{Class definition:} | |
| 1133 | -\begin{verbatim} | |
| 1134 | -/* Constructors */ | |
| 1135 | -GModel(void); // Creates empty model | |
| 1136 | -GModel(const GModel& model); // Creates copy of model | |
| 1137 | -GModel(const GModelSpatial& spatial, // Creates model from spatial and | |
| 1138 | - const GModelSpectral& spectral); // spectral components | |
| 1139 | -GModel(const GXmlElement& spatial, // Creates model from spatial and | |
| 1140 | - const GXmlElement& spectral); // spectral XML elements | |
| 1141 | - | |
| 1142 | -/* Operators */ | |
| 1143 | -GModelPar& operator() (int index); // Returns reference to parameter | |
| 1144 | -const GModelPar& operator() (int index) const; // Returns reference to parameter | |
| 1145 | -GModel& operator= (const GModel& model); // Assign model | |
| 1146 | - | |
| 1147 | -/* Methods */ | |
| 1148 | -void clear(void); // Clear model | |
| 1149 | -GModel* clone(void) const; // Clone model | |
| 1150 | -int size(void) const; // Returns number of parameters | |
| 1151 | -std::string name(void) const; // Returns model name | |
| 1152 | -void name(const std::string& name); // Set model name | |
| 1153 | -GModelSpatial* spatial(void) const; // Returns spatial component | |
| 1154 | -GModelSpectral* spectral(void) const; // Returns spectral component | |
| 1155 | -GModelTemporal* temporal(void) const; // Returns temporal component | |
| 1156 | -double value(const GSkyDir& srcDir, // Returns model value | |
| 1157 | - const GEnergy& srcEng, | |
| 1158 | - const GTime& srcTime); | |
| 1159 | -GVector gradients(const GSkyDir& srcDir, // Returns model gradient | |
| 1160 | - const GEnergy& srcEng, | |
| 1161 | - const GTime& srcTime); | |
| 1162 | -double eval(const GEvent& event, // Evaluates model for an event | |
| 1163 | - const GObservation& obs); | |
| 1164 | -double eval_gradients(const GEvent& event, // Evaluates model and gradients | |
| 1165 | - const GObservation& obs); // for an event | |
| 1166 | -bool isvalid(const std::string& name) const; // Model applies to instrument? | |
| 1167 | -std::string print(void) const; // Print model | |
| 1168 | -\end{verbatim} | |
| 1169 | - | |
| 1170 | -\paragraph{Description:} | |
| 1171 | -The {\tt GModel} class implements the factorized source model | |
| 1172 | -\begin{equation} | |
| 1173 | -S(\vec{p}, E, t) = M(\vec{p}) \times P(E) \times V(t) | |
| 1174 | -\end{equation} | |
| 1175 | -where | |
| 1176 | -\begin{itemize} | |
| 1177 | -\item[] $M(\vec{p})$ is a map of the intensity distribution (in units of sr$^{-1}$), | |
| 1178 | -\item[] $P(E)$ is the source spectrum (in units of photons cm$^{-2}$ s$^{-1}$ MeV$^{-1}$), and | |
| 1179 | -\item[] $V(t)$ is a source modulation function (unitless), | |
| 1180 | -\item[] $\vec{p}$ is the true photon arrival direction, | |
| 1181 | -\item[] $E$ is the true photon energy, and | |
| 1182 | -\item[] $t$ is the true photon arrival time. | |
| 1183 | -\end{itemize} | |
| 1184 | - | |
| 1185 | - | |
| 1186 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1187 | -\newpage | |
| 1188 | -\subsection{{\tt GModelPar}} | |
| 1189 | - | |
| 1190 | -\paragraph{Class definition:} | |
| 1191 | -\begin{verbatim} | |
| 1192 | -/* Constructors */ | |
| 1193 | -GModelPar(void); // Creates empty parameter | |
| 1194 | -GModelPar(const GModelPar& par); // Creates copy of parameter | |
| 1195 | - | |
| 1196 | -/* Operators */ | |
| 1197 | -GModelPar& operator= (const GModelPar& par); // Assign parameter | |
| 1198 | - | |
| 1199 | -/* Methods */ | |
| 1200 | -std::string name(void) const; // Returns name | |
| 1201 | -std::string unit(void) const; // Returns unit | |
| 1202 | -double real_value(void) const; // Returns true value | |
| 1203 | -double real_error(void) const; // Returns true error | |
| 1204 | -double real_gradient(void) const; // Returns true gradient | |
| 1205 | -double real_min(void) const; // Returns true minimum | |
| 1206 | -double real_max(void) const; // Returns true maximum | |
| 1207 | -double value(void) const; // Returns value | |
| 1208 | -double error(void) const; // Returns error | |
| 1209 | -double gradient(void) const; // Returns gradient | |
| 1210 | -double min(void) const; // Returns minimum | |
| 1211 | -double max(void) const; // Returns maximum | |
| 1212 | -double scale(void) const; // Returns scale factor | |
| 1213 | -bool isfree(void) const; // Signals that parameter is free | |
| 1214 | -bool hasmin(void) const; // Signals that parameter has minimum | |
| 1215 | -bool hasmax(void) const; // Signals that parameter has maximum | |
| 1216 | -void name(const std::string& name); // Set name | |
| 1217 | -void unit(const std::string& unit); // Set unit | |
| 1218 | -void value(const double& value); // Set value | |
| 1219 | -void error(const double& error); // Set error | |
| 1220 | -void gradient(const double& gradient); // Set gradient | |
| 1221 | -void min(const double& min); // Set minimum | |
| 1222 | -void max(const double& max); // Set maximum | |
| 1223 | -void scale(const double& scale); // Set scale factor | |
| 1224 | -void range(const double& min, const double& max); // Set minimum and maximum | |
| 1225 | -void remove_min(void); // Remove minimum | |
| 1226 | -void remove_max(void); // Remove maximum | |
| 1227 | -void remove_range(void); // Remove minimum and maximum | |
| 1228 | -void free(void); // Set parameter free | |
| 1229 | -void fix(void); // Fix parameter | |
| 1230 | -void read(const GXmlElement& xml); // Read parameter from XML element | |
| 1231 | -void write(GXmlElement& xml) const; // Write parameter into XML element | |
| 1232 | -std::string print(void) const; // Print parameter | |
| 1233 | -\end{verbatim} | |
| 1234 | - | |
| 1235 | -\paragraph{Description:} | |
| 1236 | -This class implements a model parameter. | |
| 1237 | -The true parameter value is given by | |
| 1238 | -\begin{equation} | |
| 1239 | -{\tt true} = {\tt scale} \times {\tt value} | |
| 1240 | -\end{equation} | |
| 1241 | -and is accessed through the {\tt real\_} methods. | |
| 1242 | -The optimizer will only affect the {\tt value} part of the parameter. | |
| 1243 | - | |
| 1244 | - | |
| 1245 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1246 | -\newpage | |
| 1247 | -\subsection{{\tt GModels}} | |
| 1248 | - | |
| 1249 | -\paragraph{Class definition:} | |
| 1250 | -\begin{verbatim} | |
| 1251 | -/* Constructors */ | |
| 1252 | -GModels(void); // Creates empty model container | |
| 1253 | -GModels(const GModels& models); // Creates copy of container | |
| 1254 | -GModels(const std::string& filename); // Creates container from XML file | |
| 1255 | - | |
| 1256 | -/* Operators */ | |
| 1257 | -GModel& operator() (int index); // Returns reference to model | |
| 1258 | -const GModel& operator() (int index) const; // Returns reference to model | |
| 1259 | -GModels& operator= (const GModels& models); // Assign model container | |
| 1260 | - | |
| 1261 | -/* Methods */ | |
| 1262 | -void clear(void); // Clear models | |
| 1263 | -GModels* clone(void) const; // Clone models | |
| 1264 | -int size(void) const; // Returns number of models in container | |
| 1265 | -void append(const GModel& model); // Append model to container | |
| 1266 | -void load(const std::string& filename); // Load models from XML file | |
| 1267 | -void save(const std::string& filename) const; // Save models into XML file | |
| 1268 | -void read(const GXml& xml); // Read models from XML document | |
| 1269 | -void write(GXml& xml) const; // Write models into XML document | |
| 1270 | -int npars(void) const; // Returns total number of parameters | |
| 1271 | -int nfree(void) const; // Returns total number of free parameters | |
| 1272 | -GModelPar* par(int index) const; // Returns pointer to model parameter | |
| 1273 | -double value(const GSkyDir& srcDir, // Returns model value | |
| 1274 | - const GEnergy& srcEng, | |
| 1275 | - const GTime& srcTime); | |
| 1276 | -double eval(const GEvent& event, // Evaluates models for an event | |
| 1277 | - const GObservation& obs); | |
| 1278 | -double eval_gradients(const GEvent& event, // Evaluates models and parameter | |
| 1279 | - const GObservation& obs); // gradients for an event | |
| 1280 | -std::string print(void) const; // Print model | |
| 1281 | -\end{verbatim} | |
| 1282 | - | |
| 1283 | -\paragraph{Description:} | |
| 1284 | -Container class for {\tt GModel} source models. | |
| 1285 | - | |
| 1286 | - | |
| 1287 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1288 | -\newpage | |
| 1289 | -\subsection{{\tt GModelSpatial} \small[abstract]} | |
| 1290 | - | |
| 1291 | -\paragraph{Class definition:} | |
| 1292 | -\begin{verbatim} | |
| 1293 | -/* Constructors */ | |
| 1294 | -GModelSpatial(void); // Creates empty component | |
| 1295 | -GModelSpatial(const GModelSpatial& model); // Creates copy of component | |
| 1296 | - | |
| 1297 | -/* Operators */ | |
| 1298 | -GModelPar& operator() (int index); // Access model parameter | |
| 1299 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1300 | -GModelSpatial& operator= (const GModelSpatial& model); // Assign component | |
| 1301 | - | |
| 1302 | -/* Methods */ | |
| 1303 | -void clear(void); // Clear component | |
| 1304 | -GModelSpatial* clone(void) const; // Clone component | |
| 1305 | -int size(void) const; // Returns number of model parameters | |
| 1306 | -std::string type(void) const; // Returns type of component | |
| 1307 | -double eval(const GSkyDir& srcDir); // Evaluate component | |
| 1308 | -double eval_gradients(const GSkyDir& srcDir); // Evaluate component and gradients | |
| 1309 | -void read(const GXmlElement& xml); // Read component from XML element | |
| 1310 | -void write(GXmlElement& xml) const; // Write component into XML element | |
| 1311 | -bool isptsource(void) const; // Signals if component is point source | |
| 1312 | -std::string print(void) const; // Print component | |
| 1313 | -\end{verbatim} | |
| 1314 | - | |
| 1315 | -\paragraph{Description:} | |
| 1316 | -Implements the spatial component $M(\vec{p})$ of the factorized source model. | |
| 1317 | - | |
| 1318 | - | |
| 1319 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1320 | -\newpage | |
| 1321 | -\subsection{{\tt GModelSpatialPtsrc}} | |
| 1322 | - | |
| 1323 | -\paragraph{Class definition:} | |
| 1324 | -\begin{verbatim} | |
| 1325 | -/* Constructors */ | |
| 1326 | -GModelSpatialPtsrc(void); // Creates empty point source | |
| 1327 | -GModelSpatialPtsrc(const GSkyDir& dir); // Creates point source from sky direction | |
| 1328 | -GModelSpatialPtsrc(const GXmlElement& xml); // Creates point source from XML element | |
| 1329 | -GModelSpatialPtsrc(const GModelSpatialPtsrc& model); // Creates copy of point source | |
| 1330 | - | |
| 1331 | -/* Operators */ | |
| 1332 | -GModelPar& operator() (int index); // Access model parameter | |
| 1333 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1334 | -GModelSpatialPtsrc& operator= (const GModelSpatialPtsrc& model); // Assign point source | |
| 1335 | - | |
| 1336 | -/* Methods */ | |
| 1337 | -void clear(void); // Clear point source | |
| 1338 | -GModelSpatialPtsrc* clone(void) const; // Clone point source | |
| 1339 | -int size(void) const; // Returns 2 | |
| 1340 | -std::string type(void) const; // Returns "PointSource" | |
| 1341 | -double eval(const GSkyDir& srcDir); // Evaluate point source | |
| 1342 | -double eval_gradients(const GSkyDir& srcDir); // Evaluate point source and gradients | |
| 1343 | -void read(const GXmlElement& xml); // Read point source from XML element | |
| 1344 | -void write(GXmlElement& xml) const; // Write point source into XML element | |
| 1345 | -bool isptsource(void) const; // Returns true | |
| 1346 | -double ra(void) const; // Returns Right Ascension (deg) | |
| 1347 | -double dec(void) const; // Returns Declination (deg) | |
| 1348 | -GSkyDir dir(void) const; // Returns position of point source | |
| 1349 | -void dir(const GSkyDir& dir); // Set position of point source | |
| 1350 | -std::string print(void) const; // Print component | |
| 1351 | -\end{verbatim} | |
| 1352 | - | |
| 1353 | -\paragraph{Description:} | |
| 1354 | -Implements a point source model with parameters Right Ascension and Declination. | |
| 1355 | - | |
| 1356 | -The {\tt eval} method returns 1 if the specified position coincides with the position | |
| 1357 | -of the point source, 0 otherwise (coincidence is defined as the angular distance between | |
| 1358 | -the specified and the point source position being inferior to 0.1 arcseconds). | |
| 1359 | - | |
| 1360 | -The {\tt eval\_gradients} method sets both parameter gradients to 0. | |
| 1361 | - | |
| 1362 | - | |
| 1363 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1364 | -\newpage | |
| 1365 | -\subsection{{\tt GModelSpectral} \small[abstract]} | |
| 1366 | - | |
| 1367 | -\paragraph{Class definition:} | |
| 1368 | -\begin{verbatim} | |
| 1369 | -/* Constructors */ | |
| 1370 | -GModelSpectral(void); // Creates empty component | |
| 1371 | -GModelSpectral(const GModelSpectral& model); // Creates copy of component | |
| 1372 | - | |
| 1373 | -/* Operators */ | |
| 1374 | -GModelPar& operator() (int index); // Access model parameter | |
| 1375 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1376 | -GModelSpectral& operator= (const GModelSpectral& model); // Assign component | |
| 1377 | - | |
| 1378 | -/* Methods */ | |
| 1379 | -void clear(void); // Clear component | |
| 1380 | -GModelSpectral* clone(void) const; // Clone component | |
| 1381 | -int size(void) const; // Returns number of model parameters | |
| 1382 | -std::string type(void) const; // Returns type of component | |
| 1383 | -double eval(const GSkyDir& srcDir); // Evaluate component | |
| 1384 | -double eval_gradients(const GSkyDir& srcDir); // Evaluate component and gradients | |
| 1385 | -void read(const GXmlElement& xml); // Read component from XML element | |
| 1386 | -void write(GXmlElement& xml) const; // Write component into XML element | |
| 1387 | -std::string print(void) const; // Print component | |
| 1388 | -\end{verbatim} | |
| 1389 | - | |
| 1390 | -\paragraph{Description:} | |
| 1391 | -Implements the spectra component $P(E)$ of the factorized source model. | |
| 1392 | - | |
| 1393 | - | |
| 1394 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1395 | -\newpage | |
| 1396 | -\subsection{{\tt GModelSpectralPlaw}} | |
| 1397 | - | |
| 1398 | -\paragraph{Class definition:} | |
| 1399 | -\begin{verbatim} | |
| 1400 | -/* Constructors */ | |
| 1401 | -GModelSpectralPlaw(void); // Creates empty power law | |
| 1402 | -GModelSpectralPlaw(const double& norm,); // Creates power law from | |
| 1403 | - const double& index); // normalization and index | |
| 1404 | -GModelSpectralPlaw(const GXmlElement& xml); // Creates power law from XML element | |
| 1405 | -GModelSpectralPlaw(const GModelSpectralPlaw& model); // Creates copy of power law | |
| 1406 | - | |
| 1407 | -/* Operators */ | |
| 1408 | -GModelPar& operator() (int index); // Access model parameter | |
| 1409 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1410 | -GModelSpectralPlaw& operator= (const GModelSpectralPlaw& model); // Assign power law | |
| 1411 | - | |
| 1412 | -/* Methods */ | |
| 1413 | -void clear(void); // Clear power law | |
| 1414 | -GModelSpectralPlaw* clone(void) const; // Clone power law | |
| 1415 | -int size(void) const; // Returns 3 | |
| 1416 | -std::string type(void) const; // Returns "PowerLaw" | |
| 1417 | -double eval(const GEnergy& srcEng); // Evaluate power law | |
| 1418 | -double eval_gradients(const GEnergy& srcEng); // Evaluate power law and gradients | |
| 1419 | -void read(const GXmlElement& xml); // Read power law from XML element | |
| 1420 | -void write(GXmlElement& xml) const; // Write power law into XML element | |
| 1421 | -void autoscale(void); // Automatically scale normalization | |
| 1422 | -double norm(void) const; // Returns normalization | |
| 1423 | -double index(void) const; // Returns index | |
| 1424 | -double pivot(void) const; // Returns pivot energy (MeV) | |
| 1425 | -std::string print(void) const; // Print power law | |
| 1426 | -\end{verbatim} | |
| 1427 | - | |
| 1428 | -\paragraph{Description:} | |
| 1429 | -Implements power law spectral model | |
| 1430 | -\begin{equation} | |
| 1431 | -I(E) = {\tt norm} \, (E/{\tt pivot})^{{\tt index}} | |
| 1432 | -\end{equation} | |
| 1433 | -where | |
| 1434 | -${\tt norm}=n_s n_v$ is the normalization or prefactor (units ph/cm$^2$/s/MeV), | |
| 1435 | -${\tt index}=i_s i_v$ is the spectral index, and | |
| 1436 | -${\tt pivot}=p_s p_v$ is the pivot energy (units MeV). | |
| 1437 | -Note that each parameter is factorised into a scaling factor (indexed by $s$) and a | |
| 1438 | -parameter value (indexed by $v$). | |
| 1439 | -This function is evaluated using the {\tt eval} method. | |
| 1440 | - | |
| 1441 | -The {\tt eval\_gradients} methods computes in addition the partial derivatives of | |
| 1442 | -the parameter values: | |
| 1443 | -\begin{eqnarray} | |
| 1444 | -dI/dn_v &= & n_s (E/{\tt pivot})^{{\tt index}} \\ | |
| 1445 | -dI/di_v & = & {\tt norm} (E/{\tt pivot})^{{\tt index}} i_s \ln(E/{\tt pivot}) \\ | |
| 1446 | -dI/dp_v & = & {\tt norm} (E/{\tt pivot})^{{\tt index}} (-{\tt index}) / p_v | |
| 1447 | -\end{eqnarray} | |
| 1448 | - | |
| 1449 | - | |
| 1450 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1451 | -\newpage | |
| 1452 | -\subsection{{\tt GModelSpectralExpPlaw}} | |
| 1453 | - | |
| 1454 | -\paragraph{Class definition:} | |
| 1455 | -\begin{verbatim} | |
| 1456 | -/* Constructors */ | |
| 1457 | -GModelSpectralExpPlaw(void); // Creates empty cutoff power law | |
| 1458 | -GModelSpectralExpPlaw(const double& norm,); // Creates cutoff power law from | |
| 1459 | - const double& index, // normalization, index and | |
| 1460 | - const double& ecut); // exponential cutoff energy | |
| 1461 | -GModelSpectralExpPlaw(const GXmlElement& xml); // Creates cutoff PL from XML element | |
| 1462 | -GModelSpectralExpPlaw(const GModelSpectralExpPlaw& model); // Creates copy of cutoff power law | |
| 1463 | - | |
| 1464 | -/* Operators */ | |
| 1465 | -GModelPar& operator() (int index); // Access model parameter | |
| 1466 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1467 | -GModelSpectralExpPlaw& operator= (const GModelSpectralExpPlaw& model); // Assign cutoff power law | |
| 1468 | - | |
| 1469 | -/* Methods */ | |
| 1470 | -void clear(void); // Clear cutoff power law | |
| 1471 | -GModelSpectralExpPlaw* clone(void) const; // Clone cutoff power law | |
| 1472 | -int size(void) const; // Returns 4 | |
| 1473 | -std::string type(void) const; // Returns "ExpCutoff" | |
| 1474 | -double eval(const GEnergy& srcEng); // Evaluate cutoff power law | |
| 1475 | -double eval_gradients(const GEnergy& srcEng); // Evaluate cutoff PL and gradients | |
| 1476 | -void read(const GXmlElement& xml); // Read cutoff PL from XML element | |
| 1477 | -void write(GXmlElement& xml) const; // Write cutoff PL into XML element | |
| 1478 | -void autoscale(void); // Automatically scale normalization | |
| 1479 | -double norm(void) const; // Returns normalization | |
| 1480 | -double index(void) const; // Returns index | |
| 1481 | -double ecut(void) const; // Returns cutoff energy (MeV) | |
| 1482 | -double pivot(void) const; // Returns pivot energy (MeV) | |
| 1483 | -std::string print(void) const; // Print cutoff power law | |
| 1484 | -\end{verbatim} | |
| 1485 | - | |
| 1486 | -\paragraph{Description:} | |
| 1487 | -Implements power law spectral model | |
| 1488 | -\begin{equation} | |
| 1489 | -I(E) = {\tt norm} \, (E/{\tt pivot})^{{\tt index}} \exp(-E/{\tt ecut}) | |
| 1490 | -\end{equation} | |
| 1491 | -where | |
| 1492 | -${\tt norm}=n_s n_v$ is the normalization or prefactor (units ph/cm$^2$/s/MeV), | |
| 1493 | -${\tt index}=i_s i_v$ is the spectral index, | |
| 1494 | -${\tt ecut}=c_s c_v$ is the cutoff energy (units MeV), and | |
| 1495 | -${\tt pivot}=p_s p_v$ is the pivot energy (units MeV). | |
| 1496 | -Note that each parameter is factorised into a scaling factor (indexed by $s$) and a | |
| 1497 | -parameter value (indexed by $v$). | |
| 1498 | -This function is evaluated using the {\tt eval} method. | |
| 1499 | - | |
| 1500 | -The {\tt eval\_gradients} methods computes in addition the partial derivatives of | |
| 1501 | -the parameter values: | |
| 1502 | -\begin{eqnarray} | |
| 1503 | -dI/dn_v &= & n_s (E/{\tt pivot})^{{\tt index}} \exp(-E/{\tt ecut}) \\ | |
| 1504 | -dI/di_v & = & {\tt norm} (E/{\tt pivot})^{{\tt index}} \exp(-E/{\tt ecut}) i_s \ln(E/{\tt pivot}) \\ | |
| 1505 | -dI/dc_v & = & {\tt norm} (E/{\tt pivot})^{{\tt index}} \exp(-E/{\tt ecut}) (E/{\tt ecut}^2) c_s \\ | |
| 1506 | -dI/dp_v & = & {\tt norm} (E/{\tt pivot})^{{\tt index}} \exp(-E/{\tt ecut}) (-{\tt index}) / p_v | |
| 1507 | -\end{eqnarray} | |
| 1508 | - | |
| 1509 | - | |
| 1510 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1511 | -\newpage | |
| 1512 | -\subsection{{\tt GModelTemporal} \small[abstract]} | |
| 1513 | - | |
| 1514 | -\paragraph{Class definition:} | |
| 1515 | -\begin{verbatim} | |
| 1516 | -/* Constructors */ | |
| 1517 | -GModelTemporal(void); // Creates empty component | |
| 1518 | -GModelTemporal(const GModelTemporal& model); // Creates copy of component | |
| 1519 | - | |
| 1520 | -/* Operators */ | |
| 1521 | -GModelPar& operator() (int index); // Access model parameter | |
| 1522 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1523 | -GModelTemporal& operator= (const GModelTemporal& model); // Assign component | |
| 1524 | - | |
| 1525 | -/* Methods */ | |
| 1526 | -void clear(void); // Clear component | |
| 1527 | -GModelTemporal* clone(void) const; // Clone component | |
| 1528 | -int size(void) const; // Returns number of model parameters | |
| 1529 | -std::string type(void) const; // Returns type of component | |
| 1530 | -double eval(const GTime& srcTime); // Evaluate component | |
| 1531 | -double eval_gradients(const GTime& srcTime); // Evaluate component and gradients | |
| 1532 | -void read(const GXmlElement& xml); // Read component from XML element | |
| 1533 | -void write(GXmlElement& xml) const; // Write component into XML element | |
| 1534 | -std::string print(void) const; // Print component | |
| 1535 | -\end{verbatim} | |
| 1536 | - | |
| 1537 | -\paragraph{Description:} | |
| 1538 | -Implements the temporal component $V(t)$ of the factorized source model. | |
| 1539 | - | |
| 1540 | - | |
| 1541 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1542 | -\newpage | |
| 1543 | -\subsection{{\tt GModelTemporalConst}} | |
| 1544 | - | |
| 1545 | -\paragraph{Class definition:} | |
| 1546 | -\begin{verbatim} | |
| 1547 | -/* Constructors */ | |
| 1548 | -GModelTemporalConst(void); // Creates empty component | |
| 1549 | -GModelTemporalConst(const GModelTemporalConst& model); // Creates copy of component | |
| 1550 | - | |
| 1551 | -/* Operators */ | |
| 1552 | -GModelPar& operator() (int index); // Access model parameter | |
| 1553 | -const GModelPar& operator() (int index) const; // Access model parameter | |
| 1554 | -GModelTemporalConst& operator= (const GModelTemporalConst& model); // Assign component | |
| 1555 | - | |
| 1556 | -/* Methods */ | |
| 1557 | -void clear(void); // Clear component | |
| 1558 | -GModelTemporalConst* clone(void) const; // Clone component | |
| 1559 | -int size(void) const; // Returns 1 | |
| 1560 | -std::string type(void) const; // Returns "Constant" | |
| 1561 | -double eval(const GTime& srcTime); // Evaluate component | |
| 1562 | -double eval_gradients(const GTime& srcTime); // Evaluate component and gradients | |
| 1563 | -void read(const GXmlElement& xml); // Read component from XML element | |
| 1564 | -void write(GXmlElement& xml) const; // Write component into XML element | |
| 1565 | -std::string print(void) const; // Print component | |
| 1566 | -\end{verbatim} | |
| 1567 | - | |
| 1568 | -\paragraph{Description:} | |
| 1569 | -Implements a non-variable (constant) source. | |
| 1570 | - | |
| 1571 | -The {\tt eval} method returns 1, the {\tt eval\_gradients} methods sets the gradient to 0. | |
| 1572 | - | |
| 1573 | - | |
| 1574 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1575 | -\subsection{{\tt GNodeArray}} | |
| 1576 | - | |
| 1577 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1578 | -\subsection{{\tt GObservation}} | |
| 1579 | - | |
| 1580 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1581 | -\subsection{{\tt GObservations}} | |
| 1582 | - | |
| 1583 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1584 | -\subsection{{\tt GOptimizer}} | |
| 1585 | - | |
| 1586 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1587 | -\subsection{{\tt GOptimizerFunction}} | |
| 1588 | - | |
| 1589 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1590 | -\subsection{{\tt GOptimizerLM}} | |
| 1591 | - | |
| 1592 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1593 | -\subsection{{\tt GOptimizerPars}} | |
| 1594 | - | |
| 1595 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1596 | -\subsection{{\tt GPar}} | |
| 1597 | - | |
| 1598 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1599 | -\subsection{{\tt GPars}} | |
| 1600 | - | |
| 1601 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1602 | -\subsection{{\tt GPointing}} | |
| 1603 | - | |
| 1604 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1605 | -\subsection{{\tt GResponse}} | |
| 1606 | - | |
| 1607 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1608 | -\subsection{{\tt GRoi}} | |
| 1609 | - | |
| 1610 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1611 | -\subsection{{\tt GSkyDir}} | |
| 1612 | - | |
| 1613 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1614 | -\subsection{{\tt GSkymap}} | |
| 1615 | - | |
| 1616 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1617 | -\subsection{{\tt GSkyPixel}} | |
| 1618 | - | |
| 1619 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1620 | -\subsection{{\tt GSparseMatrix}} | |
| 1621 | - | |
| 1622 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1623 | -\subsection{{\tt GSymMatrix}} | |
| 1624 | - | |
| 1625 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1626 | -\subsection{{\tt GTime}} | |
| 1627 | - | |
| 1628 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1629 | -\subsection{{\tt GTools}} | |
| 1630 | - | |
| 1631 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1632 | -\subsection{{\tt GVector}} | |
| 1633 | - | |
| 1634 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1635 | -\subsection{{\tt GWcs}} | |
| 1636 | - | |
| 1637 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1638 | -\subsection{{\tt GWcsCAR}} | |
| 1639 | - | |
| 1640 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1641 | -\subsection{{\tt GWcsHPX}} | |
| 1642 | - | |
| 1643 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1644 | -\subsection{{\tt GXml}} | |
| 1645 | - | |
| 1646 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1647 | -\subsection{{\tt GXmlAttribute}} | |
| 1648 | - | |
| 1649 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1650 | -\subsection{{\tt GXmlComment}} | |
| 1651 | - | |
| 1652 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1653 | -\subsection{{\tt GXmlDocument}} | |
| 1654 | - | |
| 1655 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1656 | -\subsection{{\tt GXmlElement}} | |
| 1657 | - | |
| 1658 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1659 | -\subsection{{\tt GXmlNode}} | |
| 1660 | - | |
| 1661 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1662 | -\subsection{{\tt GXmlPI}} | |
| 1663 | - | |
| 1664 | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
| 1665 | -\subsection{{\tt GXmlText}} | |
| 1666 | - | |
| 1667 | - | |
| 1668 | -\end{document} |
doc/manual.sty deleted
| 1 | -%% | |
| 2 | -%% "manual.sty" provides definitions for the ISDC User Manuals | |
| 3 | -%% | |
| 4 | -%% Copyright (C) 2002 Jurgen Knodlseder | |
| 5 | -%% | |
| 6 | -\NeedsTeXFormat{LaTeX2e} | |
| 7 | -\ProvidesPackage{manual}[2002/02/18 v1.0 ISDC User Manual] | |
| 8 | - | |
| 9 | -% | |
| 10 | -% The page dimensions | |
| 11 | -% | |
| 12 | -%\setlength\paperheight{9.25in} | |
| 13 | -%\setlength\paperwidth{7.375in} | |
| 14 | -\setlength\parindent{0cm} | |
| 15 | -\setlength\parskip{0.2cm} | |
| 16 | -\setlength\linewidth{13.2cm} | |
| 17 | -\setlength\headheight{1.5cm} | |
| 18 | -\setlength\textwidth{16.3cm} | |
| 19 | -\setlength\textheight{22.5cm} | |
| 20 | -\setlength\oddsidemargin{0cm} | |
| 21 | -\setlength\topmargin{-1.7cm} | |
| 22 | -%\setlength\parindent{2em} | |
| 23 | -%\setlength\headheight{8pt} | |
| 24 | -\setlength\headsep{19pt} | |
| 25 | -\setlength\footskip{24pt} | |
| 26 | -%\setlength\textwidth{345pt} | |
| 27 | -%\setlength\textheight{46pc} | |
| 28 | -\setlength\evensidemargin{1.6804in} | |
| 29 | -%\setlength\oddsidemargin{1.5139in} | |
| 30 | -%\setlength\topmargin{.625in} | |
| 31 | - | |
| 32 | -% | |
| 33 | -% ISDC page style | |
| 34 | -% | |
| 35 | -\pagestyle{myheadings} | |
| 36 | -\markboth{\task\ User Manual} | |
| 37 | - {\task\ User Manual} | |
| 38 | - | |
| 39 | -%\renewcommand{\subsection}{\@startsection{subsection}{3}{-4pc}{-16pt}{6pt}{% | |
| 40 | -% \rightmark{Introduction}}} | |
| 41 | - | |
| 42 | -% | |
| 43 | -% Define front-page command | |
| 44 | -% | |
| 45 | -\newcommand{\frontpage}{% | |
| 46 | -\begin{center} | |
| 47 | -\framebox[16cm]{ | |
| 48 | -\begin{minipage}[c]{16cm} | |
| 49 | -\vspace*{6.5cm} | |
| 50 | -\begin{center} | |
| 51 | - | |
| 52 | -% Software component | |
| 53 | -\framebox{ | |
| 54 | - \framebox{ | |
| 55 | - \parbox{10cm}{ | |
| 56 | - \vspace{5mm} \centerline{ | |
| 57 | - \vspace{5mm} \Huge \bf | |
| 58 | - \task | |
| 59 | - } | |
| 60 | - } | |
| 61 | - } | |
| 62 | -} | |
| 63 | - | |
| 64 | -% User Manual | |
| 65 | -\vspace{10mm} | |
| 66 | -{\Huge \bf User Manual} | |
| 67 | -\\[10mm] | |
| 68 | - | |
| 69 | -% Version, Date | |
| 70 | -{\normalsize \bf Version \version\\ \calendar} | |
| 71 | -\\[10mm] | |
| 72 | - | |
| 73 | -% Author | |
| 74 | -\rm | |
| 75 | -J\"urgen Kn\"odlseder\\ | |
| 76 | -Institut de Recherche en Astrophysique et Plan\'etologie (IRAP)\\ | |
| 77 | -knodlseder@cesr.fr\\ | |
| 78 | -http://www.irap.omp.eu/ | |
| 79 | - | |
| 80 | -\vfill | |
| 81 | -\end{center} | |
| 82 | -\vspace*{6.5cm} | |
| 83 | -\end{minipage} | |
| 84 | -} | |
| 85 | -\end{center} | |
| 86 | - | |
| 87 | -\thispagestyle{empty} | |
| 88 | -\pagenumbering{roman} | |
| 89 | -\newpage | |
| 90 | -\begin{center} | |
| 91 | -\parbox{15cm}{ | |
| 92 | -\vspace{200mm} | |
| 93 | -\centerline{Note to the user} | |
| 94 | -\vspace{3mm} | |
| 95 | -This software has been written to analyse gamma-ray data. | |
| 96 | -Particular care has been taken in making the software user friendly | |
| 97 | -and well documented. | |
| 98 | -If you appreciated this effort, and if this software and User Manual | |
| 99 | -were useful for your scientific work, the author would appreciate a | |
| 100 | -corresponding acknowledgment in your published work. | |
| 101 | -} | |
| 102 | -\end{center} | |
| 103 | - | |
| 104 | -\newpage | |
| 105 | -\tableofcontents | |
| 106 | -\newpage | |
| 107 | -\pagenumbering{arabic} | |
| 108 | -} | |
| 109 | - | |
| 110 | - | |
| 111 | -% | |
| 112 | -% Further commands | |
| 113 | -% | |
| 114 | -%\newcommand{\icd}[1]{\item[{\tt #1}] } | |
| 115 | -\newcommand{\icd}[1]{\item{\tt #1} } | |
| 116 | -\newcommand{\cur}[1]{% | |
| 117 | -\icd{#1} specifies the current ISDC status when the function is entered. | |
| 118 | - If {\tt status != ISDC\_OK} the function does nothing and | |
| 119 | - returns the input status as return code. | |
| 120 | -} | |
| 121 | -\endinput | |
| 122 | -%% | |
| 123 | -%% End of file `manual.sty'. |
gammalib.pc.in
| ... | ... | @@ -6,7 +6,7 @@ includedir=${prefix}/include |
| 6 | 6 | Name: GammaLib |
| 7 | 7 | Description: Versatile toolbox for analysis of astronomical gamma-ray data |
| 8 | 8 | URL: http://gammalib.sourceforge.net/ |
| 9 | -Version: 0.6.2 | |
| 9 | +Version: 0.7.0 | |
| 10 | 10 | Requires: |
| 11 | 11 | Requires.private: @CFITSIO@ |
| 12 | 12 | Conflicts: | ... | ... |
gammalib.sh deleted
| 1 | -#! /bin/bash -f | |
| 2 | - | |
| 3 | -# Set parameters | |
| 4 | -installdir=$(pwd)/build | |
| 5 | -makedoc="no" | |
| 6 | - | |
| 7 | -echo "Checkout latest GammaLib" | |
| 8 | -rm -rf gammalib | |
| 9 | -cvs -Q -d /home/cvs export -N -r HEAD "gammalib" | |
| 10 | - | |
| 11 | -# Extract version number | |
| 12 | -version=`cat gammalib/configure.ac | grep 'AC_INIT' | awk -F"[" '{print $3}' | sed 's/],//' | sed 's/\./ /g'` | |
| 13 | -version=`printf "%2.2d-%2.2d-%2.2d" $version` | |
| 14 | -echo "GammaLib version: "$version | |
| 15 | - | |
| 16 | -# Set source directory | |
| 17 | -sourcedir=gammalib-$version | |
| 18 | -rm -rf $sourcedir | |
| 19 | -mv gammalib $sourcedir | |
| 20 | - | |
| 21 | -# | |
| 22 | -echo "Create Makefile.in and configure scripts" | |
| 23 | -cd $sourcedir | |
| 24 | -./autogen.sh | |
| 25 | -rm -f gammalib.sh | |
| 26 | -cd .. | |
| 27 | - | |
| 28 | -# | |
| 29 | -echo "Create gammalib_wrap.cpp and gammalib.py files for python binding (making swig obsolete)" | |
| 30 | -inc_inst="-I$sourcedir/inst/mwl/pyext -I$sourcedir/inst/lat/pyext -I$sourcedir/inst/cta/pyext" | |
| 31 | -opt_inst="-DWITH_INST_MWL -DWITH_INST_LAT -DWITH_INST_CTA" | |
| 32 | -swig -c++ -python -Wall -includeall -I$sourcedir/src $inc_inst $opt_inst -o $sourcedir/pyext/gammalib_wrap.cpp -outdir $sourcedir/pyext $sourcedir/pyext/gammalib.i | |
| 33 | - | |
| 34 | -# | |
| 35 | -if [ "x$makedoc" == "xyes" ] ; then | |
| 36 | - echo "Create doxygen documentation" | |
| 37 | - cd $sourcedir/doc | |
| 38 | - doxygen Doxyfile | |
| 39 | - cd latex | |
| 40 | - make | |
| 41 | - make | |
| 42 | - dvips -o refman.ps refman | |
| 43 | - ps2pdf refman.ps | |
| 44 | - cd ../.. | |
| 45 | -fi | |
| 46 | - | |
| 47 | -# | |
| 48 | -echo "Create LaTeX documentation" | |
| 49 | -cd $sourcedir/doc | |
| 50 | -# | |
| 51 | -latex gammalib_um.tex | |
| 52 | -dvips gammalib_um.dvi -o gammalib_um.ps | |
| 53 | -ps2pdf gammalib_um.ps | |
| 54 | -rm -f gammalib_um.dvi gammalib_um.aux gammalib_um.log gammalib_um.tex gammalib_um.toc manual.sty gammalib_um.ps | |
| 55 | -# | |
| 56 | -cd dev/coding | |
| 57 | -latex gammalib_coding.tex | |
| 58 | -dvips gammalib_coding.dvi -o gammalib_coding.ps | |
| 59 | -ps2pdf gammalib_coding.ps | |
| 60 | -cd ../.. | |
| 61 | -mv dev/coding/gammalib_coding.pdf . | |
| 62 | -# | |
| 63 | -cd dev/inst | |
| 64 | -latex gammalib_inst.tex | |
| 65 | -dvips gammalib_inst.dvi -o gammalib_inst.ps | |
| 66 | -ps2pdf gammalib_inst.ps | |
| 67 | -cd ../.. | |
| 68 | -mv dev/inst/gammalib_inst.pdf . | |
| 69 | -# | |
| 70 | -cd dev/maths | |
| 71 | -latex gammalib_maths.tex | |
| 72 | -dvips gammalib_maths.dvi -o gammalib_maths.ps | |
| 73 | -ps2pdf gammalib_maths.ps | |
| 74 | -cd ../.. | |
| 75 | -mv dev/maths/gammalib_maths.pdf . | |
| 76 | -# | |
| 77 | -cd dev/sdd | |
| 78 | -latex gammalib_sdd.tex | |
| 79 | -dvips gammalib_sdd.dvi -o gammalib_sdd.ps | |
| 80 | -ps2pdf gammalib_sdd.ps | |
| 81 | -cd ../.. | |
| 82 | -mv dev/sdd/gammalib_sdd.pdf . | |
| 83 | -# | |
| 84 | -cd dev/srs | |
| 85 | -latex gammalib_srs.tex | |
| 86 | -dvips gammalib_srs.dvi -o gammalib_srs.ps | |
| 87 | -ps2pdf gammalib_srs.ps | |
| 88 | -cd ../.. | |
| 89 | -mv dev/srs/gammalib_srs.pdf . | |
| 90 | -# | |
| 91 | -rm -rf dev | |
| 92 | -cd ../.. | |
| 93 | - | |
| 94 | -echo "Make files read/write" | |
| 95 | -chmod -R u+rw $sourcedir | |
| 96 | - | |
| 97 | -echo "Create tarball" | |
| 98 | -tar cvf - $sourcedir > $sourcedir.tar | |
| 99 | -rm -f $sourcedir.tar.gz | |
| 100 | -gzip $sourcedir.tar | |
| 101 | - | |
| 102 | -# | |
| 103 | -echo "Configure GammaLib" | |
| 104 | -cd $sourcedir | |
| 105 | -./configure --prefix=$installdir | |
| 106 | - | |
| 107 | -# | |
| 108 | -echo "Compile GammaLib" | |
| 109 | -make -j10 | |
| 110 | - | |
| 111 | -# | |
| 112 | -echo "Check GammaLib" | |
| 113 | -make check | |
| 114 | - | |
| 115 | -# | |
| 116 | -echo "Install GammaLib" | |
| 117 | -make install |
include/GApplication.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GApplication.hpp - GammaLib application base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GApplication.hpp |
| 23 | 23 | * @brief GammaLib application base class |
| 24 | - * @author Jurgen Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GAPPLICATION_HPP |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | #include <ctime> |
| 32 | 32 | #include <vector> |
| 33 | 33 | #include <string> |
| 34 | -#include <iostream> | |
| 34 | +#include "GBase.hpp" | |
| 35 | 35 | #include "GLog.hpp" |
| 36 | 36 | #include "GPars.hpp" |
| 37 | 37 | |
| ... | ... | @@ -46,11 +46,7 @@ |
| 46 | 46 | * classes, and automatically have access to task parameters and the |
| 47 | 47 | * application logger. |
| 48 | 48 | ***************************************************************************/ |
| 49 | -class GApplication { | |
| 50 | - | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<< (std::ostream& os, const GApplication& app); | |
| 53 | - friend GLog& operator<< (GLog& log, const GApplication& app); | |
| 49 | +class GApplication : public GBase { | |
| 54 | 50 | |
| 55 | 51 | public: |
| 56 | 52 | // Constructors and destructors |
| ... | ... | @@ -67,33 +63,35 @@ public: |
| 67 | 63 | const GPar& operator[](const std::string& name) const; |
| 68 | 64 | |
| 69 | 65 | // Methods |
| 70 | - std::string name(void) const; | |
| 71 | - std::string version(void) const; | |
| 72 | - double telapse(void) const; | |
| 73 | - double celapse(void) const; | |
| 74 | - void logFileOpen(bool clobber = true); | |
| 75 | - bool logTerse(void) const; | |
| 76 | - bool logNormal(void) const; | |
| 77 | - bool logExplicit(void) const; | |
| 78 | - bool logVerbose(void) const; | |
| 79 | - bool logDebug(void) const; | |
| 80 | - bool clobber(void) const; | |
| 81 | - bool haspar(const std::string& name) const; | |
| 82 | - std::string par_filename(void) const; | |
| 83 | - std::string log_filename(void) const; | |
| 84 | - void log_header(void); | |
| 85 | - void log_trailer(void); | |
| 86 | - void log_parameters(void); | |
| 87 | - std::string print(void) const; | |
| 66 | + void clear(void); | |
| 67 | + GApplication* clone(void) const; | |
| 68 | + std::string name(void) const; | |
| 69 | + std::string version(void) const; | |
| 70 | + double telapse(void) const; | |
| 71 | + double celapse(void) const; | |
| 72 | + void logFileOpen(bool clobber = true); | |
| 73 | + bool logTerse(void) const; | |
| 74 | + bool logNormal(void) const; | |
| 75 | + bool logExplicit(void) const; | |
| 76 | + bool logVerbose(void) const; | |
| 77 | + bool logDebug(void) const; | |
| 78 | + bool clobber(void) const; | |
| 79 | + bool haspar(const std::string& name) const; | |
| 80 | + std::string par_filename(void) const; | |
| 81 | + std::string log_filename(void) const; | |
| 82 | + void log_header(void); | |
| 83 | + void log_trailer(void); | |
| 84 | + void log_parameters(void); | |
| 85 | + std::string print(void) const; | |
| 88 | 86 | |
| 89 | 87 | // Public members |
| 90 | - GLog log; //!< Application logger | |
| 88 | + GLog log; //!< Application logger | |
| 91 | 89 | |
| 92 | 90 | protected: |
| 93 | 91 | // Protected methods |
| 94 | - void init_members(void); | |
| 95 | - void copy_members(const GApplication& app); | |
| 96 | - void free_members(void); | |
| 92 | + void init_members(void); | |
| 93 | + void copy_members(const GApplication& app); | |
| 94 | + void free_members(void); | |
| 97 | 95 | |
| 98 | 96 | // Protected data members |
| 99 | 97 | std::string m_name; //!< Application name | ... | ... |
include/GBase.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GBase.hpp - GammaLib base class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2012 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GBase.hpp | |
| 23 | + * @brief Definition of interface for all GammaLib classes | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GBASE_HPP | |
| 28 | +#define GBASE_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include <iostream> | |
| 33 | + | |
| 34 | + | |
| 35 | +/***********************************************************************//** | |
| 36 | + * @class GBase | |
| 37 | + * | |
| 38 | + * @brief Interface class for all GammaLib classes | |
| 39 | + * | |
| 40 | + * This class defines the interface for all GammaLib classes. It is an | |
| 41 | + * abstract base class from which all other GammaLib classes will be | |
| 42 | + * derived. The interface class imposes on all GammaLib classes to | |
| 43 | + * implement the following methods: | |
| 44 | + * | |
| 45 | + * clear() Sets the object to a clean initial state | |
| 46 | + * | |
| 47 | + * clone() Creates a deep copy of the object | |
| 48 | + * | |
| 49 | + * print() Print content of object | |
| 50 | + ***************************************************************************/ | |
| 51 | +class GBase { | |
| 52 | + | |
| 53 | +public: | |
| 54 | + /// @brief Destructor | |
| 55 | + /// | |
| 56 | + /// Destroys class. | |
| 57 | + virtual ~GBase(void) {} | |
| 58 | + | |
| 59 | + /// @brief Clear object | |
| 60 | + /// | |
| 61 | + /// Sets the object to a clean initial state. After calling the method | |
| 62 | + /// the object will be in the same state as it were if an empty instance | |
| 63 | + /// of the object would have been created. | |
| 64 | + virtual void clear(void) = 0; | |
| 65 | + | |
| 66 | + /// @brief Clones object | |
| 67 | + /// | |
| 68 | + /// @return Pointer to deep copy of object. | |
| 69 | + /// | |
| 70 | + /// Creates a deep copy of the object and returns a pointer to the | |
| 71 | + /// object. | |
| 72 | + virtual GBase* clone(void) const = 0; | |
| 73 | + | |
| 74 | + /// @brief Print content of object | |
| 75 | + /// | |
| 76 | + /// @return String containing the content of the object. | |
| 77 | + /// | |
| 78 | + /// Formats the content in a standard way and puts this content in a | |
| 79 | + /// C++ string that is returned. | |
| 80 | + virtual std::string print(void) const = 0; | |
| 81 | +}; | |
| 82 | + | |
| 83 | +/* __ Forward declarations _______________________________________________ */ | |
| 84 | +class GLog; | |
| 85 | + | |
| 86 | +/* __ Prototypes _________________________________________________________ */ | |
| 87 | +std::ostream& operator<<(std::ostream& os, const GBase& base); | |
| 88 | +GLog& operator<<(GLog& log, const GBase& base); | |
| 89 | + | |
| 90 | +#endif /* GBASE_HPP */ | ... | ... |
include/GCaldb.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCaldb.hpp - Calibration database class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,18 +21,17 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCaldb.hpp |
| 23 | 23 | * @brief Calibration database class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCALDB_HPP |
| 28 | 28 | #define GCALDB_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GFits.hpp" |
| 35 | -#include "GFitsBinTable.hpp" | |
| 34 | +#include "GFitsTable.hpp" | |
| 36 | 35 | |
| 37 | 36 | |
| 38 | 37 | /***********************************************************************//** |
| ... | ... | @@ -47,21 +46,29 @@ |
| 47 | 46 | * variable, or set using the dir() method. |
| 48 | 47 | * |
| 49 | 48 | * It is assumed that the calibration data are found under |
| 50 | - * $CALDB/data/<mission>[/<instrument>] | |
| 49 | + * | |
| 50 | + * $CALDB/data/<mission>[/<instrument>] | |
| 51 | + * | |
| 52 | + * or | |
| 53 | + * | |
| 54 | + * $GAMMALIB_CALDB/data/<mission>[/<instrument>] | |
| 55 | + * | |
| 51 | 56 | * and that the Calibration Index File (CIF) is located at |
| 52 | - * $CALDB/data/<mission>[/<instrument>]/caldb.indx | |
| 53 | - * where <mission> is the name of the mission and <instrument> is the | |
| 57 | + * | |
| 58 | + * $CALDB/data/<mission>[/<instrument>]/caldb.indx | |
| 59 | + * | |
| 60 | + * or | |
| 61 | + * | |
| 62 | + * $GAMMALIB_CALDB/data/<mission>[/<instrument>]/caldb.indx | |
| 63 | + * | |
| 64 | + * where \<mission\> is the name of the mission and \<instrument\> is the | |
| 54 | 65 | * optional instrument name (all lower case). |
| 55 | 66 | * |
| 56 | 67 | * The calibration database for a given mission and instrument is opened |
| 57 | 68 | * using the open() method. Once opened, database information can be |
| 58 | 69 | * accessed. After usage, the database is closed using the close() method. |
| 59 | 70 | ***************************************************************************/ |
| 60 | -class GCaldb { | |
| 61 | - | |
| 62 | - // I/O friends | |
| 63 | - friend std::ostream& operator<<(std::ostream& os, const GCaldb& caldb); | |
| 64 | - friend GLog& operator<<(GLog& log, const GCaldb& caldb); | |
| 71 | +class GCaldb : public GBase { | |
| 65 | 72 | |
| 66 | 73 | public: |
| 67 | 74 | // Constructors and destructors | ... | ... |
include/GCsv.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCsv.hpp - Column separated values table class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,17 +21,16 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCsv.hpp |
| 23 | 23 | * @brief Column separated values table class definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -#ifndef GCsv_HPP | |
| 28 | -#define GCsv_HPP | |
| 27 | +#ifndef GCSV_HPP | |
| 28 | +#define GCSV_HPP | |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| ... | ... | @@ -39,11 +38,7 @@ |
| 39 | 38 | * |
| 40 | 39 | * @brief Column separated values table class definition |
| 41 | 40 | ***************************************************************************/ |
| 42 | -class GCsv { | |
| 43 | - | |
| 44 | - // I/O friends | |
| 45 | - friend std::ostream& operator<< (std::ostream& os, const GCsv& csv); | |
| 46 | - friend GLog& operator<< (GLog& log, const GCsv& csv); | |
| 41 | +class GCsv : public GBase { | |
| 47 | 42 | |
| 48 | 43 | public: |
| 49 | 44 | // Constructors and destructors |
| ... | ... | @@ -81,4 +76,4 @@ protected: |
| 81 | 76 | std::vector<std::vector<std::string> > m_data; //!< CSV table data |
| 82 | 77 | }; |
| 83 | 78 | |
| 84 | -#endif /* GCsv_HPP */ | |
| 79 | +#endif /* GCSV_HPP */ | ... | ... |
include/GDerivative.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GDerivative.hpp - Derivative class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GDerivative.hpp |
| 23 | 23 | * @brief GDerivative class interface definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GDERIVATIVE_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GFunction.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -43,11 +42,7 @@ |
| 43 | 42 | * The function to be derived is implemented by the abstract GFunction |
| 44 | 43 | * class. |
| 45 | 44 | ***************************************************************************/ |
| 46 | -class GDerivative { | |
| 47 | - | |
| 48 | - // I/O friends | |
| 49 | - friend std::ostream& operator<<(std::ostream& os, const GDerivative& dx); | |
| 50 | - friend GLog& operator<<(GLog& log, const GDerivative& dx); | |
| 45 | +class GDerivative : public GBase { | |
| 51 | 46 | |
| 52 | 47 | public: |
| 53 | 48 | ... | ... |
include/GEbounds.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GEbounds.hpp - Energy boundaries class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,16 +21,15 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GEbounds.hpp |
| 23 | 23 | * @brief Energy boundaries class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GEBOUNDS_HPP |
| 28 | 28 | #define GEBOUNDS_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GFits.hpp" |
| 35 | 34 | #include "GFitsTable.hpp" |
| 36 | 35 | #include "GEnergy.hpp" |
| ... | ... | @@ -43,11 +42,7 @@ |
| 43 | 42 | * |
| 44 | 43 | * This class holds a list of energy intervals. |
| 45 | 44 | ***************************************************************************/ |
| 46 | -class GEbounds { | |
| 47 | - | |
| 48 | - // I/O friends | |
| 49 | - friend std::ostream& operator<<(std::ostream& os, const GEbounds& ebds); | |
| 50 | - friend GLog& operator<<(GLog& log, const GEbounds& ebds); | |
| 45 | +class GEbounds : public GBase { | |
| 51 | 46 | |
| 52 | 47 | public: |
| 53 | 48 | // Constructors and destructors |
| ... | ... | @@ -81,7 +76,7 @@ public: |
| 81 | 76 | GEnergy emax(int inx) const; |
| 82 | 77 | GEnergy emean(int inx) const; |
| 83 | 78 | GEnergy elogmean(int inx) const; |
| 84 | - bool isin(const GEnergy& eng) const; | |
| 79 | + bool contains(const GEnergy& eng) const; | |
| 85 | 80 | std::string print(void) const; |
| 86 | 81 | |
| 87 | 82 | ... | ... |
include/GEnergy.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GEnergy.hpp - Energy class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GEnergy.hpp |
| 23 | 23 | * @brief Energy value class definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GENERGY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | |
| 35 | 34 | |
| 36 | 35 | /***********************************************************************//** |
| ... | ... | @@ -46,11 +45,7 @@ |
| 46 | 45 | * value is changed. This considerably reduces the number of log10 operations |
| 47 | 46 | * in many applications and speeds up the performance. |
| 48 | 47 | ***************************************************************************/ |
| 49 | -class GEnergy { | |
| 50 | - | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<< (std::ostream& os, const GEnergy& eng); | |
| 53 | - friend GLog& operator<< (GLog& log, const GEnergy& eng); | |
| 48 | +class GEnergy : public GBase { | |
| 54 | 49 | |
| 55 | 50 | // Operator friends |
| 56 | 51 | friend GEnergy operator+ (const GEnergy &a, const GEnergy &b); |
| ... | ... | @@ -78,6 +73,7 @@ public: |
| 78 | 73 | |
| 79 | 74 | // Methods |
| 80 | 75 | void clear(void); |
| 76 | + GEnergy* clone(void) const; | |
| 81 | 77 | double erg(void) const; |
| 82 | 78 | double keV(void) const; |
| 83 | 79 | double MeV(void) const; | ... | ... |
include/GEvent.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GEvent.hpp - Event abstract base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GEvent.hpp |
| 23 | 23 | * @brief GEvent abstract base class interface definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GEVENT_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GInstDir.hpp" |
| 35 | 34 | #include "GEnergy.hpp" |
| 36 | 35 | #include "GTime.hpp" |
| ... | ... | @@ -69,11 +68,7 @@ |
| 69 | 68 | * The GEvent class does not hold any data members. Data members are stored |
| 70 | 69 | * in the derived classes. |
| 71 | 70 | ***************************************************************************/ |
| 72 | -class GEvent { | |
| 73 | - | |
| 74 | - // I/O friends | |
| 75 | - friend std::ostream& operator<< (std::ostream& os, const GEvent& event); | |
| 76 | - friend GLog& operator<< (GLog& log, const GEvent& event); | |
| 71 | +class GEvent : public GBase { | |
| 77 | 72 | |
| 78 | 73 | public: |
| 79 | 74 | // Constructors and destructors | ... | ... |
include/GEvents.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GEvents.hpp - Abstract event container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GEvents.hpp |
| 23 | 23 | * @brief Abstract event container class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GEVENTS_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GEvent.hpp" |
| 35 | 34 | #include "GFits.hpp" |
| 36 | 35 | #include "GEbounds.hpp" |
| ... | ... | @@ -61,11 +60,7 @@ |
| 61 | 60 | * An event iterator allows iterating over the event atoms or bins of the |
| 62 | 61 | * container. |
| 63 | 62 | ***************************************************************************/ |
| 64 | -class GEvents { | |
| 65 | - | |
| 66 | - // I/O friends | |
| 67 | - friend std::ostream& operator<<(std::ostream& os, const GEvents& events); | |
| 68 | - friend GLog& operator<<(GLog& log, const GEvents& events); | |
| 63 | +class GEvents : public GBase { | |
| 69 | 64 | |
| 70 | 65 | public: |
| 71 | 66 | // Constructors and destructors | ... | ... |
include/GFits.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFits.hpp - FITS file access class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFits.hpp |
| 23 | 23 | * @brief FITS file access class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITS_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GFitsHDU.hpp" |
| 36 | 35 | #include "GFitsImage.hpp" |
| 37 | 36 | #include "GFitsTable.hpp" |
| ... | ... | @@ -47,11 +46,7 @@ |
| 47 | 46 | * which are implemented by the GFitsHDU class. Each HDU is composed of a |
| 48 | 47 | * header (GFitsHeader) and some data (GFitsData). |
| 49 | 48 | ***************************************************************************/ |
| 50 | -class GFits { | |
| 51 | - | |
| 52 | - // I/O friends | |
| 53 | - friend std::ostream& operator<<(std::ostream& os, const GFits& fits); | |
| 54 | - friend GLog& operator<<(GLog& log, const GFits& fits); | |
| 49 | +class GFits : public GBase { | |
| 55 | 50 | |
| 56 | 51 | public: |
| 57 | 52 | // Constructors and destructors |
| ... | ... | @@ -65,6 +60,7 @@ public: |
| 65 | 60 | |
| 66 | 61 | // Methods |
| 67 | 62 | void clear(void); |
| 63 | + GFits* clone(void) const; | |
| 68 | 64 | int size(void) const; |
| 69 | 65 | void open(const std::string& filename, bool create = false); |
| 70 | 66 | void save(bool clobber = false); | ... | ... |
include/GFitsAsciiTable.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsAsciiTable.hpp - FITS ASCII table class * | |
| 2 | + * GFitsAsciiTable.hpp - FITS ASCII table class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsAsciiTable.hpp |
| 23 | - * @brief GFitsAsciiTable class definition. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief FITS ASCII table class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSASCIITABLE_HPP |
| ... | ... | @@ -34,9 +34,9 @@ |
| 34 | 34 | /***********************************************************************//** |
| 35 | 35 | * @class GFitsAsciiTable |
| 36 | 36 | * |
| 37 | - * @brief Interface for FITS binary table | |
| 37 | + * @brief Interface for FITS ASCII table | |
| 38 | 38 | * |
| 39 | - * The following ASCII tables are supported: | |
| 39 | + * The following ASCII table columns are supported: | |
| 40 | 40 | * TSTRING (A), |
| 41 | 41 | * TLONG (I), |
| 42 | 42 | * TDOUBLE (F,D) |
| ... | ... | @@ -54,19 +54,16 @@ public: |
| 54 | 54 | // Operators |
| 55 | 55 | GFitsAsciiTable& operator= (const GFitsAsciiTable& table); |
| 56 | 56 | |
| 57 | - // Implemented pure virtual methods | |
| 58 | - HDUType exttype(void) const { return HT_ASCII_TABLE; } | |
| 59 | - | |
| 60 | 57 | // Methods |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsAsciiTable* clone(void) const; | |
| 60 | + HDUType exttype(void) const { return HT_ASCII_TABLE; } | |
| 61 | 61 | |
| 62 | 62 | private: |
| 63 | 63 | // Private methods |
| 64 | - void init_members(void); | |
| 65 | - void copy_members(const GFitsAsciiTable& table); | |
| 66 | - void free_members(void); | |
| 67 | - GFitsAsciiTable* clone(void) const; | |
| 68 | - | |
| 69 | - // Private data area | |
| 64 | + void init_members(void); | |
| 65 | + void copy_members(const GFitsAsciiTable& table); | |
| 66 | + void free_members(void); | |
| 70 | 67 | }; |
| 71 | 68 | |
| 72 | 69 | #endif /* GFITSASCIITABLE_HPP */ | ... | ... |
include/GFitsBinTable.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsBinTable.hpp - FITS binary table class * | |
| 2 | + * GFitsBinTable.hpp - FITS binary table class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsBinTable.hpp |
| 23 | - * @brief GFitsBinTable class definition. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief FITS binary table class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSBINTABLE_HPP |
| ... | ... | @@ -49,18 +49,15 @@ public: |
| 49 | 49 | GFitsBinTable& operator= (const GFitsBinTable& table); |
| 50 | 50 | |
| 51 | 51 | // Implemented pure virtual methods |
| 52 | - HDUType exttype(void) const { return HT_BIN_TABLE; } | |
| 53 | - | |
| 54 | - // Methods | |
| 52 | + virtual void clear(void); | |
| 53 | + virtual GFitsBinTable* clone(void) const; | |
| 54 | + HDUType exttype(void) const { return HT_BIN_TABLE; } | |
| 55 | 55 | |
| 56 | 56 | private: |
| 57 | 57 | // Private methods |
| 58 | - void init_members(void); | |
| 59 | - void copy_members(const GFitsBinTable& table); | |
| 60 | - void free_members(void); | |
| 61 | - GFitsBinTable* clone(void) const; | |
| 62 | - | |
| 63 | - // Private data area | |
| 58 | + void init_members(void); | |
| 59 | + void copy_members(const GFitsBinTable& table); | |
| 60 | + void free_members(void); | |
| 64 | 61 | }; |
| 65 | 62 | |
| 66 | 63 | #endif /* GFITSBINTABLE_HPP */ | ... | ... |
include/GFitsHDU.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsHDU.hpp - FITS HDU handling class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsHDU.hpp |
| 23 | 23 | * @brief GFitsHDU class definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSHDU_HPP |
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | +#include "GBase.hpp" | |
| 32 | 33 | #include "GFitsHeader.hpp" |
| 33 | 34 | #include "GFitsHeaderCard.hpp" |
| 34 | 35 | |
| ... | ... | @@ -47,7 +48,7 @@ |
| 47 | 48 | * @todo Implement GFitsHDU* select(const std::string& expr) that applies |
| 48 | 49 | * to a table HDU for row selection. |
| 49 | 50 | ***************************************************************************/ |
| 50 | -class GFitsHDU { | |
| 51 | +class GFitsHDU : public GBase { | |
| 51 | 52 | |
| 52 | 53 | // Friend classes |
| 53 | 54 | friend class GFits; |
| ... | ... | @@ -69,8 +70,9 @@ public: |
| 69 | 70 | }; |
| 70 | 71 | |
| 71 | 72 | // Pure virtual methods |
| 72 | - virtual HDUType exttype(void) const = 0; | |
| 73 | + virtual void clear(void) = 0; | |
| 73 | 74 | virtual GFitsHDU* clone(void) const = 0; |
| 75 | + virtual HDUType exttype(void) const = 0; | |
| 74 | 76 | virtual std::string print(void) const = 0; |
| 75 | 77 | |
| 76 | 78 | // Implemented methods |
| ... | ... | @@ -96,6 +98,9 @@ public: |
| 96 | 98 | |
| 97 | 99 | protected: |
| 98 | 100 | // Protected methods |
| 101 | + void init_members(void); | |
| 102 | + void copy_members(const GFitsHDU& hdu); | |
| 103 | + void free_members(void); | |
| 99 | 104 | void connect(void* fptr); |
| 100 | 105 | void move_to_hdu(void); |
| 101 | 106 | HDUType get_hdu_type(void) const; |
| ... | ... | @@ -115,12 +120,6 @@ protected: |
| 115 | 120 | int m_hdunum; //!< HDU number (starting from 0) |
| 116 | 121 | std::string m_name; //!< HDU name (extname) |
| 117 | 122 | GFitsHeader m_header; //!< HDU header |
| 118 | - | |
| 119 | -private: | |
| 120 | - // Private methods | |
| 121 | - void init_members(void); | |
| 122 | - void copy_members(const GFitsHDU& hdu); | |
| 123 | - void free_members(void); | |
| 124 | 123 | }; |
| 125 | 124 | |
| 126 | 125 | #endif /* GFITSHDU_HPP */ | ... | ... |
include/GFitsHeader.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsHeader.hpp - FITS header handling class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,15 +21,14 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsHeader.hpp |
| 23 | 23 | * @brief FITS header class definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSHEADER_HPP |
| 28 | 28 | #define GFITSHEADER_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | -#include "GLog.hpp" | |
| 31 | +#include "GBase.hpp" | |
| 33 | 32 | #include "GFitsHeaderCard.hpp" |
| 34 | 33 | |
| 35 | 34 | |
| ... | ... | @@ -44,11 +43,7 @@ |
| 44 | 43 | * saved into another file (using the 'save' method). Cards are added or |
| 45 | 44 | * changed using the 'update' method. |
| 46 | 45 | ***************************************************************************/ |
| 47 | -class GFitsHeader { | |
| 48 | - | |
| 49 | - // I/O friends | |
| 50 | - friend std::ostream& operator<< (std::ostream& os, const GFitsHeader& header); | |
| 51 | - friend GLog& operator<< (GLog& log, const GFitsHeader& header); | |
| 46 | +class GFitsHeader : public GBase { | |
| 52 | 47 | |
| 53 | 48 | public: |
| 54 | 49 | // Constructors and destructors | ... | ... |
include/GFitsHeaderCard.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsHeaderCard.hpp - FITS header card class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,15 +21,15 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsHeaderCard.hpp |
| 23 | 23 | * @brief FITS header card class definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSHEADERCARD_HPP |
| 28 | 28 | #define GFITSHEADERCARD_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | -#include "GLog.hpp" | |
| 31 | +#include <string> | |
| 32 | +#include "GBase.hpp" | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /***********************************************************************//** |
| ... | ... | @@ -43,15 +43,11 @@ |
| 43 | 43 | * |
| 44 | 44 | * @todo Many more datatypes may exist for a header card. |
| 45 | 45 | ***************************************************************************/ |
| 46 | -class GFitsHeaderCard { | |
| 46 | +class GFitsHeaderCard : public GBase { | |
| 47 | 47 | |
| 48 | 48 | // Friend classes |
| 49 | 49 | friend class GFitsHeader; |
| 50 | 50 | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<<(std::ostream& os, const GFitsHeaderCard& card); | |
| 53 | - friend GLog& operator<<(GLog& log, const GFitsHeaderCard& card); | |
| 54 | - | |
| 55 | 51 | public: |
| 56 | 52 | // Constructors & Destructors |
| 57 | 53 | GFitsHeaderCard(void); |
| ... | ... | @@ -67,32 +63,32 @@ public: |
| 67 | 63 | // Operators |
| 68 | 64 | GFitsHeaderCard& operator= (const GFitsHeaderCard& card); |
| 69 | 65 | |
| 70 | - // Methods to set card properties | |
| 71 | - void keyname(const std::string& keyname); | |
| 72 | - void value(const std::string& value); | |
| 73 | - void value(const bool& value); | |
| 74 | - void value(const float& value); | |
| 75 | - void value(const double& value); | |
| 76 | - void value(const unsigned short& value); | |
| 77 | - void value(const short& value); | |
| 78 | - void value(const unsigned int& value); | |
| 79 | - void value(const int& value); | |
| 80 | - void value(const long& value); | |
| 81 | - void value(const unsigned long& value); | |
| 82 | - void value(const long long& value); | |
| 83 | - void unit(const std::string& unit); | |
| 84 | - void comment(const std::string& comment); | |
| 85 | - | |
| 86 | - // Methods to get card properties | |
| 87 | - std::string keyname(void) const; | |
| 88 | - std::string value(void) const; | |
| 89 | - int decimals(void) const; | |
| 90 | - std::string unit(void) const; | |
| 91 | - std::string comment(void) const; | |
| 92 | - std::string string(void); | |
| 93 | - double real(void); | |
| 94 | - int integer(void); | |
| 95 | - std::string print(void) const; | |
| 66 | + // Methods | |
| 67 | + void clear(void); | |
| 68 | + GFitsHeaderCard* clone(void) const; | |
| 69 | + void keyname(const std::string& keyname); | |
| 70 | + std::string keyname(void) const; | |
| 71 | + void value(const std::string& value); | |
| 72 | + void value(const bool& value); | |
| 73 | + void value(const float& value); | |
| 74 | + void value(const double& value); | |
| 75 | + void value(const unsigned short& value); | |
| 76 | + void value(const short& value); | |
| 77 | + void value(const unsigned int& value); | |
| 78 | + void value(const int& value); | |
| 79 | + void value(const long& value); | |
| 80 | + void value(const unsigned long& value); | |
| 81 | + void value(const long long& value); | |
| 82 | + std::string value(void) const; | |
| 83 | + int decimals(void) const; | |
| 84 | + void unit(const std::string& unit); | |
| 85 | + std::string unit(void) const; | |
| 86 | + void comment(const std::string& comment); | |
| 87 | + std::string comment(void) const; | |
| 88 | + std::string string(void); | |
| 89 | + double real(void); | |
| 90 | + int integer(void); | |
| 91 | + std::string print(void) const; | |
| 96 | 92 | |
| 97 | 93 | private: |
| 98 | 94 | // Private methods | ... | ... |
include/GFitsImage.hpp
| ... | ... | @@ -28,8 +28,6 @@ |
| 28 | 28 | #define GFITSIMAGE_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | -#include "GLog.hpp" | |
| 33 | 31 | #include "GFitsHDU.hpp" |
| 34 | 32 | |
| 35 | 33 | |
| ... | ... | @@ -42,10 +40,6 @@ |
| 42 | 40 | ***************************************************************************/ |
| 43 | 41 | class GFitsImage : public GFitsHDU { |
| 44 | 42 | |
| 45 | - // I/O friends | |
| 46 | - friend std::ostream& operator<< (std::ostream& os, const GFitsImage& image); | |
| 47 | - friend GLog& operator<< (GLog& log, const GFitsImage& image); | |
| 48 | - | |
| 49 | 43 | public: |
| 50 | 44 | // Constructors and destructors |
| 51 | 45 | GFitsImage(void); |
| ... | ... | @@ -61,13 +55,14 @@ public: |
| 61 | 55 | GFitsImage& operator= (const GFitsImage& image); |
| 62 | 56 | |
| 63 | 57 | // Pure virtual methods |
| 58 | + virtual void clear(void) = 0; | |
| 59 | + virtual GFitsImage* clone(void) const = 0; | |
| 64 | 60 | virtual void* pixels(void) = 0; |
| 65 | 61 | virtual double pixel(const int& ix) const = 0; |
| 66 | 62 | virtual double pixel(const int& ix, const int& iy) const = 0; |
| 67 | 63 | virtual double pixel(const int& ix, const int& iy, const int& iz) const = 0; |
| 68 | 64 | virtual double pixel(const int& ix, const int& iy, const int& iz, const int& it) const = 0; |
| 69 | 65 | virtual int type(void) const = 0; |
| 70 | - virtual GFitsImage* clone(void) const = 0; | |
| 71 | 66 | |
| 72 | 67 | // Implemented pure virtual methods |
| 73 | 68 | HDUType exttype(void) const { return HT_IMAGE; } |
| ... | ... | @@ -84,6 +79,9 @@ public: |
| 84 | 79 | |
| 85 | 80 | protected: |
| 86 | 81 | // Protected methods |
| 82 | + void init_members(void); | |
| 83 | + void copy_members(const GFitsImage& image); | |
| 84 | + void free_members(void); | |
| 87 | 85 | void data_open(void* vptr); |
| 88 | 86 | void data_save(void); |
| 89 | 87 | void data_close(void); |
| ... | ... | @@ -113,12 +111,6 @@ protected: |
| 113 | 111 | long* m_naxes; //!< Number of pixels in each dimension |
| 114 | 112 | int m_num_pixels; //!< Number of image pixels |
| 115 | 113 | int m_anynul; //!< Number of NULLs encountered |
| 116 | - | |
| 117 | -private: | |
| 118 | - // Private methods | |
| 119 | - void init_members(void); | |
| 120 | - void copy_members(const GFitsImage& image); | |
| 121 | - void free_members(void); | |
| 122 | 114 | }; |
| 123 | 115 | |
| 124 | 116 | #endif /* GFITSIMAGE_HPP */ | ... | ... |
include/GFitsImageByte.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsImageByte.hpp - FITS Byte image class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const unsigned char& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageByte* clone(void) const; | |
| 64 | 66 | unsigned char& at(const int& ix); |
| 65 | 67 | unsigned char& at(const int& ix, const int& iy); |
| 66 | 68 | unsigned char& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageByte* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageDouble.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageDouble.hpp |
| 23 | 23 | * @brief GFitsImageDouble class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGEDOUBLE_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const double& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageDouble* clone(void) const; | |
| 64 | 66 | double& at(const int& ix); |
| 65 | 67 | double& at(const int& ix, const int& iy); |
| 66 | 68 | double& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageDouble* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageFloat.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageFloat.hpp |
| 23 | 23 | * @brief GFitsImageFloat class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGEFLOAT_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const float& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageFloat* clone(void) const; | |
| 64 | 66 | float& at(const int& ix); |
| 65 | 67 | float& at(const int& ix, const int& iy); |
| 66 | 68 | float& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageFloat* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageLong.hpp
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const long& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageLong* clone(void) const; | |
| 64 | 66 | long& at(const int& ix); |
| 65 | 67 | long& at(const int& ix, const int& iy); |
| 66 | 68 | long& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageLong* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageLongLong.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageLongLong.hpp |
| 23 | 23 | * @brief GFitsImageLongLong class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGELONGLONG_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const long long& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageLongLong* clone(void) const; | |
| 64 | 66 | long long& at(const int& ix); |
| 65 | 67 | long long& at(const int& ix, const int& iy); |
| 66 | 68 | long long& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageLongLong* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageSByte.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageSByte.hpp |
| 23 | 23 | * @brief GFitsImageSByte class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGESBYTE_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const char& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageSByte* clone(void) const; | |
| 64 | 66 | char& at(const int& ix); |
| 65 | 67 | char& at(const int& ix, const int& iy); |
| 66 | 68 | char& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageSByte* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageShort.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageShort.hpp |
| 23 | 23 | * @brief GFitsImageShort class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGESHORT_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const short& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageShort* clone(void) const; | |
| 64 | 66 | short& at(const int& ix); |
| 65 | 67 | short& at(const int& ix, const int& iy); |
| 66 | 68 | short& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageShort* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageULong.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageULong.hpp |
| 23 | 23 | * @brief GFitsImageULong class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGEULONG_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const unsigned long& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageULong* clone(void) const; | |
| 64 | 66 | unsigned long& at(const int& ix); |
| 65 | 67 | unsigned long& at(const int& ix, const int& iy); |
| 66 | 68 | unsigned long& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageULong* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsImageUShort.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsImageUShort.hpp |
| 23 | 23 | * @brief GFitsImageUShort class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSIMAGEUSHORT_HPP |
| ... | ... | @@ -61,6 +61,8 @@ public: |
| 61 | 61 | const unsigned short& operator() (const int& ix, const int& iy, const int& iz, const int& it) const; |
| 62 | 62 | |
| 63 | 63 | // Methods |
| 64 | + void clear(void); | |
| 65 | + GFitsImageUShort* clone(void) const; | |
| 64 | 66 | unsigned short& at(const int& ix); |
| 65 | 67 | unsigned short& at(const int& ix, const int& iy); |
| 66 | 68 | unsigned short& at(const int& ix, const int& iy, const int& iz); |
| ... | ... | @@ -75,7 +77,6 @@ public: |
| 75 | 77 | double pixel(const int& ix, const int& iy, const int& iz, const int& it) const; |
| 76 | 78 | void* pixels(void); |
| 77 | 79 | int type(void) const; |
| 78 | - GFitsImageUShort* clone(void) const; | |
| 79 | 80 | |
| 80 | 81 | private: |
| 81 | 82 | // Private methods | ... | ... |
include/GFitsTable.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTable.hpp - FITS table abstract base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,22 +21,17 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTable.hpp |
| 23 | 23 | * @brief FITS table abstract base class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLE_HPP |
| 28 | 28 | #define GFITSTABLE_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | -#include "GLog.hpp" | |
| 33 | 31 | #include "GFitsHDU.hpp" |
| 34 | 32 | #include "GFitsTableCol.hpp" |
| 35 | 33 | |
| 36 | 34 | |
| 37 | -/* __ Structures _________________________________________________________ */ | |
| 38 | - | |
| 39 | - | |
| 40 | 35 | /***********************************************************************//** |
| 41 | 36 | * @class GFitsTable |
| 42 | 37 | * |
| ... | ... | @@ -50,10 +45,6 @@ |
| 50 | 45 | ***************************************************************************/ |
| 51 | 46 | class GFitsTable : public GFitsHDU { |
| 52 | 47 | |
| 53 | - // I/O friends | |
| 54 | - friend std::ostream& operator<< (std::ostream& os, const GFitsTable& table); | |
| 55 | - friend GLog& operator<< (GLog& log, const GFitsTable& table); | |
| 56 | - | |
| 57 | 48 | public: |
| 58 | 49 | // Constructors and destructors |
| 59 | 50 | GFitsTable(void); |
| ... | ... | @@ -69,7 +60,9 @@ public: |
| 69 | 60 | const GFitsTableCol& operator[](const std::string& colname) const; |
| 70 | 61 | |
| 71 | 62 | // Pure virtual methods |
| 63 | + virtual void clear(void) = 0; | |
| 72 | 64 | virtual GFitsTable* clone(void) const = 0; |
| 65 | + virtual HDUType exttype(void) const = 0; | |
| 73 | 66 | |
| 74 | 67 | // Implemented Methods |
| 75 | 68 | void append_column(GFitsTableCol& column); |
| ... | ... | @@ -84,6 +77,9 @@ public: |
| 84 | 77 | |
| 85 | 78 | protected: |
| 86 | 79 | // Protected methods |
| 80 | + void init_members(void); | |
| 81 | + void copy_members(const GFitsTable& table); | |
| 82 | + void free_members(void); | |
| 87 | 83 | void data_open(void* vptr); |
| 88 | 84 | void data_save(void); |
| 89 | 85 | void data_close(void); |
| ... | ... | @@ -100,9 +96,6 @@ protected: |
| 100 | 96 | |
| 101 | 97 | private: |
| 102 | 98 | // Private methods |
| 103 | - void init_members(void); | |
| 104 | - void copy_members(const GFitsTable& table); | |
| 105 | - void free_members(void); | |
| 106 | 99 | GFitsTableCol* alloc_column(int typecode) const; |
| 107 | 100 | GFitsTableCol* ptr_column(const std::string& colname) const; |
| 108 | 101 | }; | ... | ... |
include/GFitsTableBitCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableBitCol.hpp - FITS table bit column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableBitCol.hpp |
| 23 | 23 | * @brief FITS table bit column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEBITCOL_HPP |
| ... | ... | @@ -56,12 +56,14 @@ public: |
| 56 | 56 | bool& operator() (const int& row, const int& inx = 0); |
| 57 | 57 | const bool& operator() (const int& row, const int& inx = 0) const; |
| 58 | 58 | |
| 59 | - // Implement virtual methods | |
| 60 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | - virtual double real(const int& row, const int& col = 0) const; | |
| 62 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | - virtual void insert(const int& rownum, const int& nrows); | |
| 64 | - virtual void remove(const int& rownum, const int& nrows); | |
| 59 | + // Implemented virtual methods | |
| 60 | + virtual void clear(void); | |
| 61 | + virtual GFitsTableBitCol* clone(void) const; | |
| 62 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 63 | + virtual double real(const int& row, const int& col = 0) const; | |
| 64 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 65 | + virtual void insert(const int& rownum, const int& nrows); | |
| 66 | + virtual void remove(const int& rownum, const int& nrows); | |
| 65 | 67 | |
| 66 | 68 | // Other methods |
| 67 | 69 | unsigned char* data(void) { return m_data; } |
| ... | ... | @@ -75,7 +77,6 @@ private: |
| 75 | 77 | void free_members(void); |
| 76 | 78 | |
| 77 | 79 | // Implemented pure virtual methods |
| 78 | - virtual GFitsTableBitCol* clone(void) const; | |
| 79 | 80 | virtual std::string ascii_format(void) const; |
| 80 | 81 | virtual std::string binary_format(void) const; |
| 81 | 82 | virtual void alloc_data(void); | ... | ... |
include/GFitsTableBoolCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableBoolCol.hpp - FITS table boolean column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableBoolCol.hpp |
| 23 | 23 | * @brief FITS table Boolean column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEBOOLCOL_HPP |
| ... | ... | @@ -58,11 +58,13 @@ public: |
| 58 | 58 | const bool& operator() (const int& row, const int& inx = 0) const; |
| 59 | 59 | |
| 60 | 60 | // Implement virtual methods |
| 61 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 62 | - virtual double real(const int& row, const int& col = 0) const; | |
| 63 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 64 | - virtual void insert(const int& rownum, const int& nrows); | |
| 65 | - virtual void remove(const int& rownum, const int& nrows); | |
| 61 | + virtual void clear(void); | |
| 62 | + virtual GFitsTableBoolCol* clone(void) const; | |
| 63 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 64 | + virtual double real(const int& row, const int& col = 0) const; | |
| 65 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 66 | + virtual void insert(const int& rownum, const int& nrows); | |
| 67 | + virtual void remove(const int& rownum, const int& nrows); | |
| 66 | 68 | |
| 67 | 69 | // Other methods |
| 68 | 70 | bool* data(void) { return m_data; } |
| ... | ... | @@ -71,22 +73,21 @@ public: |
| 71 | 73 | |
| 72 | 74 | private: |
| 73 | 75 | // Private methods |
| 74 | - void init_members(void); | |
| 75 | - void copy_members(const GFitsTableBoolCol& column); | |
| 76 | - void free_members(void); | |
| 77 | - void save(void); | |
| 78 | - GFitsTableBoolCol* clone(void) const; | |
| 79 | - std::string ascii_format(void) const; | |
| 80 | - std::string binary_format(void) const; | |
| 81 | - void alloc_data(void); | |
| 82 | - void release_data(void); | |
| 83 | - void alloc_nulval(const bool* value); | |
| 84 | - void init_data(void); | |
| 85 | - void fetch_data(void) const; | |
| 86 | - void alloc_buffer(void); | |
| 87 | - void free_buffer(void); | |
| 88 | - void* ptr_data(void) { return m_buffer; } | |
| 89 | - void* ptr_nulval(void) { return m_nulval; } | |
| 76 | + void init_members(void); | |
| 77 | + void copy_members(const GFitsTableBoolCol& column); | |
| 78 | + void free_members(void); | |
| 79 | + void save(void); | |
| 80 | + std::string ascii_format(void) const; | |
| 81 | + std::string binary_format(void) const; | |
| 82 | + void alloc_data(void); | |
| 83 | + void release_data(void); | |
| 84 | + void alloc_nulval(const bool* value); | |
| 85 | + void init_data(void); | |
| 86 | + void fetch_data(void) const; | |
| 87 | + void alloc_buffer(void); | |
| 88 | + void free_buffer(void); | |
| 89 | + void* ptr_data(void) { return m_buffer; } | |
| 90 | + void* ptr_nulval(void) { return m_nulval; } | |
| 90 | 91 | |
| 91 | 92 | // Private data area |
| 92 | 93 | bool* m_data; //!< Data area | ... | ... |
include/GFitsTableByteCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableByteCol.hpp - FITS table Byte column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableByteCol.hpp |
| 23 | 23 | * @brief FITS table Byte column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEBYTECOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const unsigned char& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableByteCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | unsigned char* data(void) { return m_data; } |
| ... | ... | @@ -68,18 +70,17 @@ public: |
| 68 | 70 | |
| 69 | 71 | private: |
| 70 | 72 | // Private methods |
| 71 | - void init_members(void); | |
| 72 | - void copy_members(const GFitsTableByteCol& column); | |
| 73 | - void free_members(void); | |
| 74 | - GFitsTableByteCol* clone(void) const; | |
| 75 | - std::string ascii_format(void) const; | |
| 76 | - std::string binary_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const unsigned char* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(void) { return m_data; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableByteCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + std::string ascii_format(void) const; | |
| 77 | + std::string binary_format(void) const; | |
| 78 | + void alloc_data(void); | |
| 79 | + void release_data(void); | |
| 80 | + void alloc_nulval(const unsigned char* value); | |
| 81 | + void init_data(void); | |
| 82 | + void* ptr_data(void) { return m_data; } | |
| 83 | + void* ptr_nulval(void) { return m_nulval; } | |
| 83 | 84 | |
| 84 | 85 | // Private data area |
| 85 | 86 | unsigned char* m_data; //!< Data vector | ... | ... |
include/GFitsTableCDoubleCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableCDoubleCol.hpp - FITS table double precision complex column * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableCDoubleCol.hpp |
| 23 | 23 | * @brief FITS table double complex column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLECDOUBLECOL_HPP |
| ... | ... | @@ -56,11 +56,13 @@ public: |
| 56 | 56 | const GFits::cdouble& operator() (const int& row, const int& inx = 0) const; |
| 57 | 57 | |
| 58 | 58 | // Implement virtual methods |
| 59 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 60 | - virtual double real(const int& row, const int& col = 0) const; | |
| 61 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 62 | - virtual void insert(const int& rownum, const int& nrows); | |
| 63 | - virtual void remove(const int& rownum, const int& nrows); | |
| 59 | + virtual void clear(void); | |
| 60 | + virtual GFitsTableCDoubleCol* clone(void) const; | |
| 61 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 62 | + virtual double real(const int& row, const int& col = 0) const; | |
| 63 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 64 | + virtual void insert(const int& rownum, const int& nrows); | |
| 65 | + virtual void remove(const int& rownum, const int& nrows); | |
| 64 | 66 | |
| 65 | 67 | // Other methods |
| 66 | 68 | GFits::cdouble* data(void) { return m_data; } |
| ... | ... | @@ -69,18 +71,17 @@ public: |
| 69 | 71 | |
| 70 | 72 | private: |
| 71 | 73 | // Private methods |
| 72 | - void init_members(void); | |
| 73 | - void copy_members(const GFitsTableCDoubleCol& column); | |
| 74 | - void free_members(void); | |
| 75 | - GFitsTableCDoubleCol* clone(void) const; | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - std::string binary_format(void) const; | |
| 78 | - void alloc_data(void); | |
| 79 | - void release_data(void); | |
| 80 | - void alloc_nulval(const GFits::cdouble* value); | |
| 81 | - void init_data(void); | |
| 82 | - void* ptr_data(void) { return m_data; } | |
| 83 | - void* ptr_nulval(void) { return m_nulval; } | |
| 74 | + void init_members(void); | |
| 75 | + void copy_members(const GFitsTableCDoubleCol& column); | |
| 76 | + void free_members(void); | |
| 77 | + std::string ascii_format(void) const; | |
| 78 | + std::string binary_format(void) const; | |
| 79 | + void alloc_data(void); | |
| 80 | + void release_data(void); | |
| 81 | + void alloc_nulval(const GFits::cdouble* value); | |
| 82 | + void init_data(void); | |
| 83 | + void* ptr_data(void) { return m_data; } | |
| 84 | + void* ptr_nulval(void) { return m_nulval; } | |
| 84 | 85 | |
| 85 | 86 | // Private data area |
| 86 | 87 | GFits::cdouble* m_data; //!< Data vector | ... | ... |
include/GFitsTableCFloatCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableCFloatCol.hpp - FITS table single precision complex column * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableCFloatCol.hpp |
| 23 | 23 | * @brief FITS table float complex column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLECFLOATCOL_HPP |
| ... | ... | @@ -56,11 +56,13 @@ public: |
| 56 | 56 | const GFits::cfloat& operator() (const int& row, const int& inx = 0) const; |
| 57 | 57 | |
| 58 | 58 | // Implement virtual methods |
| 59 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 60 | - virtual double real(const int& row, const int& col = 0) const; | |
| 61 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 62 | - virtual void insert(const int& rownum, const int& nrows); | |
| 63 | - virtual void remove(const int& rownum, const int& nrows); | |
| 59 | + virtual void clear(void); | |
| 60 | + virtual GFitsTableCFloatCol* clone(void) const; | |
| 61 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 62 | + virtual double real(const int& row, const int& col = 0) const; | |
| 63 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 64 | + virtual void insert(const int& rownum, const int& nrows); | |
| 65 | + virtual void remove(const int& rownum, const int& nrows); | |
| 64 | 66 | |
| 65 | 67 | // Other methods |
| 66 | 68 | GFits::cfloat* data(void) { return m_data; } |
| ... | ... | @@ -69,18 +71,17 @@ public: |
| 69 | 71 | |
| 70 | 72 | private: |
| 71 | 73 | // Private methods |
| 72 | - void init_members(void); | |
| 73 | - void copy_members(const GFitsTableCFloatCol& column); | |
| 74 | - void free_members(void); | |
| 75 | - GFitsTableCFloatCol* clone(void) const; | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - std::string binary_format(void) const; | |
| 78 | - void alloc_data(void); | |
| 79 | - void release_data(void); | |
| 80 | - void alloc_nulval(const GFits::cfloat* value); | |
| 81 | - void init_data(void); | |
| 82 | - void* ptr_data(void) { return m_data; } | |
| 83 | - void* ptr_nulval(void) { return m_nulval; } | |
| 74 | + void init_members(void); | |
| 75 | + void copy_members(const GFitsTableCFloatCol& column); | |
| 76 | + void free_members(void); | |
| 77 | + std::string ascii_format(void) const; | |
| 78 | + std::string binary_format(void) const; | |
| 79 | + void alloc_data(void); | |
| 80 | + void release_data(void); | |
| 81 | + void alloc_nulval(const GFits::cfloat* value); | |
| 82 | + void init_data(void); | |
| 83 | + void* ptr_data(void) { return m_data; } | |
| 84 | + void* ptr_nulval(void) { return m_nulval; } | |
| 84 | 85 | |
| 85 | 86 | // Private data area |
| 86 | 87 | GFits::cfloat* m_data; //!< Data vector | ... | ... |
include/GFitsTableCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableCol.hpp - FITS table column abstract base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,17 +21,16 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableCol.hpp |
| 23 | 23 | * @brief FITS table column abstract base class definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLECOL_HPP |
| 28 | 28 | #define GFITSTABLECOL_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 33 | 32 | #include <vector> |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| ... | ... | @@ -41,15 +40,11 @@ |
| 41 | 40 | * |
| 42 | 41 | * This class implements a FITS table column. Vector columns are supported. |
| 43 | 42 | ***************************************************************************/ |
| 44 | -class GFitsTableCol { | |
| 43 | +class GFitsTableCol : public GBase { | |
| 45 | 44 | |
| 46 | 45 | // Friend classes |
| 47 | 46 | friend class GFitsTable; |
| 48 | 47 | |
| 49 | - // I/O friends | |
| 50 | - friend std::ostream& operator<< (std::ostream& os, const GFitsTableCol& column); | |
| 51 | - friend GLog& operator<< (GLog& log, const GFitsTableCol& column); | |
| 52 | - | |
| 53 | 48 | public: |
| 54 | 49 | // Constructors and destructors |
| 55 | 50 | GFitsTableCol(void); |
| ... | ... | @@ -61,12 +56,14 @@ public: |
| 61 | 56 | // Operators |
| 62 | 57 | GFitsTableCol& operator= (const GFitsTableCol& column); |
| 63 | 58 | |
| 64 | - // Virtual Methods | |
| 65 | - virtual std::string string(const int& row, const int& inx = 0) const = 0; | |
| 66 | - virtual double real(const int& row, const int& inx = 0) const = 0; | |
| 67 | - virtual int integer(const int& row, const int& inx = 0) const = 0; | |
| 68 | - virtual void insert(const int& rownum, const int& nrows) = 0; | |
| 69 | - virtual void remove(const int& rownum, const int& nrows) = 0; | |
| 59 | + // Pure virtual Methods | |
| 60 | + virtual void clear(void) = 0; | |
| 61 | + virtual GFitsTableCol* clone(void) const = 0; | |
| 62 | + virtual std::string string(const int& row, const int& inx = 0) const = 0; | |
| 63 | + virtual double real(const int& row, const int& inx = 0) const = 0; | |
| 64 | + virtual int integer(const int& row, const int& inx = 0) const = 0; | |
| 65 | + virtual void insert(const int& rownum, const int& nrows) = 0; | |
| 66 | + virtual void remove(const int& rownum, const int& nrows) = 0; | |
| 70 | 67 | |
| 71 | 68 | // Base class Methods |
| 72 | 69 | void name(const std::string& name); |
| ... | ... | @@ -105,24 +102,21 @@ protected: |
| 105 | 102 | void* m_fitsfile; //!< FITS file pointer associated with column |
| 106 | 103 | |
| 107 | 104 | // Protected pure virtual methods |
| 108 | - virtual GFitsTableCol* clone(void) const = 0; | |
| 109 | - virtual std::string ascii_format(void) const = 0; | |
| 110 | - virtual std::string binary_format(void) const = 0; | |
| 111 | - virtual void alloc_data(void) = 0; | |
| 112 | - virtual void init_data(void) = 0; | |
| 113 | - virtual void* ptr_data(void) = 0; | |
| 114 | - virtual void* ptr_nulval(void) = 0; | |
| 105 | + virtual std::string ascii_format(void) const = 0; | |
| 106 | + virtual std::string binary_format(void) const = 0; | |
| 107 | + virtual void alloc_data(void) = 0; | |
| 108 | + virtual void init_data(void) = 0; | |
| 109 | + virtual void* ptr_data(void) = 0; | |
| 110 | + virtual void* ptr_nulval(void) = 0; | |
| 115 | 111 | |
| 116 | 112 | // Protected virtual methods |
| 117 | - virtual void save(void); | |
| 118 | - virtual void fetch_data(void) const; | |
| 119 | - virtual void load_column(void); | |
| 120 | - virtual void save_column(void); | |
| 121 | - virtual std::ostream& dump_column(std::ostream& os) const; | |
| 122 | - virtual GLog& dump_column(GLog& log) const; | |
| 123 | - virtual int offset(const int& row, const int& inx) const; | |
| 113 | + virtual void save(void); | |
| 114 | + virtual void fetch_data(void) const; | |
| 115 | + virtual void load_column(void); | |
| 116 | + virtual void save_column(void); | |
| 117 | + virtual int offset(const int& row, const int& inx) const; | |
| 124 | 118 | |
| 125 | -private: | |
| 119 | +protected: | |
| 126 | 120 | // Private methods |
| 127 | 121 | void init_members(void); |
| 128 | 122 | void copy_members(const GFitsTableCol& column); | ... | ... |
include/GFitsTableDoubleCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableDoubleCol.hpp - FITS table double column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableDoubleCol.hpp |
| 23 | 23 | * @brief FITS table double column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEDOUBLECOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const double& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableDoubleCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | double* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableDoubleCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableDoubleCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableFloatCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableFloatCol.hpp - FITS table float column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const float& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableFloatCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | float* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableFloatCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableFloatCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableLongCol.hpp
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const long& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableLongCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | long* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableLongCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableLongCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableLongLongCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableLongLongCol.hpp - FITS table long long column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableLongLongCol.hpp |
| 23 | 23 | * @brief FITS table long long integer column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knodlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLELONGLONGCOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const long long& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableLongLongCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | long long* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableLongLongCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableLongLongCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableShortCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableShortCol.hpp - FITS table short column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableShortCol.hpp |
| 23 | 23 | * @brief FITS table short integer column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLESHORTCOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const short& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableShortCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | short* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableShortCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableShortCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableStringCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableStringCol.hpp - FITS table string column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableStringCol.hpp |
| 23 | 23 | * @brief FITS table string column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLESTRINGCOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const std::string& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableStringCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | std::string* data(void) { return m_data; } |
| ... | ... | @@ -72,7 +74,6 @@ private: |
| 72 | 74 | void copy_members(const GFitsTableStringCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | 76 | void save(void); |
| 75 | - GFitsTableStringCol* clone(void) const; | |
| 76 | 77 | std::string ascii_format(void) const; |
| 77 | 78 | std::string binary_format(void) const; |
| 78 | 79 | void alloc_data(void); | ... | ... |
include/GFitsTableULongCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableULongCol.hpp - FITS table unsigned long column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableULongCol.hpp |
| 23 | 23 | * @brief FITS table unsigned long integer column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEULONGCOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const unsigned long& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableULongCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | unsigned long* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableULongCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableULongCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GFitsTableUShortCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableUShortCol.hpp - FITS table unsigned short column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GFitsTableUShortCol.hpp |
| 23 | 23 | * @brief FITS table unsigned short integer column class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GFITSTABLEUSHORTCOL_HPP |
| ... | ... | @@ -55,11 +55,13 @@ public: |
| 55 | 55 | const unsigned short& operator() (const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| 57 | 57 | // Implement virtual methods |
| 58 | - virtual std::string string(const int& row, const int& col = 0) const; | |
| 59 | - virtual double real(const int& row, const int& col = 0) const; | |
| 60 | - virtual int integer(const int& row, const int& col = 0) const; | |
| 61 | - virtual void insert(const int& rownum, const int& nrows); | |
| 62 | - virtual void remove(const int& rownum, const int& nrows); | |
| 58 | + virtual void clear(void); | |
| 59 | + virtual GFitsTableUShortCol* clone(void) const; | |
| 60 | + virtual std::string string(const int& row, const int& col = 0) const; | |
| 61 | + virtual double real(const int& row, const int& col = 0) const; | |
| 62 | + virtual int integer(const int& row, const int& col = 0) const; | |
| 63 | + virtual void insert(const int& rownum, const int& nrows); | |
| 64 | + virtual void remove(const int& rownum, const int& nrows); | |
| 63 | 65 | |
| 64 | 66 | // Other methods |
| 65 | 67 | unsigned short* data(void) { return m_data; } |
| ... | ... | @@ -71,7 +73,6 @@ private: |
| 71 | 73 | void init_members(void); |
| 72 | 74 | void copy_members(const GFitsTableUShortCol& column); |
| 73 | 75 | void free_members(void); |
| 74 | - GFitsTableUShortCol* clone(void) const; | |
| 75 | 76 | std::string ascii_format(void) const; |
| 76 | 77 | std::string binary_format(void) const; |
| 77 | 78 | void alloc_data(void); | ... | ... |
include/GGti.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GGti.hpp - Good time interval class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GGti.hpp |
| 23 | 23 | * @brief Good time interval class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GGTI_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GFits.hpp" |
| 35 | 34 | #include "GFitsTable.hpp" |
| 36 | 35 | #include "GTime.hpp" |
| ... | ... | @@ -44,11 +43,7 @@ |
| 44 | 43 | * This class holds a list of Good Time Intervals, i.e. time intervals that |
| 45 | 44 | * are valid for science analysis. Times are stored using the GTime class. |
| 46 | 45 | ***************************************************************************/ |
| 47 | -class GGti { | |
| 48 | - | |
| 49 | - // I/O friends | |
| 50 | - friend std::ostream& operator<< (std::ostream& os, const GGti& gti); | |
| 51 | - friend GLog& operator<< (GLog& log, const GGti& gti); | |
| 46 | +class GGti : public GBase { | |
| 52 | 47 | |
| 53 | 48 | public: |
| 54 | 49 | // Constructors and destructors |
| ... | ... | @@ -61,6 +56,7 @@ public: |
| 61 | 56 | |
| 62 | 57 | // Methods |
| 63 | 58 | void clear(void); |
| 59 | + GGti* clone(void) const; | |
| 64 | 60 | int size(void) const { return m_num; } |
| 65 | 61 | void add(const GTime& tstart, const GTime& tstop); |
| 66 | 62 | void append(const GTime& tstart, const GTime& tstop); |
| ... | ... | @@ -88,7 +84,6 @@ protected: |
| 88 | 84 | void copy_members(const GGti& gti); |
| 89 | 85 | void free_members(void); |
| 90 | 86 | void set_attributes(void); |
| 91 | - GGti* clone(void) const; | |
| 92 | 87 | void insert_gti(int inx, const GTime& tstart, const GTime& tstop); |
| 93 | 88 | void merge_gtis(void); |
| 94 | 89 | ... | ... |
include/GInstDir.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GInstDir.hpp - Instrument direction abstract base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GInstDir.hpp |
| 23 | 23 | * @brief GInstDir abstract base class definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GINSTDIR_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | |
| 35 | 34 | |
| 36 | 35 | /***********************************************************************//** |
| ... | ... | @@ -45,11 +44,7 @@ |
| 45 | 44 | * reconstructions for imaging devices or detector numbers etc. for |
| 46 | 45 | * non-imaging devices. |
| 47 | 46 | ***************************************************************************/ |
| 48 | -class GInstDir { | |
| 49 | - | |
| 50 | - // I/O friends | |
| 51 | - friend std::ostream& operator<< (std::ostream& os, const GInstDir& dir); | |
| 52 | - friend GLog& operator<< (GLog& log, const GInstDir& dir); | |
| 47 | +class GInstDir : public GBase { | |
| 53 | 48 | |
| 54 | 49 | public: |
| 55 | 50 | // Constructors and destructors | ... | ... |
include/GIntegral.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GIntegral.hpp - Integration class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GIntegral.hpp |
| 23 | 23 | * @brief Integration class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GINTEGRAL_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GIntegrand.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -42,11 +41,7 @@ |
| 42 | 41 | * This class allows to perform integration using various methods. The |
| 43 | 42 | * integrand is implemented by a derived class of GIntegrand. |
| 44 | 43 | ***************************************************************************/ |
| 45 | -class GIntegral { | |
| 46 | - | |
| 47 | - // I/O friends | |
| 48 | - friend std::ostream& operator<<(std::ostream& os, const GIntegral& integral); | |
| 49 | - friend GLog& operator<<(GLog& log, const GIntegral& integral); | |
| 44 | +class GIntegral : public GBase { | |
| 50 | 45 | |
| 51 | 46 | public: |
| 52 | 47 | ... | ... |
include/GMatrix.hpp
| ... | ... | @@ -29,8 +29,6 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 34 | 32 | #include "GMatrixBase.hpp" |
| 35 | 33 | |
| 36 | 34 | /* __ Forward declarations _______________________________________________ */ |
| ... | ... | @@ -49,10 +47,6 @@ class GSparseMatrix; |
| 49 | 47 | ***************************************************************************/ |
| 50 | 48 | class GMatrix : public GMatrixBase { |
| 51 | 49 | |
| 52 | - // I/O friends | |
| 53 | - friend std::ostream& operator<<(std::ostream& os, const GMatrix& matrix); | |
| 54 | - friend GLog& operator<<(GLog& log, const GMatrix& matrix); | |
| 55 | - | |
| 56 | 50 | // Binary operator friends |
| 57 | 51 | friend GMatrix operator*(const double& a, const GMatrix& b); |
| 58 | 52 | friend GMatrix operator*(const GMatrix& a, const double& b); |
| ... | ... | @@ -91,6 +85,7 @@ public: |
| 91 | 85 | |
| 92 | 86 | // Implemented pure virtual base class methods |
| 93 | 87 | void clear(void); |
| 88 | + GMatrix* clone(void) const; | |
| 94 | 89 | void transpose(void); |
| 95 | 90 | void invert(void); |
| 96 | 91 | void add_col(const GVector& vector, const int& col); |
| ... | ... | @@ -179,7 +174,6 @@ GMatrix GMatrix::operator-(void) const |
| 179 | 174 | /*************************************************************************** |
| 180 | 175 | * Inline methods * |
| 181 | 176 | ***************************************************************************/ |
| 182 | -inline void GMatrix::clear(void) { set_all_elements(0.0); } | |
| 183 | 177 | inline double GMatrix::min(void) const { return get_min_element(); } |
| 184 | 178 | inline double GMatrix::max(void) const { return get_max_element(); } |
| 185 | 179 | inline double GMatrix::sum(void) const { return get_element_sum(); } | ... | ... |
include/GMatrixBase.hpp
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | +#include "GBase.hpp" | |
| 32 | 33 | #include "GVector.hpp" |
| 33 | 34 | |
| 34 | 35 | |
| ... | ... | @@ -41,7 +42,7 @@ |
| 41 | 42 | * common interface of the matrix objects and provides some common services |
| 42 | 43 | * to the derived classes. |
| 43 | 44 | ***************************************************************************/ |
| 44 | -class GMatrixBase { | |
| 45 | +class GMatrixBase : public GBase { | |
| 45 | 46 | |
| 46 | 47 | public: |
| 47 | 48 | // Constructors and destructors |
| ... | ... | @@ -60,22 +61,23 @@ public: |
| 60 | 61 | virtual bool operator!=(const GMatrixBase& matrix) const; |
| 61 | 62 | |
| 62 | 63 | // Pure virtual methods |
| 63 | - virtual void clear() = 0; | |
| 64 | - virtual void transpose() = 0; | |
| 65 | - virtual void invert() = 0; | |
| 66 | - virtual void add_col(const GVector& vector, const int& col) = 0; | |
| 67 | - virtual void insert_col(const GVector& vector, const int& col) = 0; | |
| 68 | - virtual GVector extract_row(const int& row) const = 0; | |
| 69 | - virtual GVector extract_col(const int& col) const = 0; | |
| 70 | - virtual double fill(void) const = 0; | |
| 71 | - virtual double min(void) const = 0; | |
| 72 | - virtual double max(void) const = 0; | |
| 73 | - virtual double sum(void) const = 0; | |
| 74 | - virtual std::string print(void) const = 0; | |
| 64 | + virtual void clear(void) = 0; | |
| 65 | + virtual GMatrixBase* clone(void) const = 0; | |
| 66 | + virtual void transpose(void) = 0; | |
| 67 | + virtual void invert(void) = 0; | |
| 68 | + virtual void add_col(const GVector& vector, const int& col) = 0; | |
| 69 | + virtual void insert_col(const GVector& vector, const int& col) = 0; | |
| 70 | + virtual GVector extract_row(const int& row) const = 0; | |
| 71 | + virtual GVector extract_col(const int& col) const = 0; | |
| 72 | + virtual double fill(void) const = 0; | |
| 73 | + virtual double min(void) const = 0; | |
| 74 | + virtual double max(void) const = 0; | |
| 75 | + virtual double sum(void) const = 0; | |
| 76 | + virtual std::string print(void) const = 0; | |
| 75 | 77 | |
| 76 | 78 | // Implemented base class methods |
| 77 | - virtual int cols(void) const { return m_cols; } | |
| 78 | - virtual int rows(void) const { return m_rows; } | |
| 79 | + virtual int cols(void) const { return m_cols; } | |
| 80 | + virtual int rows(void) const { return m_rows; } | |
| 79 | 81 | |
| 80 | 82 | protected: |
| 81 | 83 | // Protected methods | ... | ... |
include/GModel.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModel.hpp - Abstract virtual model base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModel.hpp |
| 23 | 23 | * @brief Abstract model base class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODEL_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GModelPar.hpp" |
| 36 | 35 | #include "GXmlElement.hpp" |
| 37 | 36 | #include "GEnergy.hpp" |
| ... | ... | @@ -62,11 +61,7 @@ class GObservation; |
| 62 | 61 | * model parameters. This will be done by the classes that actually |
| 63 | 62 | * implement the model parameters. |
| 64 | 63 | ***************************************************************************/ |
| 65 | -class GModel { | |
| 66 | - | |
| 67 | - // I/O friends | |
| 68 | - friend std::ostream& operator<< (std::ostream& os, const GModel& model); | |
| 69 | - friend GLog& operator<< (GLog& log, const GModel& model); | |
| 64 | +class GModel : public GBase { | |
| 70 | 65 | |
| 71 | 66 | public: |
| 72 | 67 | // Constructors and destructors | ... | ... |
include/GModelPar.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelPar.hpp - Model parameter class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelPar.hpp |
| 23 | 23 | * @brief Model parameter class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELPAR_HPP |
| ... | ... | @@ -29,9 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 34 | -#include "GException.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 35 | 33 | #include "GXmlElement.hpp" |
| 36 | 34 | |
| 37 | 35 | |
| ... | ... | @@ -54,11 +52,7 @@ |
| 54 | 52 | * Each parameter has a name, and holds optionally information about its |
| 55 | 53 | * gradient (if "hasgrad" is true). |
| 56 | 54 | ***************************************************************************/ |
| 57 | -class GModelPar { | |
| 58 | - | |
| 59 | - // I/O friends | |
| 60 | - friend std::ostream& operator<<(std::ostream& os, const GModelPar& par); | |
| 61 | - friend GLog& operator<<(GLog& log, const GModelPar& par); | |
| 55 | +class GModelPar : public GBase { | |
| 62 | 56 | |
| 63 | 57 | public: |
| 64 | 58 | // Constructors and destructors | ... | ... |
include/GModelRadialRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRadialRegistry.hpp - Radial spatial model registry class * | |
| 2 | + * GModelRadialRegistry.hpp - Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRadialRegistry.hpp |
| 23 | - * @brief Radial spatial model class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Radial model registry class interface definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELRADIALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelRadial.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelRadialRegistry |
| 39 | 38 | * |
| 40 | - * @brief Radial spatial model registry class | |
| 39 | + * @brief Radial model registry class | |
| 41 | 40 | * |
| 42 | - * The registry class allows the registration of radial spatial models that | |
| 43 | - * are not necessarily compiled into the GammaLib. It uses the static members | |
| 41 | + * The registry class allows the registration of radial models that are not | |
| 42 | + * necessarily compiled into the GammaLib. It uses the static members | |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | - * of radial spatial models that are available throughout all linked | |
| 46 | - * libraries. To register a radial spatial model it is sufficient to add | |
| 47 | - * const GModelRadialXXX g_radial_XXX_seed; | |
| 48 | - * const GModelRadialRegistry g_radial_XXX_registry(&g_radial_XXX_seed); | |
| 49 | - * at the top of the .cpp file of the radial spatial model. Here, XXX is a | |
| 50 | - * unique name that describes the model. | |
| 44 | + * of radial models that are available throughout all linked libraries. To | |
| 45 | + * register a radial model it is sufficient to add | |
| 46 | + * | |
| 47 | + * const GModelRadialXXX g_radial_XXX_seed; | |
| 48 | + * const GModelRadialRegistry g_radial_XXX_registry(&g_radial_XXX_seed); | |
| 49 | + * | |
| 50 | + * at the top of the .cpp file of the radial model. Here, XXX is a unique | |
| 51 | + * name that describes the model. | |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelRadialRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelRadialRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelRadialRegistry& registry); | |
| 53 | +class GModelRadialRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelRadial* alloc(const std::string& type) const; | |
| 67 | + GModelRadial* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRegistry.hpp - Model registry class * | |
| 2 | + * GModelRegistry.hpp - Model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRegistry.hpp |
| 23 | - * @brief GModelRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModel.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the model registry class. | |
| 39 | + * @brief Interface definition for the model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of models that are available throughout all linked libraries. To register |
| 46 | 45 | * a model it is sufficient to add |
| 47 | - * const GModelXXX g_XXX_seed; | |
| 48 | - * const GModelRegistry g_XXX_registry(&g_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelXXX g_XXX_seed; | |
| 48 | + * const GModelRegistry g_XXX_registry(&g_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the model. Here, XXX is a unique name that |
| 50 | 51 | * describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelRegistry& registry); | |
| 53 | +class GModelRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModel* alloc(const std::string& type) const; | |
| 67 | + GModel* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelSpatial.hpp
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GModelPar.hpp" |
| 36 | 35 | #include "GSkyDir.hpp" |
| 37 | 36 | #include "GXmlElement.hpp" |
| ... | ... | @@ -47,11 +46,7 @@ |
| 47 | 46 | * source model. A typical example of a spatial component is a point source |
| 48 | 47 | * (implemented by the derived class GModelSpatialPtsrc). |
| 49 | 48 | ***************************************************************************/ |
| 50 | -class GModelSpatial { | |
| 51 | - | |
| 52 | - // I/O friends | |
| 53 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpatial& model); | |
| 54 | - friend GLog& operator<<(GLog& log, const GModelSpatial& model); | |
| 49 | +class GModelSpatial : public GBase { | |
| 55 | 50 | |
| 56 | 51 | public: |
| 57 | 52 | // Constructors and destructors | ... | ... |
include/GModelSpatialRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpatialRegistry.hpp - Spatial model registry class * | |
| 2 | + * GModelSpatialRegistry.hpp - Spatial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpatialRegistry.hpp |
| 23 | - * @brief GModelSpatialRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spatial model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELSPATIALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelSpatial.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelSpatialRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the spatial model registry class. | |
| 39 | + * @brief Interface definition for the spatial model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of spatial models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of spatial models that are available throughout all linked libraries. To |
| 46 | 45 | * register a spatial model it is sufficient to add |
| 47 | - * const GModelSpatialXXX g_spatial_XXX_seed; | |
| 48 | - * const GModelSpatialRegistry g_spatial_XXX_registry(&g_spatial_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelSpatialXXX g_spatial_XXX_seed; | |
| 48 | + * const GModelSpatialRegistry g_spatial_XXX_registry(&g_spatial_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the spatial model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelSpatialRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpatialRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelSpatialRegistry& registry); | |
| 53 | +class GModelSpatialRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelSpatial* alloc(const std::string& type) const; | |
| 67 | + GModelSpatial* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelSpectral.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpectral.hpp - Abstract spectral model base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpectral.hpp |
| 23 | 23 | * @brief Abstract spectral model base class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELSPECTRAL_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GModelPar.hpp" |
| 36 | 35 | #include "GEnergy.hpp" |
| 37 | 36 | #include "GRan.hpp" |
| ... | ... | @@ -46,11 +45,7 @@ |
| 46 | 45 | * This class implements the spectral component of the factorised source |
| 47 | 46 | * model. |
| 48 | 47 | ***************************************************************************/ |
| 49 | -class GModelSpectral { | |
| 50 | - | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpectral& model); | |
| 53 | - friend GLog& operator<<(GLog& log, const GModelSpectral& model); | |
| 48 | +class GModelSpectral : public GBase { | |
| 54 | 49 | |
| 55 | 50 | public: |
| 56 | 51 | // Constructors and destructors | ... | ... |
include/GModelSpectralRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpectralRegistry.hpp - Spectral model registry class * | |
| 2 | + * GModelSpectralRegistry.hpp - Spectral model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpectralRegistry.hpp |
| 23 | - * @brief GModelSpectralRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spectral model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELSPECTRALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelSpectral.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelSpectralRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the spectral model registry class. | |
| 39 | + * @brief Interface definition for the spectral model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of spectral models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of spectral models that are available throughout all linked libraries. To |
| 46 | 45 | * register a spectral model it is sufficient to add |
| 47 | - * const GModelSpectralXXX g_spectral_XXX_seed; | |
| 48 | - * const GModelSpectralRegistry g_spectral_XXX_registry(&g_spectral_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelSpectralXXX g_spectral_XXX_seed; | |
| 48 | + * const GModelSpectralRegistry g_spectral_XXX_registry(&g_spectral_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the spectral model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelSpectralRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpectralRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelSpectralRegistry& registry); | |
| 53 | +class GModelSpectralRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelSpectral* alloc(const std::string& type) const; | |
| 67 | + GModelSpectral* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelTemporal.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelTemporal.hpp - Abstract temporal model base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelTemporal.hpp |
| 23 | 23 | * @brief Abstract temporal model base class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELTEMPORAL_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GModelPar.hpp" |
| 36 | 35 | #include "GTime.hpp" |
| 37 | 36 | #include "GRan.hpp" |
| ... | ... | @@ -48,11 +47,7 @@ |
| 48 | 47 | * that is given by the spectral component. Normally, this model will have |
| 49 | 48 | * a mean value of 1. |
| 50 | 49 | ***************************************************************************/ |
| 51 | -class GModelTemporal { | |
| 52 | - | |
| 53 | - // I/O friends | |
| 54 | - friend std::ostream& operator<<(std::ostream& os, const GModelTemporal& model); | |
| 55 | - friend GLog& operator<<(GLog& log, const GModelTemporal& model); | |
| 50 | +class GModelTemporal : public GBase { | |
| 56 | 51 | |
| 57 | 52 | public: |
| 58 | 53 | // Constructors and destructors | ... | ... |
include/GModelTemporalRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelTemporalRegistry.hpp - Temporal model registry class * | |
| 2 | + * GModelTemporalRegistry.hpp - Temporal model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelTemporalRegistry.hpp |
| 23 | - * @brief GModelTemporalRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Temporal model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELTEMPORALREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelTemporal.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,16 +43,14 @@ |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of temporal models that are available throughout all linked libraries. To |
| 46 | 45 | * register a temporal model it is sufficient to add |
| 47 | - * const GModelTemporalXXX g_temporal_XXX_seed; | |
| 48 | - * const GModelTemporalRegistry g_temporal_XXX_registry(&g_spectral_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelTemporalXXX g_temporal_XXX_seed; | |
| 48 | + * const GModelTemporalRegistry g_temporal_XXX_registry(&g_spectral_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the temporal model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelTemporalRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelTemporalRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelTemporalRegistry& registry); | |
| 53 | +class GModelTemporalRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelTemporal* alloc(const std::string& type) const; | |
| 67 | + GModelTemporal* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModels.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModels.hpp - Model container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,15 +21,14 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModels.hpp |
| 23 | 23 | * @brief Model container class definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELS_HPP |
| 28 | 28 | #define GMODELS_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | -#include "GLog.hpp" | |
| 31 | +#include <string> | |
| 33 | 32 | #include "GOptimizerPars.hpp" |
| 34 | 33 | #include "GModel.hpp" |
| 35 | 34 | #include "GXml.hpp" |
| ... | ... | @@ -47,13 +46,13 @@ class GObservation; |
| 47 | 46 | * This container class collects models of gamma-ray data that are used |
| 48 | 47 | * for maximum likelihood fitting. It derives from the optimizer parameter |
| 49 | 48 | * class GOptimizerPars. |
| 49 | + * | |
| 50 | + * @todo Add extend method to append a container to the container | |
| 51 | + * @todo Add insert method to insert a model into the container | |
| 52 | + * @todo Add pop method to delete a model from the container (default: last) | |
| 50 | 53 | ***************************************************************************/ |
| 51 | 54 | class GModels : public GOptimizerPars { |
| 52 | 55 | |
| 53 | - // I/O friends | |
| 54 | - friend std::ostream& operator<<(std::ostream& os, const GModels& models); | |
| 55 | - friend GLog& operator<<(GLog& log, const GModels& models); | |
| 56 | - | |
| 57 | 56 | public: |
| 58 | 57 | // Constructors and destructors |
| 59 | 58 | GModels(void); |
| ... | ... | @@ -63,16 +62,18 @@ public: |
| 63 | 62 | |
| 64 | 63 | // Operators |
| 65 | 64 | GModels& operator=(const GModels& models); |
| 66 | - GModel& operator[](const int& index); | |
| 67 | - const GModel& operator[](const int& index) const; | |
| 68 | - GModel& operator[](const std::string& name); | |
| 69 | - const GModel& operator[](const std::string& name) const; | |
| 65 | + GModel* operator[](const int& index); | |
| 66 | + const GModel* operator[](const int& index) const; | |
| 67 | + GModel* operator[](const std::string& name); | |
| 68 | + const GModel* operator[](const std::string& name) const; | |
| 70 | 69 | |
| 71 | 70 | // Methods |
| 72 | 71 | void clear(void); |
| 73 | 72 | GModels* clone(void) const; |
| 74 | 73 | int size(void) const { return m_models.size(); } |
| 75 | 74 | void append(const GModel& model); |
| 75 | + void set(const int& index, const GModel& model); | |
| 76 | + void set(const std::string& name, const GModel& model); | |
| 76 | 77 | void load(const std::string& filename); |
| 77 | 78 | void save(const std::string& filename) const; |
| 78 | 79 | void read(const GXml& xml); |
| ... | ... | @@ -87,6 +88,7 @@ protected: |
| 87 | 88 | void copy_members(const GModels& models); |
| 88 | 89 | void free_members(void); |
| 89 | 90 | void set_pointers(void); |
| 91 | + int get_index(const std::string& name) const; | |
| 90 | 92 | |
| 91 | 93 | // Proteced members |
| 92 | 94 | std::vector<GModel*> m_models; //!< List of models | ... | ... |
include/GNodeArray.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GNodeArray.hpp |
| 23 | 23 | * @brief Node array class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GNODEARRAY_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GVector.hpp" |
| 36 | 35 | |
| 37 | 36 | |
| ... | ... | @@ -53,11 +52,7 @@ |
| 53 | 52 | * wgt_left() and wgt_right(). |
| 54 | 53 | * If the nodes are equally spaced, interpolation is more rapid. |
| 55 | 54 | ***************************************************************************/ |
| 56 | -class GNodeArray { | |
| 57 | - | |
| 58 | - // I/O friends | |
| 59 | - friend std::ostream& operator<<(std::ostream& os, const GNodeArray& array); | |
| 60 | - friend GLog& operator<<(GLog& log, const GNodeArray& array); | |
| 55 | +class GNodeArray : public GBase { | |
| 61 | 56 | |
| 62 | 57 | public: |
| 63 | 58 | // Constructors and destructors | ... | ... |
include/GNumerics.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GNumerics.hpp - Numerical functions * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2012 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GNumerics.hpp | |
| 23 | + * @brief Numerical function definitions | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GNUMERICS_HPP | |
| 28 | +#define GNUMERICS_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | + | |
| 32 | +/* __ Namespaces _________________________________________________________ */ | |
| 33 | + | |
| 34 | +/* __ Constants __________________________________________________________ */ | |
| 35 | + | |
| 36 | +/* __ Prototypes _________________________________________________________ */ | |
| 37 | +double gammln(const double& x); | |
| 38 | + | |
| 39 | +#endif /* GNUMERICS_HPP */ | ... | ... |
include/GObservation.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservation.hpp |
| 23 | 23 | * @brief Abstract observation base class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOBSERVATION_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GEvents.hpp" |
| 35 | 34 | #include "GResponse.hpp" |
| 36 | 35 | #include "GPointing.hpp" |
| ... | ... | @@ -59,14 +58,7 @@ |
| 59 | 58 | * that implement instrument specific observations in order to optimize the |
| 60 | 59 | * execution speed for data analysis. |
| 61 | 60 | ***************************************************************************/ |
| 62 | -class GObservation { | |
| 63 | - | |
| 64 | - // Friend classes | |
| 65 | - //friend class GObservations; | |
| 66 | - | |
| 67 | - // I/O friends | |
| 68 | - friend std::ostream& operator<< (std::ostream& os, const GObservation& obs); | |
| 69 | - friend GLog& operator<< (GLog& log, const GObservation& obs); | |
| 61 | +class GObservation : public GBase { | |
| 70 | 62 | |
| 71 | 63 | public: |
| 72 | 64 | // Constructors and destructors | ... | ... |
include/GObservationRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GObservationRegistry.hpp - Observation registry class * | |
| 2 | + * GObservationRegistry.hpp - Observation registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservationRegistry.hpp |
| 23 | - * @brief GObservationRegistry class interface definition | |
| 24 | - * @author J. Knoedlseder | |
| 23 | + * @brief Observation registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOBSERVATIONREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GObservation.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,17 +43,15 @@ |
| 44 | 43 | * m_number, m_names, and m_obs which are allocated globally to keep track |
| 45 | 44 | * of observations that are available throughout all linked libraries. To |
| 46 | 45 | * register an observation it is sufficient to add |
| 47 | - * const GXXXObservation g_obs_XXX_seed; | |
| 48 | - * const GObservationRegistry g_obs_XXX_registry(&g_obs_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GXXXObservation g_obs_XXX_seed; | |
| 48 | + * const GObservationRegistry g_obs_XXX_registry(&g_obs_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the observation. Here, XXX is a unique |
| 50 | 51 | * name that describes the instrument for which the observation class is |
| 51 | 52 | * implemented. |
| 52 | 53 | ***************************************************************************/ |
| 53 | -class GObservationRegistry { | |
| 54 | - | |
| 55 | - // I/O friends | |
| 56 | - friend std::ostream& operator<<(std::ostream& os, const GObservationRegistry& registry); | |
| 57 | - friend GLog& operator<<(GLog& log, const GObservationRegistry& registry); | |
| 54 | +class GObservationRegistry : public GRegistry { | |
| 58 | 55 | |
| 59 | 56 | public: |
| 60 | 57 | // Constructors and destructors |
| ... | ... | @@ -68,8 +65,8 @@ public: |
| 68 | 65 | |
| 69 | 66 | // Methods |
| 70 | 67 | int size(void) const { return m_number; } |
| 71 | - GObservation* alloc(const std::string& instrument) const; | |
| 72 | - std::string instrument(const int& index) const; | |
| 68 | + GObservation* alloc(const std::string& name) const; | |
| 69 | + std::string name(const int& index) const; | |
| 73 | 70 | std::string print(void) const; |
| 74 | 71 | |
| 75 | 72 | protected: | ... | ... |
include/GObservations.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GObservations.hpp - Observation container class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservations.hpp |
| 23 | 23 | * @brief Observations container class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOBSERVATIONS_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GObservation.hpp" |
| 36 | 35 | #include "GEvent.hpp" |
| 37 | 36 | #include "GOptimizer.hpp" |
| ... | ... | @@ -61,11 +60,7 @@ |
| 61 | 60 | * @todo Use std::vector for building a list of pointers to observations |
| 62 | 61 | * instead of a proper memory handling implementation. |
| 63 | 62 | ***************************************************************************/ |
| 64 | -class GObservations { | |
| 65 | - | |
| 66 | - // I/O friends | |
| 67 | - friend std::ostream& operator<<(std::ostream& os, const GObservations& obs); | |
| 68 | - friend GLog& operator<<(GLog& log, const GObservations& obs); | |
| 63 | +class GObservations : public GBase { | |
| 69 | 64 | |
| 70 | 65 | public: |
| 71 | 66 | // Constructors and destructors |
| ... | ... | @@ -80,19 +75,20 @@ public: |
| 80 | 75 | const GObservation& operator[](const int& index) const; |
| 81 | 76 | |
| 82 | 77 | // Methods |
| 83 | - void clear(void); | |
| 84 | - int size(void) const { return m_obs.size(); } | |
| 85 | - void append(GObservation& obs); | |
| 86 | - void load(const std::string& filename); | |
| 87 | - void save(const std::string& filename) const; | |
| 88 | - void read(const GXml& xml); | |
| 89 | - void write(GXml& xml) const; | |
| 90 | - void models(const GModels& models) { m_models=models;} | |
| 91 | - void models(const std::string& filename); | |
| 92 | - GModels& models(void) { return m_models; } | |
| 93 | - void optimize(GOptimizer& opt); | |
| 94 | - double npred(void) const { return m_npred; } | |
| 95 | - std::string print(void) const; | |
| 78 | + void clear(void); | |
| 79 | + GObservations* clone(void) const; | |
| 80 | + int size(void) const { return m_obs.size(); } | |
| 81 | + void append(GObservation& obs); | |
| 82 | + void load(const std::string& filename); | |
| 83 | + void save(const std::string& filename) const; | |
| 84 | + void read(const GXml& xml); | |
| 85 | + void write(GXml& xml) const; | |
| 86 | + void models(const GModels& models) { m_models=models;} | |
| 87 | + void models(const std::string& filename); | |
| 88 | + GModels& models(void) { return m_models; } | |
| 89 | + void optimize(GOptimizer& opt); | |
| 90 | + double npred(void) const { return m_npred; } | |
| 91 | + std::string print(void) const; | |
| 96 | 92 | |
| 97 | 93 | // Event iterator |
| 98 | 94 | class iterator { |
| ... | ... | @@ -165,9 +161,9 @@ public: |
| 165 | 161 | |
| 166 | 162 | protected: |
| 167 | 163 | // Protected methods |
| 168 | - void init_members(void); | |
| 169 | - void copy_members(const GObservations& obs); | |
| 170 | - void free_members(void); | |
| 164 | + void init_members(void); | |
| 165 | + void copy_members(const GObservations& obs); | |
| 166 | + void free_members(void); | |
| 171 | 167 | |
| 172 | 168 | // Protected members |
| 173 | 169 | std::vector<GObservation*> m_obs; //!< List of observations | ... | ... |
include/GOptimizer.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GOptimizer.hpp - Abstract base class for optimizer * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GOptimizer.hpp |
| 23 | 23 | * @brief Optimizer abstract base class interface definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOPTIMIZER_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GOptimizerPars.hpp" |
| 35 | 34 | #include "GOptimizerFunction.hpp" |
| 36 | 35 | #include "GModels.hpp" |
| ... | ... | @@ -43,11 +42,7 @@ |
| 43 | 42 | * |
| 44 | 43 | * This class defines the abstract interface for the optimizer class. |
| 45 | 44 | ***************************************************************************/ |
| 46 | -class GOptimizer { | |
| 47 | - | |
| 48 | - // I/O friends | |
| 49 | - friend std::ostream& operator<<(std::ostream& os, const GOptimizer& opt); | |
| 50 | - friend GLog& operator<<(GLog& log, const GOptimizer& opt); | |
| 45 | +class GOptimizer : public GBase { | |
| 51 | 46 | |
| 52 | 47 | public: |
| 53 | 48 | // Constructors and destructors | ... | ... |
include/GOptimizerPars.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GOptimizerPars.hpp - Optimizer parameter container class * | |
| 2 | + * GOptimizerPars.hpp - Optimizer parameters abstract base class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2009-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GOptimizerPars.hpp |
| 23 | - * @brief Optimizer parameter container class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Optimizer parameters abstract base class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOPTIMIZERPARS_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GModelPar.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -53,11 +52,7 @@ |
| 53 | 52 | * very clean. We should think about how we can make this a clean |
| 54 | 53 | * thing ... |
| 55 | 54 | ***************************************************************************/ |
| 56 | -class GOptimizerPars { | |
| 57 | - | |
| 58 | - // I/O friends | |
| 59 | - friend std::ostream& operator<<(std::ostream& os, const GOptimizerPars& pars); | |
| 60 | - friend GLog& operator<<(GLog& log, const GOptimizerPars& pars); | |
| 55 | +class GOptimizerPars : public GBase { | |
| 61 | 56 | |
| 62 | 57 | public: |
| 63 | 58 | // Constructors and destructors |
| ... | ... | @@ -69,11 +64,13 @@ public: |
| 69 | 64 | virtual GOptimizerPars& operator=(const GOptimizerPars& pars); |
| 70 | 65 | |
| 71 | 66 | // Methods |
| 72 | - int npars(void) const { return m_pars.size(); } | |
| 73 | - int nfree(void) const; | |
| 74 | - GModelPar& par(const int& index); | |
| 75 | - const GModelPar& par(const int& index) const; | |
| 76 | - std::string print(void) const; | |
| 67 | + virtual void clear(void); | |
| 68 | + virtual GOptimizerPars* clone(void) const; | |
| 69 | + virtual int npars(void) const { return m_pars.size(); } | |
| 70 | + virtual int nfree(void) const; | |
| 71 | + virtual GModelPar& par(const int& index); | |
| 72 | + virtual const GModelPar& par(const int& index) const; | |
| 73 | + virtual std::string print(void) const; | |
| 77 | 74 | |
| 78 | 75 | protected: |
| 79 | 76 | // Protected methods | ... | ... |
include/GPar.hpp
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | |
| 35 | 34 | |
| 36 | 35 | /***********************************************************************//** |
| ... | ... | @@ -38,16 +37,12 @@ |
| 38 | 37 | * |
| 39 | 38 | * @brief Application parameter class interface defintion. |
| 40 | 39 | ***************************************************************************/ |
| 41 | -class GPar { | |
| 40 | +class GPar : public GBase { | |
| 42 | 41 | |
| 43 | 42 | // Friend classes |
| 44 | 43 | friend class GPars; |
| 45 | 44 | friend class GApplication; |
| 46 | 45 | |
| 47 | - // I/O friends | |
| 48 | - friend std::ostream& operator<<(std::ostream& os, const GPar& par); | |
| 49 | - friend GLog& operator<<(GLog& log, const GPar& par); | |
| 50 | - | |
| 51 | 46 | public: |
| 52 | 47 | // Constructors and destructors |
| 53 | 48 | GPar(void); |
| ... | ... | @@ -62,6 +57,7 @@ public: |
| 62 | 57 | GPar& operator= (const GPar& par); |
| 63 | 58 | |
| 64 | 59 | // Methods |
| 60 | + void clear(void); | |
| 65 | 61 | GPar* clone(void) const; |
| 66 | 62 | void type(const std::string& type); |
| 67 | 63 | void mode(const std::string& mode); | ... | ... |
include/GPars.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GPars.hpp - Application parameters * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPars.hpp |
| 23 | 23 | * @brief Application parameter container class definition |
| 24 | - * @author Jurgen Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GPARS_HPP |
| ... | ... | @@ -30,9 +30,8 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 33 | +#include "GBase.hpp" | |
| 34 | 34 | #include "GPar.hpp" |
| 35 | -#include "GLog.hpp" | |
| 36 | 35 | |
| 37 | 36 | |
| 38 | 37 | /***********************************************************************//** |
| ... | ... | @@ -42,15 +41,11 @@ |
| 42 | 41 | * |
| 43 | 42 | * This class holds a collection of application parameters. |
| 44 | 43 | ***************************************************************************/ |
| 45 | -class GPars { | |
| 44 | +class GPars : public GBase { | |
| 46 | 45 | |
| 47 | 46 | // Friend classes |
| 48 | 47 | friend class GApplication; |
| 49 | 48 | |
| 50 | - // I/O friends | |
| 51 | - friend std::ostream& operator<<(std::ostream& os, const GPars& pars); | |
| 52 | - friend GLog& operator<<(GLog& log, const GPars& pars); | |
| 53 | - | |
| 54 | 49 | public: |
| 55 | 50 | // Constructors and destructors |
| 56 | 51 | GPars(void); | ... | ... |
include/GPhoton.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GPhoton.hpp - Photon class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPhoton.hpp |
| 23 | 23 | * @brief Photon class definition. |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GPHOTON_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GSkyDir.hpp" |
| 36 | 35 | #include "GEnergy.hpp" |
| 37 | 36 | #include "GTime.hpp" |
| ... | ... | @@ -46,11 +45,7 @@ |
| 46 | 45 | * photon arrival direction, its energy and its arrival time. This class is |
| 47 | 46 | * mainly used for Monte Carlo simulations. |
| 48 | 47 | ***************************************************************************/ |
| 49 | -class GPhoton { | |
| 50 | - | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<< (std::ostream& os, const GPhoton& ph); | |
| 53 | - friend GLog& operator<< (GLog& log, const GPhoton& ph); | |
| 48 | +class GPhoton : public GBase { | |
| 54 | 49 | |
| 55 | 50 | // Operator friends |
| 56 | 51 | friend bool operator== (const GPhoton &a, const GPhoton &b); |
| ... | ... | @@ -67,6 +62,7 @@ public: |
| 67 | 62 | |
| 68 | 63 | // Methods |
| 69 | 64 | void clear(void); |
| 65 | + GPhoton* clone(void) const; | |
| 70 | 66 | const GSkyDir& dir(void) const { return m_dir; } |
| 71 | 67 | const GEnergy& energy(void) const { return m_energy; } |
| 72 | 68 | const GTime& time(void) const { return m_time; } | ... | ... |
include/GPointing.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GPointing.hpp - Pointing abstract base class * | |
| 2 | + * GPointing.hpp - Pointing interface class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GPointing.hpp |
| 23 | - * @brief Pointing abstract base class definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Pointing interface class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GPOINTING_HPP |
| ... | ... | @@ -29,25 +29,18 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GSkyDir.hpp" |
| 35 | -#include "GTime.hpp" | |
| 36 | 34 | |
| 37 | 35 | |
| 38 | 36 | /***********************************************************************//** |
| 39 | 37 | * @class GPointing |
| 40 | 38 | * |
| 41 | - * @brief Abstract interface for the pointing classes | |
| 39 | + * @brief Interface for the pointing classes | |
| 42 | 40 | * |
| 43 | - * The pointing class holds information about the time dependent telescope | |
| 44 | - * pointing. | |
| 41 | + * The pointing class holds information about the telescope pointing. | |
| 45 | 42 | ***************************************************************************/ |
| 46 | -class GPointing { | |
| 47 | - | |
| 48 | - // I/O friends | |
| 49 | - friend std::ostream& operator<<(std::ostream& os, const GPointing& pnt); | |
| 50 | - friend GLog& operator<<(GLog& log, const GPointing& pnt); | |
| 43 | +class GPointing : public GBase { | |
| 51 | 44 | |
| 52 | 45 | public: |
| 53 | 46 | // Constructors and destructors | ... | ... |
include/GRan.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GRan.hpp - Randon number generator class * | |
| 2 | + * GRan.hpp - Random number generator class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GRan.hpp |
| 23 | - * @brief Randon number generator class definition. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Random number generator class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GRAN_HPP |
| ... | ... | @@ -29,23 +29,17 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 34 | -#include "GSkyDir.hpp" | |
| 35 | -#include "GEnergy.hpp" | |
| 36 | -#include "GTime.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 37 | 33 | |
| 38 | 34 | |
| 39 | 35 | /***********************************************************************//** |
| 40 | 36 | * @class GRan |
| 41 | 37 | * |
| 42 | 38 | * @brief Random number generator class |
| 39 | + * | |
| 40 | + * This class implements a random number generator. | |
| 43 | 41 | ***************************************************************************/ |
| 44 | -class GRan { | |
| 45 | - | |
| 46 | - // I/O friends | |
| 47 | - friend std::ostream& operator<< (std::ostream& os, const GRan& ran); | |
| 48 | - friend GLog& operator<< (GLog& log, const GRan& ran); | |
| 42 | +class GRan : public GBase { | |
| 49 | 43 | |
| 50 | 44 | public: |
| 51 | 45 | // Constructors and destructors |
| ... | ... | @@ -65,6 +59,7 @@ public: |
| 65 | 59 | unsigned long long int int64(void); |
| 66 | 60 | double uniform(void); |
| 67 | 61 | double exp(const double& lambda); |
| 62 | + double poisson(const double& lambda); | |
| 68 | 63 | double chisq2(void); |
| 69 | 64 | std::string print(void) const; |
| 70 | 65 | |
| ... | ... | @@ -79,6 +74,12 @@ protected: |
| 79 | 74 | unsigned long long int m_u; //!< u |
| 80 | 75 | unsigned long long int m_v; //!< v |
| 81 | 76 | unsigned long long int m_w; //!< w |
| 77 | + | |
| 78 | + // Poisson cache | |
| 79 | + double m_oldm; | |
| 80 | + double m_sq; | |
| 81 | + double m_alxm; | |
| 82 | + double m_g; | |
| 82 | 83 | }; |
| 83 | 84 | |
| 84 | 85 | #endif /* GRAN_HPP */ | ... | ... |
include/GRegistry.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GRegistry.hpp - Interface class for registries * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) 2012 by Juergen Knoedlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software: you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * This program is distributed in the hope that it will be useful, * | |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 15 | + * GNU General Public License for more details. * | |
| 16 | + * * | |
| 17 | + * You should have received a copy of the GNU General Public License * | |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 19 | + * * | |
| 20 | + ***************************************************************************/ | |
| 21 | +/** | |
| 22 | + * @file GRegistry.hpp | |
| 23 | + * @brief Interface class definition for registries | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GREGISTRY_HPP | |
| 28 | +#define GREGISTRY_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include <iostream> | |
| 33 | +#include "GLog.hpp" | |
| 34 | + | |
| 35 | + | |
| 36 | +/***********************************************************************//** | |
| 37 | + * @class GRegistry | |
| 38 | + * | |
| 39 | + * @brief Interface class for registries | |
| 40 | + * | |
| 41 | + * This class defines the interface for registries. A registry is a | |
| 42 | + * container class that contains instance of derived classes. For example, | |
| 43 | + * if three different derived classes exist for a given base class, the | |
| 44 | + * registry will contain one instance for each derived class. Using the | |
| 45 | + * clone mechanism, the registry may thus provide a new instance of a given | |
| 46 | + * derived class, depending on the type of the derived class. | |
| 47 | + * | |
| 48 | + * The interface class requires the implementation of the following methods | |
| 49 | + * for all registry classes: | |
| 50 | + * | |
| 51 | + * size(void) Number of elements in registry class | |
| 52 | + * | |
| 53 | + * name(const int& index) Name of registered class by index | |
| 54 | + * | |
| 55 | + * print() Print content of registry | |
| 56 | + ***************************************************************************/ | |
| 57 | +class GRegistry { | |
| 58 | + | |
| 59 | +public: | |
| 60 | + /// @brief Destructor | |
| 61 | + /// | |
| 62 | + /// Destroys class. | |
| 63 | + virtual ~GRegistry(void) {} | |
| 64 | + | |
| 65 | + /// @brief Return number of classes in registry | |
| 66 | + /// | |
| 67 | + /// Returns the number of classes that have been registered in the | |
| 68 | + /// registry. | |
| 69 | + virtual int size(void) const = 0; | |
| 70 | + | |
| 71 | + /// @brief Return name of registered class by index | |
| 72 | + /// | |
| 73 | + /// @param[in] index Class index [0,...,size()-1] | |
| 74 | + /// | |
| 75 | + /// Returns the name of a registered class, specified by its index in | |
| 76 | + /// the registry. | |
| 77 | + virtual std::string name(const int& index) const = 0; | |
| 78 | + | |
| 79 | + /// @brief Print content of object | |
| 80 | + /// | |
| 81 | + /// @return String containing the content of the object. | |
| 82 | + /// | |
| 83 | + /// Formats the content in a standard way and puts this content in a | |
| 84 | + /// C++ string that is returned. | |
| 85 | + virtual std::string print(void) const = 0; | |
| 86 | +}; | |
| 87 | + | |
| 88 | +/* __ Prototypes _________________________________________________________ */ | |
| 89 | +std::ostream& operator<<(std::ostream& os, const GRegistry& registry); | |
| 90 | +GLog& operator<<(GLog& log, const GRegistry& registry); | |
| 91 | + | |
| 92 | +#endif /* GREGISTRY_HPP */ | ... | ... |
include/GResponse.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GResponse.hpp |
| 23 | 23 | * @brief Abstract response base class definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GRESPONSE_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GEvent.hpp" |
| 35 | 34 | #include "GSkyDir.hpp" |
| 36 | 35 | #include "GEnergy.hpp" |
| ... | ... | @@ -60,11 +59,7 @@ class GObservation; |
| 60 | 59 | * The npred method returns the integral of the instrument response function |
| 61 | 60 | * over the dataspace. This method is only required for unbinned analysis. |
| 62 | 61 | ***************************************************************************/ |
| 63 | -class GResponse { | |
| 64 | - | |
| 65 | - // I/O friends | |
| 66 | - friend std::ostream& operator<< (std::ostream& os, const GResponse& rsp); | |
| 67 | - friend GLog& operator<< (GLog& log, const GResponse& rsp); | |
| 62 | +class GResponse : public GBase { | |
| 68 | 63 | |
| 69 | 64 | public: |
| 70 | 65 | // Constructors and destructors | ... | ... |
include/GRoi.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GRoi.hpp - Region of interest abstract base class * | |
| 2 | + * GRoi.hpp - Region of interest interface class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GRoi.hpp |
| 23 | - * @brief Region of interest abstract base class definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Region of interest interface class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GROI_HPP |
| ... | ... | @@ -29,28 +29,23 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | |
| 35 | 34 | |
| 36 | 35 | /***********************************************************************//** |
| 37 | 36 | * @class GRoi |
| 38 | 37 | * |
| 39 | - * @brief Abstract interface for the region of interest classes | |
| 38 | + * @brief Interface for the region of interest classes | |
| 40 | 39 | * |
| 41 | 40 | * The region of interest class holds instrument specific information about |
| 42 | 41 | * the spatial region in detector or telescopes coordinates that is used |
| 43 | 42 | * for an analysis. In particular, the definition of a region of interest |
| 44 | 43 | * is required for an unbinned analysis. |
| 45 | 44 | ***************************************************************************/ |
| 46 | -class GRoi { | |
| 45 | +class GRoi : public GBase { | |
| 47 | 46 | |
| 48 | - // Friend classes | |
| 49 | - friend class GObservation; | |
| 50 | - | |
| 51 | - // I/O friends | |
| 52 | - friend std::ostream& operator<<(std::ostream& os, const GRoi& roi); | |
| 53 | - friend GLog& operator<<(GLog& log, const GRoi& roi); | |
| 47 | + // Friend classes | |
| 48 | + friend class GObservation; | |
| 54 | 49 | |
| 55 | 50 | public: |
| 56 | 51 | // Constructors and destructors | ... | ... |
include/GSkyDir.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyDir.hpp - Class that implements a sky direction * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GSkyDir.hpp |
| 23 | 23 | * @brief Sky direction class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GSKYDIR_HPP |
| ... | ... | @@ -29,10 +29,8 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GVector.hpp" |
| 35 | -#include "GMatrix.hpp" | |
| 36 | 34 | |
| 37 | 35 | |
| 38 | 36 | /***********************************************************************//** |
| ... | ... | @@ -49,11 +47,7 @@ |
| 49 | 47 | * if requested. Coordinates can be given and returned in radians or in |
| 50 | 48 | * degrees. Note that the epoch for celestial coordinates is fixed to J2000. |
| 51 | 49 | ***************************************************************************/ |
| 52 | -class GSkyDir { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GSkyDir& dir); | |
| 56 | - friend GLog& operator<<(GLog& log, const GSkyDir& dir); | |
| 50 | +class GSkyDir : public GBase { | |
| 57 | 51 | |
| 58 | 52 | // Operator friends |
| 59 | 53 | friend bool operator==(const GSkyDir &a, const GSkyDir &b); |
| ... | ... | @@ -70,6 +64,7 @@ public: |
| 70 | 64 | |
| 71 | 65 | // Methods |
| 72 | 66 | void clear(void); |
| 67 | + GSkyDir* clone(void) const; | |
| 73 | 68 | void radec(const double& ra, const double& dec); |
| 74 | 69 | void radec_deg(const double& ra, const double& dec); |
| 75 | 70 | void lb(const double& l, const double& b); | ... | ... |
include/GSkyPixel.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyPixel.cpp - Class that implements a 2D sky pixel index * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GSkyPixel.hpp |
| 23 | - * @brief GSkyPixel class definition. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Sky pixel class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GSKYPIXEL_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | |
| 35 | 34 | |
| 36 | 35 | /***********************************************************************//** |
| ... | ... | @@ -38,11 +37,7 @@ |
| 38 | 37 | * |
| 39 | 38 | * @brief GSkyPixel class interface defintion |
| 40 | 39 | ***************************************************************************/ |
| 41 | -class GSkyPixel { | |
| 42 | - | |
| 43 | - // I/O friends | |
| 44 | - friend std::ostream& operator<< (std::ostream& os, const GSkyPixel& pixel); | |
| 45 | - friend GLog& operator<< (GLog& log, const GSkyPixel& pixel); | |
| 40 | +class GSkyPixel : public GBase { | |
| 46 | 41 | |
| 47 | 42 | public: |
| 48 | 43 | // Constructors and destructors |
| ... | ... | @@ -55,6 +50,8 @@ public: |
| 55 | 50 | GSkyPixel& operator= (const GSkyPixel& pixel); |
| 56 | 51 | |
| 57 | 52 | // Methods |
| 53 | + void clear(void); | |
| 54 | + GSkyPixel* clone(void) const; | |
| 58 | 55 | void x(const double& x); |
| 59 | 56 | void y(const double& y); |
| 60 | 57 | double x(void) const; | ... | ... |
include/GSkymap.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GSkymap.hpp |
| 23 | 23 | * @brief Sky map class definition. |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GSKYMAP_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GWcs.hpp" |
| 35 | 34 | #include "GSkyDir.hpp" |
| 36 | 35 | #include "GSkyPixel.hpp" |
| ... | ... | @@ -61,11 +60,7 @@ |
| 61 | 60 | * index or sky pixel and the true physical sky direction are provided by the |
| 62 | 61 | * pix2dir() and dir2pix() methods. |
| 63 | 62 | ***************************************************************************/ |
| 64 | -class GSkymap { | |
| 65 | - | |
| 66 | - // I/O friends | |
| 67 | - friend std::ostream& operator<< (std::ostream& os, const GSkymap& map); | |
| 68 | - friend GLog& operator<<(GLog& log, const GSkymap& map); | |
| 63 | +class GSkymap : public GBase { | |
| 69 | 64 | |
| 70 | 65 | public: |
| 71 | 66 | // Constructors and destructors | ... | ... |
include/GSparseMatrix.hpp
| ... | ... | @@ -29,8 +29,6 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 34 | 32 | #include "GMatrixBase.hpp" |
| 35 | 33 | |
| 36 | 34 | /* __ Definitions ________________________________________________________ */ |
| ... | ... | @@ -63,10 +61,6 @@ class GSparseMatrix : public GMatrixBase { |
| 63 | 61 | friend class GSparseSymbolic; |
| 64 | 62 | friend class GSparseNumeric; |
| 65 | 63 | |
| 66 | - // I/O friends | |
| 67 | - friend std::ostream& operator<<(std::ostream& os, const GSparseMatrix& matrix); | |
| 68 | - friend GLog& operator<<(GLog& log, const GSparseMatrix& matrix); | |
| 69 | - | |
| 70 | 64 | // Binary operator friends |
| 71 | 65 | friend GSparseMatrix operator*(const double& a, const GSparseMatrix& b); |
| 72 | 66 | friend GSparseMatrix operator*(const GSparseMatrix& a, const double& b); |
| ... | ... | @@ -119,34 +113,35 @@ public: |
| 119 | 113 | GSparseMatrix& operator/=(const double& scalar); |
| 120 | 114 | |
| 121 | 115 | // Implemented pure virtual base class methods |
| 122 | - void clear(void); | |
| 123 | - void transpose(void); | |
| 124 | - void invert(void); | |
| 125 | - void add_col(const GVector& vector, const int& col); | |
| 126 | - void insert_col(const GVector& vector, const int& col); | |
| 127 | - GVector extract_row(const int& row) const; | |
| 128 | - GVector extract_col(const int& col) const; | |
| 129 | - double fill(void) const; | |
| 130 | - double min(void) const; | |
| 131 | - double max(void) const; | |
| 132 | - double sum(void) const; | |
| 133 | - std::string print(void) const; | |
| 116 | + void clear(void); | |
| 117 | + GSparseMatrix* clone(void) const; | |
| 118 | + void transpose(void); | |
| 119 | + void invert(void); | |
| 120 | + void add_col(const GVector& vector, const int& col); | |
| 121 | + void insert_col(const GVector& vector, const int& col); | |
| 122 | + GVector extract_row(const int& row) const; | |
| 123 | + GVector extract_col(const int& col) const; | |
| 124 | + double fill(void) const; | |
| 125 | + double min(void) const; | |
| 126 | + double max(void) const; | |
| 127 | + double sum(void) const; | |
| 128 | + std::string print(void) const; | |
| 134 | 129 | |
| 135 | 130 | // Other methods |
| 136 | - void add_col(const double* values, const int* rows, | |
| 137 | - int number, const int& col); | |
| 138 | - void insert_col(const double* values, const int* rows, | |
| 139 | - int number, const int& col); | |
| 140 | - void cholesky_decompose(bool compress = true); | |
| 141 | - GVector cholesky_solver(const GVector& vector, bool compress = true); | |
| 142 | - void cholesky_invert(bool compress = true); | |
| 143 | - void set_mem_block(const int& block); | |
| 144 | - void stack_init(const int& size = 0, const int& entries = 0); | |
| 145 | - int stack_push_column(const GVector& vector, const int& col); | |
| 146 | - int stack_push_column(const double* values, const int* rows, | |
| 147 | - const int& number, const int& col); | |
| 148 | - void stack_flush(void); | |
| 149 | - void stack_destroy(void); | |
| 131 | + void add_col(const double* values, const int* rows, | |
| 132 | + int number, const int& col); | |
| 133 | + void insert_col(const double* values, const int* rows, | |
| 134 | + int number, const int& col); | |
| 135 | + void cholesky_decompose(bool compress = true); | |
| 136 | + GVector cholesky_solver(const GVector& vector, bool compress = true); | |
| 137 | + void cholesky_invert(bool compress = true); | |
| 138 | + void set_mem_block(const int& block); | |
| 139 | + void stack_init(const int& size = 0, const int& entries = 0); | |
| 140 | + int stack_push_column(const GVector& vector, const int& col); | |
| 141 | + int stack_push_column(const double* values, const int* rows, | |
| 142 | + const int& number, const int& col); | |
| 143 | + void stack_flush(void); | |
| 144 | + void stack_destroy(void); | |
| 150 | 145 | |
| 151 | 146 | private: |
| 152 | 147 | // Private methods | ... | ... |
include/GSymMatrix.hpp
| ... | ... | @@ -29,8 +29,6 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 34 | 32 | #include "GMatrixBase.hpp" |
| 35 | 33 | |
| 36 | 34 | /* __ Forward declarations _______________________________________________ */ |
| ... | ... | @@ -49,10 +47,6 @@ class GSparseMatrix; |
| 49 | 47 | ***************************************************************************/ |
| 50 | 48 | class GSymMatrix : public GMatrixBase { |
| 51 | 49 | |
| 52 | - // I/O friends | |
| 53 | - friend std::ostream& operator<<(std::ostream& os, const GSymMatrix& matrix); | |
| 54 | - friend GLog& operator<<(GLog& log, const GSymMatrix& matrix); | |
| 55 | - | |
| 56 | 50 | // Binary operator friends |
| 57 | 51 | friend GSymMatrix operator*(const double& a, const GSymMatrix& b); |
| 58 | 52 | friend GSymMatrix operator*(const GSymMatrix& a, const double& b); |
| ... | ... | @@ -91,6 +85,7 @@ public: |
| 91 | 85 | |
| 92 | 86 | // Implemented pure virtual base class methods |
| 93 | 87 | virtual void clear(void); |
| 88 | + virtual GSymMatrix* clone(void) const; | |
| 94 | 89 | virtual void transpose(void) { return; } |
| 95 | 90 | virtual void invert(void); |
| 96 | 91 | virtual void add_col(const GVector& vector, const int& col); |
| ... | ... | @@ -175,7 +170,6 @@ GSymMatrix GSymMatrix::operator-(void) const |
| 175 | 170 | /*************************************************************************** |
| 176 | 171 | * Inline methods * |
| 177 | 172 | ***************************************************************************/ |
| 178 | -inline void GSymMatrix::clear(void) { set_all_elements(0.0); } | |
| 179 | 173 | inline double GSymMatrix::min(void) const { return get_min_element(); } |
| 180 | 174 | inline double GSymMatrix::max(void) const { return get_max_element(); } |
| 181 | 175 | ... | ... |
include/GTestCase.hpp
| ... | ... | @@ -28,8 +28,8 @@ |
| 28 | 28 | #define GTESTCASE_H |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 32 | +#include "GBase.hpp" | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /***********************************************************************//** |
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | * Furthermore, the test case knows whether the test succeeded or failed, |
| 45 | 45 | * and whether the test was an error or a failure test. |
| 46 | 46 | ***************************************************************************/ |
| 47 | -class GTestCase{ | |
| 47 | +class GTestCase : public GBase { | |
| 48 | 48 | |
| 49 | 49 | public: |
| 50 | 50 | // public enumerators |
| ... | ... | @@ -63,6 +63,8 @@ public: |
| 63 | 63 | GTestCase& operator= (const GTestCase& test); |
| 64 | 64 | |
| 65 | 65 | // Methods |
| 66 | + void clear(void); | |
| 67 | + GTestCase* clone(void) const; | |
| 66 | 68 | std::string name(void) const; |
| 67 | 69 | void name(const std::string& name); |
| 68 | 70 | std::string message(void) const; | ... | ... |
include/GTestSuite.hpp
| ... | ... | @@ -34,7 +34,6 @@ class GTestSuite; |
| 34 | 34 | typedef void (GTestSuite::*pfunction)(void); |
| 35 | 35 | |
| 36 | 36 | /* __ Includes ___________________________________________________________ */ |
| 37 | -#include <iostream> | |
| 38 | 37 | #include <vector> |
| 39 | 38 | #include <string> |
| 40 | 39 | #include "GLog.hpp" |
| ... | ... | @@ -73,7 +72,7 @@ public: |
| 73 | 72 | virtual bool run(void); |
| 74 | 73 | std::string name(void) const; |
| 75 | 74 | void name(const std::string& name); |
| 76 | - void cout(bool cout); | |
| 75 | + void cout(const bool& flag); | |
| 77 | 76 | void test_assert(bool result, |
| 78 | 77 | const std::string& name, |
| 79 | 78 | const std::string& message=""); | ... | ... |
include/GTestSuites.hpp
| ... | ... | @@ -30,10 +30,10 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | +#include "GBase.hpp" | |
| 34 | +#include "GLog.hpp" | |
| 33 | 35 | #include "GXml.hpp" |
| 34 | -#include "GTools.hpp" | |
| 35 | 36 | #include "GTestSuite.hpp" |
| 36 | -#include "GTestCase.hpp" | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /***********************************************************************//** |
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | * |
| 46 | 46 | * @todo Detailed description |
| 47 | 47 | ***************************************************************************/ |
| 48 | -class GTestSuites { | |
| 48 | +class GTestSuites : public GBase { | |
| 49 | 49 | |
| 50 | 50 | public: |
| 51 | 51 | // Constructors and destructors |
| ... | ... | @@ -60,19 +60,20 @@ public: |
| 60 | 60 | const GTestSuite& operator[](const int& index) const; |
| 61 | 61 | |
| 62 | 62 | // Methods |
| 63 | - void clear(void); | |
| 64 | - int size(void) const; | |
| 65 | - void append(GTestSuite& suite); | |
| 66 | - bool run(void); | |
| 67 | - void save(const std::string& filename) const; | |
| 68 | - std::string name(void) const; | |
| 69 | - void name(const std::string& name); | |
| 70 | - void cout(bool cout); | |
| 71 | - int errors(void) const; | |
| 72 | - int failures(void) const; | |
| 73 | - int tests(void) const; | |
| 74 | - time_t timestamp(void) const; | |
| 75 | - std::string print(void) const; | |
| 63 | + void clear(void); | |
| 64 | + GTestSuites* clone(void) const; | |
| 65 | + int size(void) const; | |
| 66 | + void append(GTestSuite& suite); | |
| 67 | + bool run(void); | |
| 68 | + void save(const std::string& filename) const; | |
| 69 | + std::string name(void) const; | |
| 70 | + void name(const std::string& name); | |
| 71 | + void cout(const bool& flag); | |
| 72 | + int errors(void) const; | |
| 73 | + int failures(void) const; | |
| 74 | + int tests(void) const; | |
| 75 | + time_t timestamp(void) const; | |
| 76 | + std::string print(void) const; | |
| 76 | 77 | |
| 77 | 78 | protected: |
| 78 | 79 | // Protected methods | ... | ... |
include/GTime.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GTime.hpp - Time class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GTime.hpp |
| 23 | 23 | * @brief Time class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GTIME_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| ... | ... | @@ -44,11 +43,7 @@ |
| 44 | 43 | * |
| 45 | 44 | * @todo Make use of MJD reference in operators. |
| 46 | 45 | ***************************************************************************/ |
| 47 | -class GTime { | |
| 48 | - | |
| 49 | - // I/O friends | |
| 50 | - friend GLog& operator<< (GLog& log, const GTime& time); | |
| 51 | - friend std::ostream& operator<< (std::ostream& os, const GTime& time); | |
| 46 | +class GTime : public GBase { | |
| 52 | 47 | |
| 53 | 48 | // Operator friends |
| 54 | 49 | friend GTime operator+ (const GTime &a, const GTime &b); |
| ... | ... | @@ -85,6 +80,7 @@ public: |
| 85 | 80 | |
| 86 | 81 | // Methods |
| 87 | 82 | void clear(void); |
| 83 | + GTime* clone(void) const; | |
| 88 | 84 | double jd(void) const; |
| 89 | 85 | double mjd(void) const; |
| 90 | 86 | double met(void) const; | ... | ... |
include/GVector.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GVector.hpp - Vector class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2006-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2006-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GVector.hpp |
| 23 | 23 | * @brief Vector class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GVECTOR_HPP |
| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <cmath> |
| 32 | 32 | #include <string> |
| 33 | -#include <iostream> | |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | #include "GException.hpp" |
| 36 | 35 | |
| 37 | 36 | |
| ... | ... | @@ -44,11 +43,7 @@ |
| 44 | 43 | * is intended to be used for numerical computation (it is not ment to |
| 45 | 44 | * replace the std::vector template class). |
| 46 | 45 | ***************************************************************************/ |
| 47 | -class GVector { | |
| 48 | - | |
| 49 | - // I/O friends | |
| 50 | - friend std::ostream& operator<<(std::ostream& os, const GVector& v); | |
| 51 | - friend GLog& operator<<(GLog& log, const GVector& v); | |
| 46 | +class GVector : public GBase { | |
| 52 | 47 | |
| 53 | 48 | // Operator friends |
| 54 | 49 | friend GVector operator+(const GVector &a, const GVector &b); |
| ... | ... | @@ -118,6 +113,7 @@ public: |
| 118 | 113 | |
| 119 | 114 | // Vector methods |
| 120 | 115 | void clear(void); |
| 116 | + GVector* clone(void) const; | |
| 121 | 117 | int size(void) const; |
| 122 | 118 | int non_zeros(void) const; |
| 123 | 119 | std::string print(void) const; | ... | ... |
include/GWcs.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GWcs.hpp - World Coordinate System virtual base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GWcs.hpp |
| 23 | 23 | * @brief World Coordinate System virtual base class definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GWCS_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GFitsHDU.hpp" |
| 35 | 34 | #include "GSkyDir.hpp" |
| 36 | 35 | #include "GSkyPixel.hpp" |
| ... | ... | @@ -41,16 +40,12 @@ |
| 41 | 40 | * |
| 42 | 41 | * @brief GWcs virtual base class interface defintion |
| 43 | 42 | ***************************************************************************/ |
| 44 | -class GWcs { | |
| 43 | +class GWcs : public GBase { | |
| 45 | 44 | |
| 46 | 45 | // Operator friends |
| 47 | 46 | friend bool operator== (const GWcs &a, const GWcs &b); |
| 48 | 47 | friend bool operator!= (const GWcs &a, const GWcs &b); |
| 49 | 48 | |
| 50 | - // I/O friends | |
| 51 | - friend std::ostream& operator<< (std::ostream& os, const GWcs& wcs); | |
| 52 | - friend GLog& operator<< (GLog& log, const GWcs& wcs); | |
| 53 | - | |
| 54 | 49 | public: |
| 55 | 50 | // Constructors and destructors |
| 56 | 51 | GWcs(void); | ... | ... |
include/GWcsRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GWcsRegistry.hpp - World Coordinate Projection registry class * | |
| 2 | + * GWcsRegistry.hpp - World Coordinate Projection registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GWcsRegistry.hpp |
| 23 | 23 | * @brief World Coordinate Projection registry class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GWCSREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GWcslib.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,16 +43,14 @@ |
| 44 | 43 | * m_number, m_codes, m_names, and m_prjs which are allocated globally to keep |
| 45 | 44 | * track of projections that are available throughout all linked libraries. To |
| 46 | 45 | * register a projection it is sufficient to add |
| 47 | - * const GWcsXXX g_wcs_XXX_seed; | |
| 48 | - * const GWcsRegistry g_wcs_XXX_registry(&g_wcs_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GWcsXXX g_wcs_XXX_seed; | |
| 48 | + * const GWcsRegistry g_wcs_XXX_registry(&g_wcs_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the projection. Here, XXX is a unique |
| 50 | 51 | * code that describes the projection. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GWcsRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GWcsRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GWcsRegistry& registry); | |
| 53 | +class GWcsRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors | ... | ... |
include/GXml.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXml.hpp - XML class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,16 +21,15 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GXml.hpp |
| 23 | 23 | * @brief XML class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GXML_HPP |
| 28 | 28 | #define GXML_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GBase.hpp" | |
| 34 | 33 | #include "GXmlNode.hpp" |
| 35 | 34 | #include "GXmlDocument.hpp" |
| 36 | 35 | #include "GXmlElement.hpp" |
| ... | ... | @@ -47,17 +46,13 @@ |
| 47 | 46 | * This class implements an XML object. It holds the root node of the XML |
| 48 | 47 | * document. |
| 49 | 48 | ***************************************************************************/ |
| 50 | -class GXml { | |
| 49 | +class GXml : public GBase { | |
| 51 | 50 | |
| 52 | 51 | // Friend classes |
| 53 | 52 | friend class GXmlNode; |
| 54 | 53 | friend class GXmlDocument; |
| 55 | 54 | friend class GXmlText; |
| 56 | 55 | |
| 57 | - // I/O friends | |
| 58 | - friend std::ostream& operator<<(std::ostream& os, const GXml& xml); | |
| 59 | - friend GLog& operator<<(GLog& log, const GXml& xml); | |
| 60 | - | |
| 61 | 56 | public: |
| 62 | 57 | // Constructors and destructors |
| 63 | 58 | GXml(void); |
| ... | ... | @@ -70,6 +65,7 @@ public: |
| 70 | 65 | |
| 71 | 66 | // Methods |
| 72 | 67 | void clear(void); |
| 68 | + GXml* clone(void) const; | |
| 73 | 69 | void append(GXmlNode* node); |
| 74 | 70 | void load(const std::string& filename); |
| 75 | 71 | void save(const std::string& filename); |
| ... | ... | @@ -79,7 +75,8 @@ public: |
| 79 | 75 | int elements(const std::string& name) const; |
| 80 | 76 | GXmlElement* element(int index) const; |
| 81 | 77 | GXmlElement* element(const std::string& name, int index) const; |
| 82 | - std::string print(int indent = 0) const; | |
| 78 | + std::string print(void) const; | |
| 79 | + std::string print(int indent) const; | |
| 83 | 80 | |
| 84 | 81 | protected: |
| 85 | 82 | // Protected enumerators | ... | ... |
include/GXmlAttribute.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXmlAttribute.hpp - XML attribute class definition * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GXmlAttribute.hpp |
| 23 | 23 | * @brief XML attribute class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GXMLATTRIBUTE_HPP |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <cstdio> // FILE, std::fprintf |
| 32 | 32 | #include <string> |
| 33 | +#include "GBase.hpp" | |
| 33 | 34 | |
| 34 | 35 | |
| 35 | 36 | /***********************************************************************//** |
| ... | ... | @@ -41,7 +42,7 @@ |
| 41 | 42 | * consists of a name-value pair. Note that the hyphens are stored for the |
| 42 | 43 | * attribute value. Allowed hyphens are " and '. |
| 43 | 44 | ***************************************************************************/ |
| 44 | -class GXmlAttribute { | |
| 45 | +class GXmlAttribute : public GBase { | |
| 45 | 46 | |
| 46 | 47 | public: |
| 47 | 48 | // Constructors and destructors | ... | ... |
include/GXmlNode.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXmlNode.hpp - Abstract XML node base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,17 +21,16 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GXmlNode.hpp |
| 23 | 23 | * @brief Abstract XML node base class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GXMLNODE_HPP |
| 28 | 28 | #define GXMLNODE_HPP |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | -#include <iostream> | |
| 32 | 31 | #include <string> |
| 33 | 32 | #include <vector> |
| 34 | -#include "GLog.hpp" | |
| 33 | +#include "GBase.hpp" | |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| ... | ... | @@ -41,11 +40,7 @@ |
| 41 | 40 | * |
| 42 | 41 | * This class defines an abstract node of a XML document. |
| 43 | 42 | ***************************************************************************/ |
| 44 | -class GXmlNode { | |
| 45 | - | |
| 46 | - // I/O friends | |
| 47 | - friend std::ostream& operator<<(std::ostream& os, const GXmlNode& node); | |
| 48 | - friend GLog& operator<<(GLog& log, const GXmlNode& node); | |
| 43 | +class GXmlNode : public GBase { | |
| 49 | 44 | |
| 50 | 45 | public: |
| 51 | 46 | // Constructors and destructors |
| ... | ... | @@ -72,8 +67,9 @@ public: |
| 72 | 67 | virtual void clear(void) = 0; |
| 73 | 68 | virtual GXmlNode* clone(void) const = 0; |
| 74 | 69 | virtual void write(FILE* fptr, int indent = 0) const = 0; |
| 75 | - virtual std::string print(int indent = 0) const = 0; | |
| 76 | 70 | virtual NodeType type(void) const = 0; |
| 71 | + virtual std::string print(void) const; | |
| 72 | + virtual std::string print(int indent) const = 0; | |
| 77 | 73 | |
| 78 | 74 | // Methods |
| 79 | 75 | void append(GXmlNode* node); | ... | ... |
include/GammaLib.hpp
| ... | ... | @@ -18,17 +18,24 @@ |
| 18 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 19 | 19 | * * |
| 20 | 20 | ***************************************************************************/ |
| 21 | +/** | |
| 22 | + * @file GammaLib.hpp | |
| 23 | + * @brief GammaLib definitions | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | + */ | |
| 21 | 26 | |
| 22 | 27 | #ifndef GAMMALIB_HPP |
| 23 | 28 | #define GAMMALIB_HPP |
| 24 | 29 | |
| 25 | -/* __ Includes ___________________________________________________________ */ | |
| 26 | - | |
| 27 | 30 | |
| 28 | 31 | /*************************************************************************** |
| 29 | 32 | * Core services * |
| 30 | 33 | ***************************************************************************/ |
| 31 | 34 | |
| 35 | +/* __ Interface classes __________________________________________________ */ | |
| 36 | +#include "GBase.hpp" | |
| 37 | +#include "GRegistry.hpp" | |
| 38 | + | |
| 32 | 39 | /* __ Common tools _______________________________________________________ */ |
| 33 | 40 | #include "GException.hpp" |
| 34 | 41 | #include "GNodeArray.hpp" |
| ... | ... | @@ -45,6 +52,7 @@ |
| 45 | 52 | #include "GIntegrand.hpp" |
| 46 | 53 | #include "GDerivative.hpp" |
| 47 | 54 | #include "GFunction.hpp" |
| 55 | +#include "GNumerics.hpp" | |
| 48 | 56 | |
| 49 | 57 | /* __ FITS module ________________________________________________________ */ |
| 50 | 58 | #include "GFits.hpp" | ... | ... |
include/Makefile.am
| 1 | 1 | # Define package included headers (to be installed) |
| 2 | 2 | pkginclude_HEADERS = GammaLib.hpp \ |
| 3 | + GBase.hpp \ | |
| 4 | + GRegistry.hpp \ | |
| 3 | 5 | GException.hpp \ |
| 4 | 6 | GNodeArray.hpp \ |
| 5 | 7 | GTools.hpp \ |
| ... | ... | @@ -118,6 +120,7 @@ pkginclude_HEADERS = GammaLib.hpp \ |
| 118 | 120 | GIntegrand.hpp \ |
| 119 | 121 | GDerivative.hpp \ |
| 120 | 122 | GFunction.hpp \ |
| 123 | + GNumerics.hpp \ | |
| 121 | 124 | GOptimizer.hpp \ |
| 122 | 125 | GOptimizerLM.hpp \ |
| 123 | 126 | GOptimizerPars.hpp \ | ... | ... |
inst/cta/Makefile.am
| ... | ... | @@ -18,6 +18,15 @@ sources = src/GCTASupport.cpp \ |
| 18 | 18 | src/GCTAResponse.cpp \ |
| 19 | 19 | src/GCTAResponse_helpers.cpp \ |
| 20 | 20 | src/GCTAResponseTable.cpp \ |
| 21 | + src/GCTAAeff.cpp \ | |
| 22 | + src/GCTAAeffPerfTable.cpp \ | |
| 23 | + src/GCTAAeffArf.cpp \ | |
| 24 | + src/GCTAAeff2D.cpp \ | |
| 25 | + src/GCTAPsf.cpp \ | |
| 26 | + src/GCTAPsfPerfTable.cpp \ | |
| 27 | + src/GCTAPsfVector.cpp \ | |
| 28 | + src/GCTAPsf2D.cpp \ | |
| 29 | + src/GCTAEdisp.cpp \ | |
| 21 | 30 | src/GCTAInstDir.cpp \ |
| 22 | 31 | src/GCTARoi.cpp \ |
| 23 | 32 | src/GCTAPointing.cpp \ |
| ... | ... | @@ -41,6 +50,15 @@ pkginclude_HEADERS = include/GCTAException.hpp \ |
| 41 | 50 | include/GCTARoi.hpp \ |
| 42 | 51 | include/GCTAResponse.hpp \ |
| 43 | 52 | include/GCTAResponseTable.hpp \ |
| 53 | + include/GCTAAeff.hpp \ | |
| 54 | + include/GCTAAeffPerfTable.hpp \ | |
| 55 | + include/GCTAAeffArf.hpp \ | |
| 56 | + include/GCTAAeff2D.hpp \ | |
| 57 | + include/GCTAPsf.hpp \ | |
| 58 | + include/GCTAPsfPerfTable.hpp \ | |
| 59 | + include/GCTAPsfVector.hpp \ | |
| 60 | + include/GCTAPsf2D.hpp \ | |
| 61 | + include/GCTAEdisp.hpp \ | |
| 44 | 62 | include/GCTAModelRadialRegistry.hpp \ |
| 45 | 63 | include/GCTAModelRadial.hpp \ |
| 46 | 64 | include/GCTAModelRadialGauss.hpp \ | ... | ... |