Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/GIDI_data.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002 # <<BEGIN-copyright>>
0003 # Copyright 2019, Lawrence Livermore National Security, LLC.
0004 # This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
0005 # gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
0006 # SPDX-License-Identifier: MIT
0007 # <<END-copyright>>
0008 */
0009 
0010 #ifndef GIDI_data_hpp_included
0011 #define GIDI_data_hpp_included 1
0012 
0013 #include <stdio.h>
0014 #include <string>
0015 #include <vector>
0016 
0017 namespace GIDI {
0018 
0019 /*
0020 ============================================================
0021 =========================== Data1d =========================
0022 ============================================================
0023 */
0024 class Data1d {     // BRB: currently not used.
0025 
0026     private:
0027         std::vector<double> m_xs;
0028         std::vector<double> m_ys;
0029 
0030     public:
0031         Data1d( std::size_t a_number, double const *const a_xs );
0032         Data1d( std::size_t a_number, double const *const a_xs, double const *const a_ys );
0033         Data1d( std::vector<double> const &a_xs );
0034         Data1d( std::vector<double> const &a_xs, std::vector<double> const &a_ys );
0035         Data1d( Data1d const &a_1dData );
0036         ~Data1d( );
0037 
0038         std::size_t size( ) const { return( m_xs.size( ) ); }
0039 
0040         Data1d operator+( double a_value ) const ;
0041         Data1d &operator+=( double a_value );
0042         Data1d operator+( Data1d const &a_rhs ) const ;
0043         Data1d &operator+=( Data1d const &a_rhs );
0044 
0045         Data1d operator-( double a_value ) const ;
0046         Data1d &operator-=( double a_value );
0047         Data1d operator-( Data1d const &a_rhs ) const ;
0048         Data1d &operator-=( Data1d const &a_rhs );
0049 
0050         Data1d operator*( double a_value ) const ;
0051         Data1d &operator*=( double a_value );
0052         Data1d operator/( double a_value ) const ;
0053         Data1d &operator/=( double a_value );
0054 
0055         void print( std::string const &a_prefix ) const ;
0056 };
0057 
0058 /*
0059 ============================================================
0060 ========================== Vector ==========================
0061 ============================================================
0062 */
0063 class Vector {
0064 
0065     private:
0066         std::vector<double> m_vector;                       /**< The list of elements, each is a double instance. */
0067 
0068         void writeWithBoundaries2( FILE *a_file, char const *a_format, std::vector<double> const &a_boundaries, double a_epsilon ) const ;
0069 
0070     public:
0071         Vector( std::size_t a_number = 0 );
0072         Vector( std::vector<double> const &a_values );
0073         Vector( std::size_t a_number, double const *a_values );
0074         Vector( Vector const &a_vector );
0075         ~Vector( );
0076 
0077         Vector &operator=( Vector const &a_rhs );
0078 
0079         std::size_t size( ) const { return( m_vector.size( ) ); }                                   /**< Returns a number of elements of *this*. */
0080         void resize( std::size_t a_number, double a_value = 0.0 ) { m_vector.resize( a_number, a_value ); }                     /**< Resizes *this* to *a_number* elements. For details, see std::vector.resize. */
0081         std::vector<double> &data( ) { return( m_vector ); }
0082 
0083         double &operator[]( std::size_t a_index ) { return( m_vector[a_index] ); }           /**< Returns a reference to the (*a_index*-1)th element. */
0084         double operator[]( std::size_t a_index ) const { return( m_vector[a_index] ); }      /**< Returns a reference to the (*a_index*-1)th element. */
0085 
0086         Vector operator+( double a_value ) const ;
0087         Vector &operator+=( double a_value );
0088         Vector operator+( Vector const &a_rhs ) const ;
0089         Vector &operator+=( Vector const &a_rhs );
0090 
0091         Vector operator-( double a_value ) const ;
0092         Vector &operator-=( double a_value );
0093         Vector operator-( Vector const &a_rhs ) const ;
0094         Vector &operator-=( Vector const &a_rhs );
0095 
0096         Vector operator*( double a_value ) const ;
0097         Vector &operator*=( double a_value );
0098 
0099         Vector operator/( double a_value ) const ;
0100         Vector &operator/=( double a_value );
0101 
0102         void reverse( );
0103 
0104         void setToValueInFlatRange( std::size_t a_start, std::size_t a_end, double a_value );
0105         double sum( );
0106         void print( std::string const &a_prefix ) const ;
0107         void write( FILE *a_file, std::string const &a_prefix ) const ;
0108         void writeWithBoundaries( FILE *a_file, char const *a_format, std::vector<double> const &a_boundaries, double a_epsilon ) const ;
0109 };
0110 
0111 /*
0112 ============================================================
0113 ========================== Matrix ==========================
0114 ============================================================
0115 */
0116 class Matrix {
0117 
0118     private:
0119         std::vector<Vector> m_matrix;                       /**< The list of rows, each is a Vector instance. */
0120 
0121     public:
0122         Matrix( std::size_t a_rows, std::size_t a_columns );
0123         Matrix( Matrix const &a_gidi_matrix );
0124         ~Matrix( );
0125         Matrix &operator=( Matrix const &a_rhs );
0126 
0127         std::size_t size( ) const { return( m_matrix.size( ) ); }                                       /**< Returns the number of rows or *this*. */
0128 
0129         Vector       &operator[]( std::size_t a_index )       { return( m_matrix[a_index] ); }   /**< Returns a reference to the (*a_index*-1)th row. */
0130         Vector const &operator[]( std::size_t a_index ) const { return( m_matrix[a_index] ); }   /**< Returns a reference to the (*a_index*-1)th row. */
0131 
0132                                                             /** Sets the cell at row **a_row** and column **a_column** to **a_value**. */
0133         void operator()( std::size_t a_row           /**< The cell's row. */,
0134                                 std::size_t a_column        /**< The cell's row. */,
0135                                 double a_value              /**< The value to put in the cell. */ )
0136                                         { m_matrix[a_row][a_column] = a_value; }
0137 
0138         std::vector<Vector> const &matrix( ) const { return( m_matrix ); }
0139 
0140         Matrix operator+( double a_value ) const ;
0141         Matrix &operator+=( double a_value );
0142         Matrix operator+( Matrix const &a_rhs ) const ;
0143         Matrix &operator+=( Matrix const &a_rhs );
0144 
0145         Matrix operator-( double a_value ) const ;
0146         Matrix &operator-=( double a_value );
0147         Matrix operator-( Matrix const &a_rhs ) const ;
0148         Matrix &operator-=( Matrix const &a_rhs );
0149 
0150         Matrix operator*( double a_value ) const ;
0151         Matrix &operator*=( double a_value );
0152 
0153         Matrix operator/( double a_value ) const ;
0154         Matrix &operator/=( double a_value );
0155 
0156         std::size_t numberOfColumns( ) const ;
0157                                                         /** Sets the cell at row **a_row** and column **a_column** to **a_value**. */
0158         void set( std::size_t a_row                     /**< The cell's row. */,
0159                   std::size_t a_column                  /**< The cell's row. */,
0160                   double a_value                        /**< The value to put in the cell. */ ) 
0161                                         {  m_matrix[a_row][a_column] = a_value; }
0162                                                         /** Sets the row at **a_row** to **a_vector**. */
0163         void set( std::size_t a_row                     /**< The row to set. */,
0164                   Vector const &a_vector                /**< The Vector to set at row **a_row**. */ )
0165                                         {  m_matrix[a_row] = a_vector; }
0166         void push_back( Vector const &a_vector );
0167         Matrix transpose( );
0168         void reverse( );
0169         void print( std::string const &a_prefixForRow ) const ;
0170 };
0171 
0172 }
0173 
0174 #endif      // End of GIDI_data_hpp_included