a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
SparseDoublyIndexedBlock.hpp
Go to the documentation of this file.
1/*
2 * SparseDoublyIndexedBlock.hpp
3 *
4 * Created on: Mar 19, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#ifndef SPARSEDOUBLYINDEXEDBLOCK_HPP_
15#define SPARSEDOUBLYINDEXEDBLOCK_HPP_
16
19
20namespace LHPC
21{
22 namespace SLHA
23 {
24 /* this template class interprets all the blocks with the same name, though
25 * differing scale values, which are interpreted as having a pair of int
26 * indices which does not have to have entries for each value (nor even
27 * necessarily positive index values).
28 */
29 template< class ValueClass >
31 InterpreterClass::SparseDoublyIndexed< ValueClass > >
32 {
33 public:
34 SparseDoublyIndexedBlock( std::string const& blockName,
35 ValueClass const& defaultUnsetValue,
36 bool const isVerbose = false,
37 int const firstIndexDigits = 2,
38 int const secondIndexDigits = 2 );
39 virtual
41
42 ValueClass&
43 operator()( std::pair< int, int > const& indexPair );
44 // this returns operator() of the lowest-scale interpreter.
45 ValueClass const&
46 operator()( std::pair< int, int > const& indexPair ) const;
47 // const version of above.
48 ValueClass&
49 operator()( int const firstIndex,
50 int const secondIndex )
51 { return (*this)( std::make_pair( firstIndex,
52 secondIndex ) ); }
53 ValueClass const&
54 operator()( int const firstIndex,
55 int const secondIndex ) const
56 { return (*this)( std::make_pair( firstIndex,
57 secondIndex ) ); }
58 bool
59 hasEntry( std::pair< int, int > const& indexPair ) const;
60 // this returns hasEntry( indexPair ) of the lowest-scale interpreter.
61 bool
62 hasEntry( int const firstIndex,
63 int const secondIndex ) const
64 { return hasEntry( std::make_pair( firstIndex,
65 secondIndex ) ); }
66 };
67
68
69
70
71
72 template< class ValueClass >
73 inline
75 std::string const& blockName,
76 ValueClass const& defaultUnsetValue,
77 bool const isVerbose,
78 int const firstIndexDigits,
79 int const secondIndexDigits ) :
80 IndexedBlockTemplate< ValueClass,
81 InterpreterClass::SparseDoublyIndexed< ValueClass > >(
82 blockName,
83 defaultUnsetValue,
84 isVerbose,
85 BOL::Vi( firstIndexDigits ).e( secondIndexDigits ) )
86 {
87 // just an initialization list.
88 }
89
90 template< class ValueClass >
91 inline
93 {
94 // does nothing.
95 }
96
97
98 template< class ValueClass >
99 inline ValueClass&
101 std::pair< int, int > const& indexPair )
102 // this returns operator() of the lowest-scale interpreter.
103 {
104 return this->dataBlocks[ this->lowestScaleIndex ]( indexPair );
105 }
106
107 template< class ValueClass >
108 inline ValueClass const&
110 std::pair< int, int > const& indexPair ) const
111 // const version of above.
112 {
113 return this->dataBlocks[ this->lowestScaleIndex ]( indexPair );
114 }
115
116 template< class ValueClass >
117 inline bool
119 std::pair< int, int > const& indexPair ) const
120 // derived classes over-ride this to interpret their data as a
121 // std::string.
122 {
123 return this->dataBlocks[ this->lowestScaleIndex ].hasEntry( indexPair );
124 }
125
126 } // end of SLHA namespace
127
128} // end of LHPC namespace
129
130
131#endif /* SPARSEDOUBLYINDEXEDBLOCK_HPP_ */
ValueClass const defaultUnsetValue
Definition: SlhaBlock.hpp:139
bool hasEntry(int const firstIndex, int const secondIndex) const
SparseDoublyIndexedBlock(std::string const &blockName, ValueClass const &defaultUnsetValue, bool const isVerbose=false, int const firstIndexDigits=2, int const secondIndexDigits=2)
ValueClass const & operator()(int const firstIndex, int const secondIndex) const
ValueClass & operator()(std::pair< int, int > const &indexPair)
ValueClass & operator()(int const firstIndex, int const secondIndex)
bool hasEntry(std::pair< int, int > const &indexPair) const
StdVectorFiller< int > Vi