Develop and Download Open Source Software

Browse Subversion Repository

Contents of /BLDConograph_ver1/trunk/src/lattice_symmetry/check_equiv.hh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download) (as text)
Sat Aug 6 01:34:09 2016 UTC (7 years, 7 months ago) by rtomiyasu
File MIME type: text/x-c++hdr
File size: 5134 byte(s)
Monoclinic(B) -> Monoclinic(C)
1 /*
2 * The MIT License
3
4 Conograph (powder auto-indexing program)
5
6 Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 *
26 */
27 #ifndef CHECK_EQUIV_HH_
28 #define CHECK_EQUIV_HH_
29
30 #include "../utility_data_structure/SymMat.hh"
31 #include "../utility_data_structure/VCData.hh"
32
33 inline bool equiv_resol(const Double& lhs, const Double& rhs,
34 const Double& resol)
35 {
36 Double diff = lhs - rhs;
37 Double max_value = max( fabs(lhs), fabs(rhs) );
38 if( fabs( diff ) <= max_value * resol ) return true;
39 return false;
40 }
41
42 inline bool equiv_zero(const SymMat<Double>& S, const Int4& i, const Int4& j, const Double& resol)
43 {
44 return equiv_resol( S(i,i)+S(j,j)+S(i,j)*2.0, S(i,i)+S(j,j)-S(i,j)*2.0, resol);
45 }
46
47 inline bool equiv_zero(const SymMat<Double>& S, const Int4& i, const Int4& j, const Int4& l, const Double& resol)
48 {
49 // Ki, Kj, Kl, Km, Kn -> Ki, -Kj, Kl, Kj+Km, Kj+Kn.
50 // (Sii + Sjj + Sij*2) + (Sjj + Sll + Sjl*2) + (Sii + Sjj + Sll + Sij*2 + Sjl*2 + Sil*2)
51 // = (Sii + Sjj - Sij*2) + (Sjj + Sll - Sjl*2) + (Sii + Sjj + Sll - Sij*2 - Sjl*2 + Sil*2).
52 return equiv_resol(
53 (S(i,i)+S(j,j)+S(l,l)+S(i,l)+(S(i,j)+S(j,l))*2.0)*2.0+S(j,j),
54 (S(i,i)+S(j,j)+S(l,l)+S(i,l)-(S(i,j)+S(j,l))*2.0)*2.0+S(j,j), resol);
55 }
56
57 inline bool equiv_zero(const SymMat<Double>& S, const Int4& i, const Int4& j, const Int4& k, const Int4& l, const Double& resol)
58 {
59 // Ki, Kj, Kk, Kl, Kn -> Ki+Kk, -Kj, -Kk, Kj+Kl, Kj+Kk+Kn
60 // (Sii + Sjj + Sij*2) + (Skk + Sll + Skl*2) + (Sii + Sjj + Skk + Sij*2 + Sjk*2 + Sik*2) + (Sjj + Skk + Sll + Sjk*2 + Skl*2 + Sjl*2)
61 // = (Sii + Sjj - Sij*2) + (Skk + Sll - Skl*2) + (Sii + Sjj + Skk - Sij*2 - Sjk*2 + Sik*2) + (Sjj + Skk + Sll - Sjk*2 - Skl*2 + Sjl*2).
62 return equiv_resol(
63 (S(i,i)+S(j,j)+S(k,k)+S(l,l)+S(i,k)+S(j,l)+(S(i,j)+S(j,k)+S(k,l))*2.0)*2.0+S(j,j)+S(k,k),
64 (S(i,i)+S(j,j)+S(k,k)+S(l,l)+S(i,k)+S(j,l)-(S(i,j)+S(j,k)+S(k,l))*2.0)*2.0+S(j,j)+S(k,k), resol);
65 }
66
67
68 inline bool check_equiv_m(const SymMat<Double>& lhs, //const Double& lhs_detS, const Double& lhs_detS_var,
69 const SymMat<Double>& rhs, //const Double& rhs_detS, const Double& rhs_detS_var,
70 const Double& resol)
71 {
72 assert( lhs.size() == 3 );
73 assert( rhs.size() == 3 );
74
75 if( !equiv_resol( lhs(0,0), rhs(0,0), resol) )
76 {
77 return false;
78 }
79 if( !equiv_resol( lhs(1,1), rhs(1,1), resol) )
80 {
81 return false;
82 }
83 if( !equiv_resol( lhs(2,2), rhs(2,2), resol) )
84 {
85 return false;
86 }
87 if( !equiv_resol( lhs(0,0)+lhs(1,1)+lhs(0,1)*2.0, rhs(0,0)+rhs(1,1)+rhs(0,1)*2.0, resol) )
88 {
89 return false;
90 }
91 if( !equiv_resol( lhs(0,0)+lhs(2,2)+lhs(0,2)*2.0, rhs(0,0)+rhs(2,2)+rhs(0,2)*2.0, resol) )
92 {
93 return false;
94 }
95 if( !equiv_resol( lhs(1,1)+lhs(2,2)+lhs(1,2)*2.0, rhs(1,1)+rhs(2,2)+rhs(1,2)*2.0, resol) )
96 {
97 return false;
98 }
99 return true;
100 }
101
102
103 inline bool check_equiv_m(const SymMat<VCData>& lhs, //const Double& lhs_detS, const Double& lhs_detS_var,
104 const SymMat<VCData>& rhs, //const Double& rhs_detS, const Double& rhs_detS_var,
105 const Double& cv2)
106 {
107 assert( lhs.size() == 3 );
108 assert( rhs.size() == 3 );
109
110 if( !vc_equiv( lhs(0,0), rhs(0,0), cv2) ) return false;
111 if( !vc_equiv( lhs(1,1), rhs(1,1), cv2) ) return false;
112 if( !vc_equiv( lhs(2,2), rhs(2,2), cv2) ) return false;
113 if( !vc_equiv( lhs(0,0) + lhs(1,1) + lhs(0,1)*2, rhs(0,0) + rhs(1,1) + rhs(0,1)*2, cv2) ) return false;
114 if( !vc_equiv( lhs(0,0) + lhs(2,2) + lhs(0,2)*2, rhs(0,0) + rhs(2,2) + rhs(0,2)*2, cv2) ) return false;
115 if( !vc_equiv( lhs(1,1) + lhs(2,2) + lhs(1,2)*2, rhs(1,1) + rhs(2,2) + rhs(1,2)*2, cv2) ) return false;
116
117 return true;
118 }
119
120
121 inline bool check_equiv_s(const SymMat<Double>& lhs, const SymMat<Double>& rhs,
122 const Double& resol)
123 {
124 assert( rhs.size() == lhs.size() );
125
126 const Int4 ISIZE = lhs.size();
127 for(Int4 i=0; i<ISIZE; i++)
128 {
129 if( !equiv_resol( lhs(i,i), rhs(i,i), resol) )
130 {
131 return false;
132 }
133 for(Int4 j=1; j<i; j++)
134 {
135 if( !equiv_resol( lhs(i,i)+lhs(j,j)+lhs(i,j)*2.0, rhs(i,i)+rhs(j,j)+rhs(i,j)*2.0, resol) )
136 {
137 return false;
138 }
139 }
140 }
141
142 return true;
143 }
144
145
146 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26