Mantid
Loading...
Searching...
No Matches
ProductOfCyclicGroups.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10
11#include <algorithm>
12
13namespace Mantid::Geometry {
14
16ProductOfCyclicGroups::ProductOfCyclicGroups(const std::string &generators) : Group(*(getGeneratedGroup(generators))) {}
17
19ProductOfCyclicGroups::ProductOfCyclicGroups(const std::vector<Group_const_sptr> &factorGroups)
20 : Group(*(getProductOfCyclicGroups(factorGroups))) {}
21
24Group_const_sptr ProductOfCyclicGroups::getGeneratedGroup(const std::string &generators) const {
25 std::vector<SymmetryOperation> operations = SymmetryOperationFactory::Instance().createSymOps(generators);
26 std::vector<Group_const_sptr> factorGroups = getFactorGroups(operations);
27
28 return getProductOfCyclicGroups(factorGroups);
29}
30
33std::vector<Group_const_sptr>
34ProductOfCyclicGroups::getFactorGroups(const std::vector<SymmetryOperation> &symmetryOperations) const {
35 std::vector<Group_const_sptr> groups;
36 groups.reserve(symmetryOperations.size());
37 std::transform(
38 symmetryOperations.cbegin(), symmetryOperations.cend(), std::back_inserter(groups),
39 [](const auto &symmetryOperation) { return GroupFactory::create<CyclicGroup>(symmetryOperation.identifier()); });
40 return groups;
41}
42
45ProductOfCyclicGroups::getProductOfCyclicGroups(const std::vector<Group_const_sptr> &factorGroups) const {
46 Group_const_sptr productGroup = std::make_shared<const Group>(*(factorGroups.front()));
47
48 for (size_t i = 1; i < factorGroups.size(); ++i) {
49 productGroup = productGroup * factorGroups[i];
50 }
51
52 return productGroup;
53}
54
55} // namespace Mantid::Geometry
The class Group represents a set of symmetry operations (or symmetry group).
Definition: Group.h:135
Group_const_sptr getGeneratedGroup(const std::string &generators) const
Generates symmetry operations from the string, creates a CyclicGroup from each operation and multipli...
ProductOfCyclicGroups(const std::string &generators)
String constructor with semicolon-separated symmetry operations.
Group_const_sptr getProductOfCyclicGroups(const std::vector< Group_const_sptr > &factorGroups) const
Multiplies all supplied groups and returns the result.
std::vector< Group_const_sptr > getFactorGroups(const std::vector< SymmetryOperation > &symmetryOperations) const
Returns a vector of cyclic groups for the given vector of symmetry operations.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< const Group > Group_const_sptr
Definition: Group.h:179