3 #include "boost/lexical_cast.hpp"
13 const std::multimap<symmetry_type, std::vector<std::string> >
14 traits<symmetry_type>::strval = {
33 std::stringstream stream;
35 Eigen::IOFormat format(opt.prec, opt.prec + 1);
37 auto print_coord = [&](
const xtal::Coordinate &coord) {
38 coord.print(
log, opt.coord_type, term, format);
41 auto print_axis = [&](
const xtal::Coordinate &coord) {
42 coord.print_axis(
log, opt.coord_type, term, format);
45 switch (info.op_type) {
53 print_axis(info.axis);
57 stream.setf(std::ios::showpoint);
59 print_axis(info.axis);
62 print_coord(info.screw_glide_shift);
68 <<
"-degree Rotation Operation about axis ";
70 print_axis(info.axis);
76 <<
"-degree Screw Operation along axis ";
79 print_axis(info.axis);
81 print_coord(info.screw_glide_shift);
91 <<
"-degree Rotoinversion Operation about axis ";
93 print_axis(info.axis);
109 std::stringstream ss;
116 std::stringstream
ss;
132 ss << std::setprecision(
opt.
prec) << val;
139 if (
add && coeff > 0) {
141 }
else if (coeff < 0) {
149 ss << std::setprecision(
opt.
prec) << coeff <<
"*" << var;
158 for (
int i = 0; i < 3; ++i) {
174 std::stringstream ss;
175 double tol = opt.
tol;
181 std::string _param =
"xyz";
183 for (
int i = 0; i < 3; ++i) {
189 std::string param = _param.substr(min_i, 1);
198 for (
int i = 0; i < 3; ++i) {
204 for (
int i = 0; i < 3; ++i) {
209 if (!writer.
ss.str().size()) {
212 ss << writer.
ss.str();
227 std::stringstream ss;
228 double tol = opt.
tol;
242 for (
int i = 0; i < 3; ++i) {
244 b = b - b[i] / a[i] * a;
249 for (
int i = 0; i < 3; ++i) {
251 a = a - a[i] / b[i] * b;
257 std::string _param =
"xyz";
259 for (
int i = 0; i < 3; ++i) {
266 for (
int j = 0; j < 3; ++j) {
273 if (min_i == -1 || min_j == -1) {
274 std::stringstream msg;
275 msg <<
"Unexpected error in sym_plane: Could not write a description for "
276 "the symmetry plane defined by a: "
277 << a.transpose() <<
", b: " << b.transpose()
278 <<
", p: " << p.transpose();
279 throw std::runtime_error(msg.str());
289 std::string param1 = _param.substr(min_i, 1);
290 std::string param2 = _param.substr(min_j, 1);
303 for (
int i = 0; i < 3; ++i) {
309 if (!writer.
ss.str().size()) {
312 ss << writer.
ss.str();
327 double tol = opt.
tol;
338 _v1 = x - x.dot(n) * n;
342 _v1 = y - y.dot(n) * n;
365 std::stringstream stream;
367 stream.flags(std::ios::showpoint | std::ios::fixed | std::ios::right);
368 Eigen::IOFormat format(opt.
prec, opt.
prec + 1);
371 auto print_r = [&](
bool inversion) {
374 if (inversion) stream <<
"-";
375 stream << boost::lexical_cast<std::string>(r);
376 }
else if (info.
angle < 180.) {
377 if (inversion) stream <<
"-";
378 stream << boost::lexical_cast<std::string>(r);
382 if (inversion) stream <<
"-";
383 stream << boost::lexical_cast<std::string>(r);
392 coord.print(stream, opt.
coord_type, term, format);
402 stream.setf(std::ios::showpoint);
410 stream.setf(std::ios::showpoint);
446 stream <<
"<error invalid>";
464 bool print_master_index =
false;
466 for (
const auto &op : g) {
467 if (op.has_valid_master() && i != op.index()) {
468 print_master_index =
true;
475 for (
const auto &op : g) {
477 if (print_master_index) {
478 log <<
" (" << op.index() + 1 <<
")";
503 bool print_master_index =
false;
505 for (
const auto &op : g) {
506 if (op.has_valid_master() && i != op.index()) {
507 print_master_index =
true;
514 for (
const auto &op : g) {
516 if (print_master_index) {
517 log <<
" (" << op.index() + 1 <<
")";
#define ENUM_IO_DEF(ENUM)
std::string indent_str() const
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Represents cartesian and fractional coordinates.
const Lattice & home() const
Access the home lattice of the coordinate.
vector_type as_vec(COORD_TYPE _mode) const
const vector_type & const_cart() const
user override to force const Access the Cartesian coordinate vector
std::string to_string(ENUM val)
Return string representation of enum class.
Eigen::CwiseUnaryOp< decltype(Local::lround_l< typename Derived::Scalar >), const Derived > lround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXl.
void print_matrix_tau_col(Log &log, const SymOp &op, Index prec)
Print formatted SymOp matrix and tau.
GenericDatumFormatter< std::string, ConfigEnumDataType > name()
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
std::string to_brief_unicode(const SymInfo &info, SymInfoOptions opt=SymInfoOptions())
Print symmetry symbol to string.
std::string description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to string.
std::string brief_description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to brief string.
void swap(ConfigDoF &A, ConfigDoF &B)
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
std::string sym_line(const xtal::Coordinate &axis, const xtal::Coordinate &point, SymInfoOptions opt)
Use axis and invariant point to return line in '0, y, 0'-type notation.
T min(const T &A, const T &B)
void print_sym_info(Log &log, const SymInfo &info, SymInfoOptions opt=SymInfoOptions())
Print SymInfo.
INDEX_TYPE Index
For long integer indexing:
std::string sym_plane(const xtal::Coordinate &v1, const xtal::Coordinate &v2, const xtal::Coordinate &point, SymInfoOptions opt)
Use two perpendicular vectors in plane and invariant point to return plane in 'x, y,...
Eigen::Matrix< int, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime > scale_to_int(const Eigen::MatrixBase< Derived > &val, double _tol=CASM::TOL)
void add_term(double coeff, std::string var)
PolyWriter(SymInfoOptions _opt=SymInfoOptions())
void add_constant(double val)
static void standardize(Eigen::Vector3d &v, double tol=TOL)
Simple struct to be used as return type for SymOp::info().
xtal::Coordinate screw_glide_shift
xtal::Coordinate location
A Cartesian coordinate that is invariant to the operation (if one exists)
bool time_reversal
If time reversal symmetry.
Options for printing SymInfo.