Validates patterns that are passed to PropertyExtractor calls.
The PatternValidator checks whether a list of Indices satisfies given rules. It is used by PropertyExtractors to verify that the Indices that are passed to its calculate-functions have the right format.
The PatternValidator is used as follows
patternValidator.validate(patterns);
Here patterns is a list of Indices that can contain Subindex flags. If all patterns pass, nothing happens. If some pattern does not pass, an error message is generated.
Number of component @link Index Indices@endlink
A multi-component Index is an Index such as {{x, y, z}, {x, y, z}}, which has two component Indices. By default, any number of component Indices are allowed. However, it is possible to configure the PatternValidator to require a given number of component Indices using
patternValidator.setNumRequiredComponentIndices(2);
Allowed Subindex flags
By default, no Subindex flags are allowed in the patterns. To allow a number of Subindex flags to be present in the pattern, add them using, for example
patternValidator.setAllowedSubindexFlags({IDX_ALL, IDX_SPIN});
Example
#include "TBTK/PropertyExtractor/PatternValidator.h"
using namespace TBTK;
using namespace PropertyExtractor;
int main(){
patternValidator.setNumRequiredComponentIndices(2);
patternValidator.setAllowedSubindexFlags({IDX_ALL, IDX_SPIN});
patternValidator.validate({
{{1, IDX_ALL, IDX_SPIN}, {2, 3, 4}},
{{2, IDX_ALL, IDX_SPIN}, {2, 3, 4}}
});
}
Output