-
Notifications
You must be signed in to change notification settings - Fork 0
/
LRL_Cell.cpp
563 lines (480 loc) · 19.9 KB
/
LRL_Cell.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <string>
#include "LRL_Cell.h"
#include "LRL_Cell_Degrees.h"
#include "C3.h"
#include "B4.h"
#include "D7.h"
#include "Delone.h"
#include "G6.h"
#include "LRL_MinMaxTools.h"
#include "LRL_RandTools.h"
#include "MatG6.h"
#include "MatS6.h"
#include "rhrand.h"
#include "S6.h"
#include "Selling.h"
#include "LRL_StringTools.h"
int randSeed1 = 19191;
const double thirtyDegrees = 30.0 / 180.0 * 4 * atan(1.0);
const double sixtyDegrees = 2.0*thirtyDegrees;
const double ninetyDegrees = 3.0*thirtyDegrees;
const double oneeightyDegrees = 180.0;
const double threesixtyDegrees = 360.0;
double LRL_Cell::randomLatticeNormalizationConstant = 10.0;
double LRL_Cell::randomLatticeNormalizationConstantSquared = randomLatticeNormalizationConstant * randomLatticeNormalizationConstant;
/* class LRL_Cell
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A class to implement some common operations for unit cells as usually
used with xray crystallography. Conversions from G6 to unit cell and
from unit to G6 are included. The angles are ALWAYS in RADIANS.
LRL_Cell(void) == default constructor
LRL_Cell( const G6& v ) == constructor to convert a G6 vector to unit cell
double Volume(void) == return the volume of a unit cell
double LRL_Cell::operator[](const int& n) const == return the n-th element of a cell (zero-based)
LRL_Cell LRL_Cell::Inverse( void ) const == compute the reciprocal cell
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: LRL_Cell()
// Description: default constructor
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell::LRL_Cell(void)
: m_valid(false)
{
m_cell.resize(6);
}
LRL_Cell::LRL_Cell(const LRL_Cell& c)
: m_cell(c.m_cell)
, m_valid(c.m_valid)
{
}
LRL_Cell::LRL_Cell( const std::vector<double>& v )
: m_cell( v )
, m_valid( (*this).m_valid )
{
for (size_t i = 3; i < 6; ++i)
m_cell[i] *= 4.0 * atan( 1.0 ) / 180.0;
}
LRL_Cell::LRL_Cell(const std::string& s)
: m_valid(true)
{
m_cell = LRL_StringTools::FromString(s);
m_valid = m_cell.size() == 6 && m_valid &&
m_cell[3] < oneeightyDegrees &&
m_cell[4] < oneeightyDegrees &&
m_cell[5] < oneeightyDegrees &&
(m_cell[3] + m_cell[4] + m_cell[5]) < threesixtyDegrees;
if (m_valid) {
for (size_t i = 3; i < 6; ++i)
m_cell[i] *= 4.0 * atan(1.0) / 180.0;
}
}
LRL_Cell::LRL_Cell(const S6& ds)
{
m_cell.resize( 6 );
const S6& s( ds );
double& a = (*this)[0];
double& b = (*this)[1];
double& c = (*this)[2];
double& al = (*this)[3];
double& be = (*this)[4];
double& ga = (*this)[5];
const double asq = -(s[3] + s[2] + s[1]);
const double bsq = -(s[4] + s[2] + s[0]);
const double csq = -(s[5] + s[1] + s[0]);
m_valid = ds.GetValid() && asq > 0.0 && bsq > 0.0 && csq > 0.0;
if ( m_valid){
a = sqrt( asq );
b = sqrt( bsq );
c = sqrt( csq );
const double cosal = s[0] / (b * c);
const double cosbe = s[1] / (a * c);
const double cosga = s[2] / (a * b);
m_valid = abs( cosal ) < 1.0 && abs( cosbe ) < 1.0 && abs( cosga ) < 1.0;
if (m_valid) {
al = acos( cosal );
be = acos( cosbe );
ga = acos( cosga );
}
static const double pi = 4.0 * atan( 1.0 );
static const double twopi = 2.0 * pi;
m_valid = (al + be + ga) < twopi;
}
}
LRL_Cell::LRL_Cell(const C3& c3)
{
static const double pi = 4.0*atan(1.0);
static const double twopi = 2.0*pi;
*this = S6(c3);
m_valid = m_valid && c3.GetValid() && GetValid() && m_cell[3] < pi && m_cell[4] < pi && m_cell[5] < pi && (m_cell[3] + m_cell[4] + m_cell[5])< twopi
&& (m_cell[3] + m_cell[4] + m_cell[5] - 2.0 * maxNC(m_cell[3], m_cell[4], m_cell[5]) >= 0.0);
}
LRL_Cell::LRL_Cell(const B4& dt)
{
(*this) = G6(dt);
m_valid = dt.GetValid( );
}
std::ostream& operator<< (std::ostream& o, const LRL_Cell& c) {
std::streamsize oldPrecision = o.precision();
o << std::fixed << std::setprecision(5);
for (size_t i = 0; i < 6; ++i)
o << std::setw(9) << c.m_cell[i] << " ";
o << std::setprecision(oldPrecision);
o.unsetf(std::ios::floatfield);
return o;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: LRL_Cell()
// Description: constructor to convert load a LRL_Cell from doubles
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell::LRL_Cell( const double a, const double b, const double c,
const double alpha, const double beta, const double gamma)
: m_valid(true)
{
m_cell.resize( 6 );
m_cell[0] = a;
m_cell[1] = b;
m_cell[2] = c;
m_cell[3] = alpha / 57.2957795130823;
m_cell[4] = beta / 57.2957795130823;
m_cell[5] = gamma / 57.2957795130823;
const double lowerlimit = 0.001;
m_valid = m_valid && a > lowerlimit && b > lowerlimit && c > lowerlimit && alpha > lowerlimit && beta > lowerlimit && gamma > lowerlimit
&& alpha < 179.99 && beta < 179.99 && gamma < 179.99 && (alpha + beta + gamma) < 360.0 &&
(alpha + beta + gamma - 2.0*maxNC(alpha, beta, gamma) >= 0.0);
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: LRL_Cell()
// Description: constructor to convert an input G6 vector (as a vector of
// doubles to E3 lengths and angles. The angles are
// stored as RADIANS (only). For angles as degrees, use the
// class LRL_Cell_Degrees.
// with lengths and angles as DEGREES. For consistency, a
// "LRL_Cell" object will never contain degrees.
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell::LRL_Cell(const G6& g6)
: m_valid(true)
{
static const double pi = 4.0*atan(1.0);
static const double twopi = 2.0*pi;
m_cell.resize(6);
const double lowerlimit = 0.0001;
if ( (!g6.GetValid()) || g6.norm() < 1.0E-10 || g6[0] <= lowerlimit || g6[1] <= lowerlimit || g6[2] <= lowerlimit) {
*this = LRL_Cell(0, 0, 0, 0, 0, 0);
return;
}
else {
m_cell[0] = sqrt(g6[0]);
m_cell[1] = sqrt(g6[1]) ;
m_cell[2] = sqrt(g6[2]);
const double cosalpha(0.5*g6[3] / (m_cell[1] * m_cell[2]));
const double cosbeta(0.5*g6[4] / (m_cell[0] * m_cell[2]));
const double cosgamma(0.5*g6[5] / (m_cell[0] * m_cell[1]));
if (std::abs(cosalpha) >= 0.9999 || std::abs(cosbeta) >= 0.9999 || std::abs(cosgamma) >= 0.9999) {
*this = LRL_Cell(0, 0, 0, 0, 0, 0);
m_valid = false;
return;
}
const double sinalpha(sqrt(1.0 - cosalpha * cosalpha));
const double sinbeta(sqrt(1.0 - cosbeta * cosbeta));
const double singamma(sqrt(1.0 - cosgamma * cosgamma));
// compute the v angles in radians
m_cell[3] = atan2(sinalpha, cosalpha);
m_cell[4] = atan2(sinbeta, cosbeta);
m_cell[5] = atan2(singamma, cosgamma);
m_valid = m_valid && m_cell[0] > lowerlimit && m_cell[1] > lowerlimit && m_cell[2] > lowerlimit &&
m_cell[3] > lowerlimit && m_cell[4] > lowerlimit && m_cell[5] > lowerlimit &&
m_cell[3] < pi && m_cell[4] < pi && m_cell[5] < pi && (m_cell[3] + m_cell[4] + m_cell[5])< twopi
&& (m_cell[3] + m_cell[4] + m_cell[5] - 2.0 * maxNC(m_cell[3], m_cell[4], m_cell[5]) >= 0.0);
}
}
LRL_Cell::LRL_Cell(const D7& v7)
: m_valid(v7.GetValid())
{
(*this) = G6(v7);
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: LRL_Cell()
// Description: destructor
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell::~LRL_Cell(void)
{
}
void Prepare2CellElements( const double minEdge, const double maxEdge, const size_t i, LRL_Cell& c ) {
static RHrand r;
const double range = std::fabs( minEdge - maxEdge );
const double d1 = r.urand( );
c[i] = range * d1 + std::sqrt( minEdge * maxEdge );
const double d2 = r.urand( );
c[i + 3] = d2 * oneeightyDegrees;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: Volume()
// Description: Return the E3 volume of a LRL_Cell
// follows the formula of Stout and Jensen page 33
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
double LRL_Cell::Volume( void ) const
{
const G6& c( m_cell );
const double c3(cos(c[3]));
const double c4(cos(c[4]));
const double c5(cos(c[5]));
const double volume( c[0]*c[1]*c[2] * sqrt( 1.0-pow(c3,2)-pow(c4,2)-pow(c5,2)
+ 2.0*c3*c4*c5 ) );
return volume;
}
bool LRL_Cell::operator== (const LRL_Cell& cl) const {
return m_cell == cl.m_cell;
}
bool LRL_Cell::operator!= (const LRL_Cell& cl) const {
return !((*this) == cl);
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: operator[]()
// Description: access function for the values in a LRL_Cell object
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
double LRL_Cell::operator[](const size_t n) const
{
const size_t nn( std::max(size_t(0),std::min(size_t(5),n)) );
return m_cell[nn];
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: operator[]()
// Description: access function for the values in a LRL_Cell object
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
double& LRL_Cell::operator[](const size_t n)
{
const size_t nn( std::max(size_t(0),std::min(size_t(5),n)) );
return m_cell[nn];
}
double LRL_Cell::DistanceBetween(const LRL_Cell& v1, const LRL_Cell& v2) {
return (B4(v1) - B4(v2)).norm();
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: Inverse()
// Description: Compute the reciprocal cell (inverse) of a cell
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell LRL_Cell::Inverse( void ) const
{
const double& a((*this)[0]);
const double& b((*this)[1]);
const double& c((*this)[2]);
const double& alpha((*this)[3]);
const double& beta ((*this)[4]);
const double& gamma((*this)[5]);
const double cosAlpha(cos(alpha));
const double cosBeta (cos(beta));
const double cosGamma(cos(gamma));
const double sinAlpha(sin(alpha));
const double sinBeta (sin(beta));
const double sinGamma(sin(gamma));
const double v = (*this).Volume( );
const double astar = b*c*sin(alpha)/v;
const double bstar = a*c*sin(beta )/v;
const double cstar = a*b*sin(gamma)/v;
const double cosAlphaStar = (cosBeta *cosGamma-cosAlpha)/fabs(sinBeta*sinGamma);
const double cosBetaStar = (cosAlpha*cosGamma-cosBeta )/fabs(sinAlpha*sinGamma);
const double cosGammaStar = (cosAlpha*cosBeta -cosGamma)/fabs(sinAlpha*sinBeta);
LRL_Cell cell;
cell.m_cell[0] = astar;
cell.m_cell[1] = bstar;
cell.m_cell[2] = cstar;
cell.m_cell[3] = atan2( sqrt(1.0-pow(cosAlphaStar,2)), cosAlphaStar);
cell.m_cell[4] = atan2( sqrt(1.0-pow(cosBetaStar ,2)), cosBetaStar );
cell.m_cell[5] = atan2( sqrt(1.0-pow(cosGammaStar,2)), cosGammaStar);
cell.m_valid = m_valid;
return cell;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: LatSymMatG6(const std::string& latsym)
// Description: return the MatG6 matrix for a lattice symbol
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
MatG6 LRL_Cell::LatSymMatG6(const std::string& latsym) const
{
if (toupper(latsym[0]) == 'P') return MatG6::Eye();
else if (toupper(latsym[0]) == 'I') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 .25 .25 .25 .25 .25 .25 0 1 0 .5 0 .5 1 0 0 0 .5 .5 0 0 0 0 0 1"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'A') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 0 .25 .25 .25 0 0 0 1 0 .5 0 0 0 0 0 0 .5 .5 0 0 0 0 0 1"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'B') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 .25 0 .25 0 .25 0 0 0 0 .5 0 .5 1 0 0 0 .5 0 0 0 0 0 0 1"); // for monoclinic, assumes c unique
else if (toupper(latsym[0]) == 'C') return MatG6("1 0 0 0 0 0 .25 .25 0 0 0 .25 0 0 1 0 0 0 0 0 0 .5 .5 0 0 0 0 0 1 0 1 0 0 0 0 .5"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'F') return MatG6(".25 .25 0 0 0 .25 .25 0 .25 0 .25 0 0 .25 .25 .25 0 0 0 0 .5 .25 .25 .25 0 .5 0 .25 .25 .25 .5 0 0 .25 .25 .25");
else if ((toupper(latsym[0]) == 'R' || toupper(latsym[0]) == 'H')
&& LRL_Cell::IsRhomobhedralAsHex(*this))
return (1.0 / 9.0)* MatG6("1 1 1 1 -1 -1 4 1 1 1 2 2 1 4 1 -2 -1 2 -4 -4 2 -1 1 -5 2 -4 2 -1 -2 1 -4 2 2 2 1 1");
else if (toupper(latsym[0]) == 'R' || toupper(latsym[0]) == 'H') return MatG6::Eye();
else if (latsym == "CCDC") return (1.0 / 9.0)* MatG6("4 1 1 1 2 2 1 1 1 1 -1 -1 1 4 1 -2 -1 2 2 -4 2 -1 -2 1 -4 -4 2 -1 1 -5 -4 2 2 2 1 1"); // CCDC matrix for R
else return MatG6::Eye();
}
MatG6 LRL_Cell::G6MakePrimitiveMatrix(const std::string& latsym)
{
if (toupper(latsym[0]) == 'P') return MatG6::Eye();
else if (toupper(latsym[0]) == 'I') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 .25 .25 .25 .25 .25 .25 0 1 0 .5 0 .5 1 0 0 0 .5 .5 0 0 0 0 0 1"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'A') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 0 .25 .25 .25 0 0 0 1 0 .5 0 0 0 0 0 0 .5 .5 0 0 0 0 0 1"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'B') return MatG6("1 0 0 0 0 0 0 1 0 0 0 0 .25 0 .25 0 .25 0 0 0 0 .5 0 .5 1 0 0 0 .5 0 0 0 0 0 0 1"); // for monoclinic, assumes c unique
else if (toupper(latsym[0]) == 'C') return MatG6("1 0 0 0 0 0 .25 .25 0 0 0 .25 0 0 1 0 0 0 0 0 0 .5 .5 0 0 0 0 0 1 0 1 0 0 0 0 .5"); // for monoclinic, assumes b unique
else if (toupper(latsym[0]) == 'F') return MatG6(".25 .25 0 0 0 .25 .25 0 .25 0 .25 0 0 .25 .25 .25 0 0 0 0 .5 .25 .25 .25 0 .5 0 .25 .25 .25 .5 0 0 .25 .25 .25");
else if (toupper(latsym[0]) == 'R') return (1.0 / 9.0)* MatG6("1 1 1 1 -1 -1 4 1 1 1 2 2 1 4 1 -2 -1 2 -4 -4 2 -1 1 -5 2 -4 2 -1 -2 1 -4 2 2 2 1 1");
else if (toupper(latsym[0]) == 'H') return MatG6::Eye();
else return MatG6::Eye();
}
MatG6 LRL_Cell::LatSymMatG6( const std::string& latsym, const LRL_Cell& c ) {
return c.LatSymMatG6( latsym );
}
const MatG6 HexPerp(MatG6::Eye() - (1./3.)*MatG6( " 1 1 0 0 0 -1 1 1 0 0 0 -1 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 1" ) );
const MatG6 RhmPerp(MatG6::Eye() - (1./3.)*MatG6( " 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1" ) );
bool LRL_Cell::IsRhomobhedralAsHex( void ) const {
return IsRhomobhedralAsHex( G6(*this));
}
/*static*/ bool LRL_Cell::IsRhomobhedralAsHex( const LRL_Cell& c ) {
static const double degrees90 = 2.0*atan(1.0);
static const double degrees120 = 4.0 / 3.0 * degrees90;;
return (std::abs(c[3] - degrees90) < 1.0E-4 && std::abs(c[4] - degrees90) < 1.0E-4) &&
(std::abs(c[5] - degrees120) < 1.0E-4);
}
// Assumes the cell EITHER has alpha=beta=gamma or a=b & alpha=beta=90 and gamma=120 (approximately)
/*static*/ bool LRL_Cell::IsRhomobhedralAsHex(const G6& v) {
return (HexPerp*v).norm() < (RhmPerp*v).norm();
}
static int iseed;
LRL_Cell LRL_Cell::rand() {
return S6::rand();
}
LRL_Cell LRL_Cell::randDeloneReduced() {//LRL_Cell::randomLatticeNormalizationConstant
S6 vRan;
S6 v;
MatS6 m;
vRan = LRL_Cell::rand();
const bool test = Delone::Reduce(vRan, m, v, 0.0);
while (!Delone::IsReduced(vRan)) {
vRan = LRL_Cell::rand();
}
return LRL_Cell(v);
}
LRL_Cell LRL_Cell::randDeloneUnreduced() {//LRL_Cell::randomLatticeNormalizationConstant
S6 vRan;
MatS6 m;
vRan = LRL_Cell::rand();
while (Delone::IsReduced(vRan)) {
vRan = LRL_Cell::rand();
}
LRL_Cell celltemp(vRan);
return LRL_Cell(vRan);
}
LRL_Cell LRL_Cell::rand(const double d) {//LRL_Cell::randomLatticeNormalizationConstant
return d*rand()/ randomLatticeNormalizationConstant;
}
LRL_Cell LRL_Cell::randDeloneReduced(const double d) {//LRL_Cell::randomLatticeNormalizationConstant
return d*randDeloneReduced()/ randomLatticeNormalizationConstant;
}
LRL_Cell LRL_Cell::randDeloneUnreduced(const double d) {//LRL_Cell::randomLatticeNormalizationConstant
return d*randDeloneUnreduced()/ randomLatticeNormalizationConstant;
}
Matrix_3x3 LRL_Cell::Cart() const {
static const double degreesPerRad = 180.0 / 4.0 / atan(1.0);
return Matrix_3x3::Cart(m_cell[0], m_cell[1], m_cell[2],
degreesPerRad*m_cell[3], degreesPerRad*m_cell[4], degreesPerRad*m_cell[5]);
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// Name: vvtorow(const double m,
// const int n1, const int n2,
// mat33& v1, mat33& v2,
// const int n3,
// MatG6& m6)
// Description: Compute one row of a 6x6 matrix from
// 2 rows of 2 3x3 matrices
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LRL_Cell LRL_Cell::operator* (const double d) const {
LRL_Cell c(*this);
c[0] *= d;
c[1] *= d;
c[2] *= d;
return c;
}
LRL_Cell LRL_Cell::operator/ (const double d) const {
LRL_Cell c(*this);
c[0] /= d;
c[1] /= d;
c[2] /= d;
return c;
}
LRL_Cell LRL_Cell::operator+ (const LRL_Cell& c) const {
const G6 v1(*this);
const G6 v2(c);
return LRL_Cell(G6(v1 + v2));
}
LRL_Cell LRL_Cell::operator- (const LRL_Cell& c) const {
const G6 v1(*this);
const G6 v2(c);
const G6 diff = v1 - v2;
if (diff.norm() < 1.0E-10)
return LRL_Cell(0,0,0,0,0,0);
else
return LRL_Cell(G6(v1 - v2));
}
LRL_Cell& LRL_Cell::operator+= (const LRL_Cell& cl) {
(*this) = (*this) + cl;
return *this;
}
LRL_Cell& LRL_Cell::operator-= (const LRL_Cell& cl) {
*this = (*this) - cl;
return *this;
}
LRL_Cell operator* (const double d, const LRL_Cell& c) {
return c*d;
}
LRL_Cell& LRL_Cell::operator= (const D7& v) {
*this = LRL_Cell(v);
return *this;
}
LRL_Cell& LRL_Cell::operator= (const C3& c3) {
*this = LRL_Cell(c3);
return *this;
}
LRL_Cell& LRL_Cell::operator= (const S6& v) {
*this = LRL_Cell(v);
return *this;
}
LRL_Cell& LRL_Cell::operator= (const B4& v) {
*this = LRL_Cell(v);
return *this;
}
LRL_Cell& LRL_Cell::operator= (const LRL_Cell& v) {
m_cell = v.m_cell;
m_valid = v.GetValid();
return *this;
}
LRL_Cell& LRL_Cell::operator= (const G6& v) {
*this = LRL_Cell(v);
m_valid = m_valid && GetValid();
return *this;
}
LRL_Cell& LRL_Cell::operator= (const std::string& s) {
*this = LRL_Cell(s);
m_valid = true;
return *this;
}
LRL_Cell& LRL_Cell::operator/= (const double d) {
(*this)[0] /= d;
(*this)[1] /= d;
(*this)[2] /= d;
m_valid = true;
return *this;
}
LRL_Cell& LRL_Cell::operator*= (const double d) {
(*this)[0] *= d;
(*this)[1] *= d;
(*this)[2] *= d;
m_valid = true;
return *this;
}
LRL_Cell LRL_Cell::GetPrimitiveCell(const std::string& latsym, const LRL_Cell& c) {
return LRL_Cell(GetPrimitiveV6Vector(latsym, c));
}
G6 LRL_Cell::GetPrimitiveV6Vector(const std::string& latsym, const LRL_Cell& c) {
const MatG6 m66 = c.LatSymMatG6(latsym);
return m66 * G6(c);
}