Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:11

0001 /*
0002  * Orthogonal_basis.h
0003  * Contains the declarations of the class Orthogonal_basis, related types and operators.
0004  * Created on: May 25, 2013
0005  * Author: Malin Sjodahl
0006  */
0007 
0008 #ifndef COLORFULL_Orthogonal_basis_h
0009 #define COLORFULL_Orthogonal_basis_h
0010 
0011 
0012 #include "Col_basis.h"
0013 
0014 
0015 namespace ColorFull {
0016 
0017 /// This class is for containing orthogonal bases,
0018 /// i.e. bases where the scalar product matrix is diagonal.
0019 /// ColorFull has (currently) no functionality for creating
0020 /// orthogonal bases, but orthogonal bases
0021 /// can be read in using read_in _Col_basis.
0022 class Orthogonal_basis:public Col_basis {
0023 
0024 public:
0025     /// Default constructor, puts private variable orthogonal_basis=true
0026     /// and calls the constructor of Col_basis.
0027     Orthogonal_basis():Col_basis(){
0028         orthogonal_basis = true;
0029     }
0030 
0031     /// To contain information about scalar products as a dvec,
0032     /// i.e., entry i is the square of vector i.
0033     dvec diagonal_d_spm;
0034 
0035     /// To contain information about scalar products as a Poly_vec,
0036     /// i.e., entry i is the square of vector i.
0037     Poly_vec diagonal_P_spm;
0038 
0039 
0040     /******************** Functions for scalar products **********************/
0041 
0042     /// Calculates the scalar product matrix assuming the basis to be orthogonal.
0043     /// Calculates both the double (d_spm) and the Polynomial (P_spm) matrices and
0044     /// saves to default file names.
0045     void scalar_product_matrix();
0046 
0047     /// Calculates the diagonal entries in the scalar product matrix,
0048     /// and (depending on arguments), saves them to the member variables
0049     /// diagonal_P_spm and diagonal_d_spm.
0050     /// This function is used by the Orthogonal_basis version of
0051     /// scalar_product_matrix.
0052     void diagonal_scalar_product_matrix( bool save_P_diagonal_spm, bool save_d_diagonal_spm, bool use_mem );
0053 
0054     /// The decomposition of a Col_amp in an orthogonal basis is done
0055     /// by calculating scalar products and dividing out the norm.
0056     /// The norm is evaluated numerically.
0057     Poly_vec decompose( const Col_amp & Ca );
0058 
0059     /// Function for calculating scalar products
0060     /// given the information about the basis and the scalar product matrix in the basis.
0061     /// The Col_amps are first decomposed using decompose,
0062     /// and then squared using the scalar product matrix P_spm.
0063     /// An orthogonal scalar product matrix is assumed.
0064     Polynomial scalar_product( const Col_amp & Ca1, const Col_amp & Ca2 );
0065 
0066     /// Function for calculating scalar products
0067     /// given the information about the basis
0068     /// and the scalar product matrix in numerical form.
0069     /// The Col_amps are first decomposed using decompose,
0070     /// and then squared using diagonal_d_spm.
0071     /// For Orthogonal_basis, an orthogonal scalar product matrix is assumed.
0072     cnum scalar_product_num( const Col_amp & Ca1, const Col_amp & Ca2 );
0073 
0074     /// Calculates the scalar product between decomposed amplitudes v1, V2
0075     /// using the diagonal_d_spm diagonal numerical scalar product matrix.
0076     /// The vectors needs to be expressed in the basis contained in cb,
0077     /// i.e., the decomposition has to be known.
0078     cnum scalar_product_num( const cvec & v1, const cvec & v2 );
0079 
0080 
0081     /******************** Functions for reading and writing **********************/
0082 
0083     /// Creates a default filename for writing out diagonal scalar products.
0084     /// The boolean variable leading should be true if the name is for a leading
0085     /// Nc variable. The filename is then modified accordingly.
0086     std::string diagonal_spm_file_name( const bool leading, const bool poly ) const;
0087 
0088     /// Writes out diagonal_d_spm to the file filename.
0089     void write_out_diagonal_d_spm( std::string filename ) const;
0090 
0091     /// Writes out diagonal_d_spm to the standard filename, see diagonal_spm_file_name.
0092     void write_out_diagonal_d_spm( ) const;
0093 
0094     /// Writes out diagonal_P_spm to the file filename.
0095     void write_out_diagonal_P_spm( std::string filename ) const;
0096 
0097     /// Writes out diagonal_P_spm to the standard filename, see diagonal_spm_file_name.
0098     void write_out_diagonal_P_spm( ) const;
0099 
0100     /// Function for writing out a dvec (the diagonal scalar products, diagonal_d_spm)
0101     /// to a file with standard filename given by diagonal_spm_file_name.
0102     /// The boolean variable leading should be true if dv only has leading
0103     /// Nc contributions. The filename is then modified accordingly.
0104     void write_out_diagonal_spm( const dvec & dv, const bool leading ) const;
0105 
0106     /// Function for writing out a Poly_vec (the diagonal scalar products, diagonal_d_spm)
0107     /// to a file with standard filename given by diagonal_spm_file_name.
0108     /// The boolean variable leading should be true if Poly_vec only has leading
0109     /// Nc contributions. The filename is then modified accordingly.
0110     void write_out_diagonal_spm( const Poly_vec & pv, const bool leading ) const;
0111 
0112 private:
0113 
0114     /// Function for calculating the scalar products matrix.
0115     /// This function uses diagonal_scalar_product_matrix
0116     /// and saved the value of the diagonal scalar products between basis vector
0117     /// i and basis vector j in the i,j -entry in
0118     /// P_spm (if save P_spm is true) and d_spm (if save_d_spm is true).
0119     /// If use_mem is true, memoization is used.
0120     void scalar_product_matrix( bool save_P_spm, bool save_d_spm, bool use_mem );
0121 
0122 
0123 };// end class Orthogonal_basis
0124 
0125 }// end namespace ColorFull
0126 
0127 
0128 #endif /* COLORFULL_Orthogonal_basis_h */