| 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 SYMMAT43_VCDATA_HH_ |
| 28 |
#define SYMMAT43_VCDATA_HH_ |
| 29 |
|
| 30 |
#include "../utility_data_structure/SymMat.hh" |
| 31 |
#include "../utility_data_structure/VCData.hh" |
| 32 |
|
| 33 |
// Assume the first element is a symmetric matrix of size 3 and the second element is a 4-by-3 matrix. |
| 34 |
typedef pair< SymMat<VCData>, NRMat<Int4> > SymMat43_VCData; |
| 35 |
|
| 36 |
inline bool operator<(const SymMat<VCData>& lhs, const SymMat<VCData>& rhs) |
| 37 |
{ |
| 38 |
assert( lhs.size() == rhs.size() ); |
| 39 |
|
| 40 |
const Int4 ISIZE = lhs.size(); |
| 41 |
|
| 42 |
for(Int4 i=0; i<ISIZE; i++) |
| 43 |
for(Int4 j=i; j<ISIZE; j++) |
| 44 |
{ |
| 45 |
const map<Int4,type_coef> lhs_sym = lhs(i,j).putVecCoef(); |
| 46 |
const map<Int4,type_coef> rhs_sym = rhs(i,j).putVecCoef(); |
| 47 |
|
| 48 |
if( lhs_sym.size() < rhs_sym.size() ) return true; |
| 49 |
if( lhs_sym.size() > rhs_sym.size() ) return false; |
| 50 |
|
| 51 |
const map<Int4,type_coef> diff = rhs_sym - lhs_sym; |
| 52 |
if( diff.empty() ) continue; |
| 53 |
assert( diff.begin()->second != 0 ); |
| 54 |
if( diff.begin()->second > 0 ) return true; |
| 55 |
else return false; |
| 56 |
} |
| 57 |
return false; |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
inline bool operator==(const SymMat<VCData>& lhs, const SymMat<VCData>& rhs) |
| 62 |
{ |
| 63 |
assert( lhs.size() >= 3 ); |
| 64 |
assert( rhs.size() >= 3 ); |
| 65 |
|
| 66 |
map<Int4,type_coef> diff; |
| 67 |
|
| 68 |
for(Int4 i=0; i<3; i++) |
| 69 |
{ |
| 70 |
for(Int4 j=i; j<3; j++) |
| 71 |
{ |
| 72 |
if( lhs(i,j).putVecCoef() == rhs(i,j).putVecCoef() ) continue; |
| 73 |
return false; |
| 74 |
} |
| 75 |
} |
| 76 |
return true; |
| 77 |
}; |
| 78 |
|
| 79 |
|
| 80 |
#endif /*SYMMAT43_HH_*/ |