Develop and Download Open Source Software

Browse Subversion Repository

Contents of /BLDConograph_ver1/trunk/src/lattice_symmetry/lattice_symmetry.cc

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++src
File size: 6760 byte(s)
Monoclinic(B) -> Monoclinic(C)
1 /*
2 * The MIT License
3
4 BLDConograph (Bravais lattice determination module in Conograph)
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 #include <set>
28 #include "check_equiv.hh"
29 #include "../utility_lattice_reduction/put_Selling_reduced_lattice.hh"
30 #include "../utility_lattice_reduction/put_Buerger_reduced_lattice.hh"
31 #include "../bravais_type/BravaisType.hh"
32 #include "lattice_symmetry.hh"
33
34 inline bool checkIfFirstEntryIsPositive(const NRMat<Int4>& rhs)
35 {
36 assert( rhs.nrows() == 4 && rhs.ncols() == 3 );
37 for(Int4 i=0; i<3; i++)
38 for(Int4 j=0; j<3; j++)
39 {
40 if( rhs[i][j] > 0 ) return true;
41 else if( rhs[i][j] < 0 ) return false;
42 }
43 return false;
44 }
45
46 inline bool operator<(const NRMat<Int4>& lhs, const NRMat<Int4>& rhs)
47 {
48 assert( lhs.nrows() >= 3 && lhs.ncols() == 3 );
49 assert( rhs.nrows() == lhs.nrows() && rhs.ncols() == lhs.ncols() );
50 for(Int4 i=0; i<3; i++)
51 for(Int4 j=0; j<3; j++)
52 {
53 if( lhs[i][j] < rhs[i][j] ) return true;
54 if( rhs[i][j] < lhs[i][j] ) return false;
55 }
56 return false;
57 }
58
59
60 static void insert_super_obtuse_equiv(const pair< NRMat<Int4>, SymMat<Double> >& S_super,
61 const Double& resol, const Double& Max_totalQ,
62 map<NRMat<Int4>, SymMat<Double> >& equivalent_tray)
63 {
64 const Double totalQ = S_super.second(0,0) + S_super.second(1,1) + S_super.second(2,2) + S_super.second(3,3);
65
66 map<NRMat<Int4>, SymMat<Double> >::iterator it;
67 Int4 k,l;
68 for(Int4 i=0; i<3; i++)
69 {
70 for(Int4 j=i+1; j<4; j++)
71 {
72 const Double& Sij = S_super.second(i,j);
73
74 if( 0.0 < Sij ) continue;
75 if( !equiv_zero(S_super.second, i,j, resol) ) continue;
76 if( Max_totalQ < totalQ - Sij * 2.0 ) continue;
77
78 const NRMat<Int4>& mat = put_reduction_matrix_dim_4(i,j);
79 pair< NRMat<Int4>, SymMat<Double> > S_super_equiv( mprod(mat, S_super.first),
80 transform_sym_matrix(mat, S_super.second) );
81
82 // Ki, Kj, Kk, Kl -> -Ki, Kj, Ki+Kk, Ki+Kl => S_super_equiv.second(k,l) = S_super.second(k,l) - S_super.second(i,j)
83 // sum_{i=0}^4 S_super_equiv.second(i,i) = -2*S_super(i,j) + sum_{i=0}^4 S_super.second(i,i)
84 put_complement_set4(i,j,k,l);
85 if( 0.0 < S_super_equiv.second(k,l) && !equiv_zero(S_super_equiv.second, k,l, resol) ) continue;
86 moveSmallerDiagonalLeftUpper(S_super_equiv.second, S_super_equiv.first);
87
88 if( !checkIfFirstEntryIsPositive( S_super_equiv.first ) ) S_super_equiv.first *= -1;
89
90 it = equivalent_tray.find(S_super_equiv.first);
91
92 if( it == equivalent_tray.end() )
93 {
94 equivalent_tray.insert( S_super_equiv );
95 insert_super_obtuse_equiv( S_super_equiv, resol, Max_totalQ, equivalent_tray );
96 }
97 }
98 }
99 };
100
101
102
103 static void set_super_obtuse_equiv(const SymMat<Double>& S_super_obtuse, const Double& resol,
104 map< NRMat<Int4>, SymMat<Double> >& equivalent_tray)
105 {
106 assert( S_super_obtuse.size() == 4 );
107 equivalent_tray.clear();
108
109 const pair< NRMat<Int4>, SymMat<Double> > S_super_obtuse_pair(put_transform_matrix_row3to4(), S_super_obtuse);
110 equivalent_tray.insert( S_super_obtuse_pair );
111
112 const Double Max_totalQ = ( S_super_obtuse(0,0) + S_super_obtuse(1,1)
113 + S_super_obtuse(2,2) + S_super_obtuse(3,3) ) * ( 1.0 + resol );
114
115 insert_super_obtuse_equiv( S_super_obtuse_pair, resol, Max_totalQ, equivalent_tray );
116 };
117
118
119
120 inline void permute_row_column(const Int4& i, const Int4& j, pair< NRMat<Int4>, SymMat<Double> >& rhs)
121 {
122 const NRMat<Int4> tmat = put_permutation_matrix_dim_4(i, j);
123 rhs.first = mprod( tmat, rhs.first );
124 if( !checkIfFirstEntryIsPositive( rhs.first) ) rhs.first *= -1;
125 rhs.second = transform_sym_matrix( tmat, rhs.second );
126 };
127
128
129 // On input, for any i < j such that stage < i, j < 4, S_super(i, i) <= S_super(j, j)
130 static void insert_super_permuted(const Int4& stage,
131 const pair< NRMat<Int4>, SymMat<Double> >& S_super,
132 const Double& resol,
133 map< NRMat<Int4>, SymMat<Double> >& equivalent_tray)
134 {
135 if( stage >= 3 )
136 {
137 equivalent_tray.insert( S_super );
138 return;
139 }
140
141 insert_super_permuted(stage+1, S_super, resol, equivalent_tray);
142
143 pair< NRMat<Int4>, SymMat<Double> > S_super_permuted = S_super;
144
145 for(Int4 i=stage+1; i<4; i++)
146 {
147 if( !equiv_resol(S_super.second(stage, stage), S_super.second(i,i), resol ) ) break;
148 permute_row_column( stage, i, S_super_permuted );
149 insert_super_permuted(stage+1, S_super_permuted, resol, equivalent_tray);
150 }
151 };
152
153
154 static void set_super_permuted(const pair< NRMat<Int4>, SymMat<Double> >& S_super,
155 const Double& resol,
156 map< NRMat<Int4>, SymMat<Double> >& equivalent_tray)
157 {
158 equivalent_tray.clear();
159 insert_super_permuted( 0, S_super, resol, equivalent_tray );
160 };
161
162
163
164 void put_S_super_obtuse_equiv(const SymMat<Double>& S_super_obtuse, const Double& resol,
165 vector< SymMat<Double> >& S_super_obtuse_equiv)
166 {
167 S_super_obtuse_equiv.clear();
168
169 map< NRMat<Int4>, SymMat<Double> > super_equiv_tray;
170 set_super_obtuse_equiv( S_super_obtuse, resol, super_equiv_tray );
171
172 map< NRMat<Int4>, SymMat<Double> > permute_equiv_tray;
173 map< NRMat<Int4>, SymMat<Double> >::const_iterator it2;
174 map< NRMat<Int4>, SymMat<Double> > S_super_obtuse_equiv_tray;
175 for(map< NRMat<Int4>, SymMat<Double> >::iterator it=super_equiv_tray.begin(); it!=super_equiv_tray.end(); it++)
176 {
177 it2 = S_super_obtuse_equiv_tray.find(it->first);
178 if( it2 != S_super_obtuse_equiv_tray.end() ) continue;
179
180 set_super_permuted( *it, resol, permute_equiv_tray );
181 for(map< NRMat<Int4>, SymMat<Double> >::const_iterator it3=permute_equiv_tray.begin(); it3!=permute_equiv_tray.end(); it3++)
182 {
183 S_super_obtuse_equiv_tray.insert(*it3);
184 S_super_obtuse_equiv.push_back(it3->second);
185 }
186 }
187 }

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