Mantid
Loading...
Searching...
No Matches
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
Mantid::Geometry::SymmetryOperationSymbolParser Class Reference

This is a parser for symmetry operation symbols in the Jones faithful representation. More...

#include <SymmetryOperationSymbolParser.h>

Static Public Member Functions

static std::string getNormalizedIdentifier (const Kernel::IntMatrix &matrix, const V3R &vector)
 Returns the Jones faithful representation of a symmetry operation. More...
 
static std::string getNormalizedIdentifier (const MatrixVectorPair< int, V3R > &data)
 Returns a Jones faithful representation of the symmetry operation characterized by the supplied matrix/column pair. More...
 
static MatrixVectorPair< int, V3RparseIdentifier (const std::string &identifier)
 Tries to parse the given symbol. More...
 

Protected Member Functions

 SymmetryOperationSymbolParser ()=default
 

Static Protected Member Functions

static bool isValidMatrixRow (const int *element, size_t columnNumber)
 Checks if there are either 1 or 2 zeros in a given matrix row and all non-zero elements are 1 or -1. More...
 
static void verifyMatrix (const Kernel::IntMatrix &matrix)
 Verify that the matrix does not contain elements with abs(element) > 1 and has an acceptable number of non-zero elements. More...
 

Detailed Description

This is a parser for symmetry operation symbols in the Jones faithful representation.

It creates matrix and a vector component from the given symbol. First an example with no translational component, the inversion:

-x,-y,-z

Parsing this symbol returns the following matrix/vector pair:

 Matrix    Vector
-1  0  0     0
 0 -1  0     0
 0  0 -1     0

Translational components, as required for screw axes and glide planes are given as rational numbers, such as in this 2_1 screw axis around z:

-x,-y,z+1/2

Which returns the following matrix/vector pair:

 Matrix    Vector
-1  0  0     0
 0 -1  0     0
 0  0  1    1/2

From these components, a SymmetryOperation object can be constructed. See the documentation for SymmetryOperation and SymmetryOperationFactory.

Author
Michael Wedel, Paul Scherrer Institut - SINQ
Date
30/09/2014

Definition at line 52 of file SymmetryOperationSymbolParser.h.

Constructor & Destructor Documentation

◆ SymmetryOperationSymbolParser()

Mantid::Geometry::SymmetryOperationSymbolParser::SymmetryOperationSymbolParser ( )
protecteddefault

Member Function Documentation

◆ getNormalizedIdentifier() [1/2]

std::string Mantid::Geometry::SymmetryOperationSymbolParser::getNormalizedIdentifier ( const Kernel::IntMatrix matrix,
const V3R vector 
)
static

Returns the Jones faithful representation of a symmetry operation.

This method generates a Jones faithful string for the given matrix and vector. The string is generated bases on some rules:

  • No spaces: 'x + 1/2' -> 'x+1/2'
  • Matrix components occur before vector components: '1/2+x' -> 'x+1/2'
  • No leading '+' signs: '+x' -> 'x'
  • If more than one matrix element is present, they are ordered x, y, z: 'y-x' -> '-x+y'

If the matrix is not 3x3, an std::runtime_error exception is thrown.

Parameters
matrix
vector
Returns

Definition at line 85 of file SymmetryOperationSymbolParser.cpp.

References Mantid::Kernel::Matrix< T >::numCols(), and Mantid::Kernel::Matrix< T >::numRows().

◆ getNormalizedIdentifier() [2/2]

std::string Mantid::Geometry::SymmetryOperationSymbolParser::getNormalizedIdentifier ( const MatrixVectorPair< int, V3R > &  data)
static

◆ isValidMatrixRow()

bool Mantid::Geometry::SymmetryOperationSymbolParser::isValidMatrixRow ( const int *  element,
size_t  columnNumber 
)
staticprotected

Checks if there are either 1 or 2 zeros in a given matrix row and all non-zero elements are 1 or -1.

Definition at line 130 of file SymmetryOperationSymbolParser.cpp.

Referenced by verifyMatrix().

◆ parseIdentifier()

MatrixVectorPair< int, V3R > Mantid::Geometry::SymmetryOperationSymbolParser::parseIdentifier ( const std::string &  identifier)
static

Tries to parse the given symbol.

This method tries to parse a given symbol and returns the matrix/vector pair resulting from the parsing process. It takes a string representing a symmetry operation in the format: x+a/b, -y-c/d, e/f-z where x, y and z are the literals 'x', 'y' and 'z', while a-f are integers, representing rational numbers. The latter don't need to be present, a string "x,y,z" is valid. Leading plus-signs may be included if desired, so that "+x,+y,+z" is also valid.

If there is a problem, a Kernel::Exception::ParseError exception is thrown.

See also SymmetryOperationSymbolParser::getNormalizedIdentifier, which performs the opposite operation.

Parameters
identifier:: Symbol representing a symmetry operation
Returns
Kernel::IntMatrix and V3R, representing the symmetry operation.

Definition at line 49 of file SymmetryOperationSymbolParser.cpp.

References Mantid::Geometry::MatrixVectorPair< MatrixNumericType, VectorType >::getMatrix(), and verifyMatrix().

Referenced by Mantid::Geometry::isValidGeneratorString(), and Mantid::Geometry::SymmetryOperation::SymmetryOperation().

◆ verifyMatrix()

void Mantid::Geometry::SymmetryOperationSymbolParser::verifyMatrix ( const Kernel::IntMatrix matrix)
staticprotected

Verify that the matrix does not contain elements with abs(element) > 1 and has an acceptable number of non-zero elements.

Definition at line 18 of file SymmetryOperationSymbolParser.cpp.

References error, isValidMatrixRow(), Mantid::Kernel::Matrix< T >::numCols(), and Mantid::Kernel::Matrix< T >::numRows().

Referenced by parseIdentifier().


The documentation for this class was generated from the following files: