1 |
< |
#include <cstdlib> |
2 |
< |
#include <cstring> |
3 |
< |
#include <cmath> |
1 |
> |
#include <stdlib.h> |
2 |
> |
#include <string.h> |
3 |
> |
#include <math.h> |
4 |
|
|
5 |
|
#include <iostream> |
6 |
|
using namespace std; |
26 |
|
SimInfo::SimInfo(){ |
27 |
|
excludes = NULL; |
28 |
|
n_constraints = 0; |
29 |
+ |
nZconstraints = 0; |
30 |
|
n_oriented = 0; |
31 |
|
n_dipoles = 0; |
32 |
|
ndf = 0; |
33 |
|
ndfRaw = 0; |
34 |
+ |
nZconstraints = 0; |
35 |
|
the_integrator = NULL; |
36 |
|
setTemp = 0; |
37 |
|
thermalTime = 0.0; |
38 |
+ |
currentTime = 0.0; |
39 |
|
rCut = 0.0; |
40 |
+ |
origRcut = -1.0; |
41 |
+ |
ecr = 0.0; |
42 |
+ |
origEcr = -1.0; |
43 |
+ |
est = 0.0; |
44 |
+ |
oldEcr = 0.0; |
45 |
+ |
oldRcut = 0.0; |
46 |
|
|
47 |
+ |
haveOrigRcut = 0; |
48 |
+ |
haveOrigEcr = 0; |
49 |
+ |
boxIsInit = 0; |
50 |
+ |
|
51 |
+ |
resetTime = 1e99; |
52 |
+ |
|
53 |
+ |
|
54 |
|
usePBC = 0; |
55 |
|
useLJ = 0; |
56 |
|
useSticky = 0; |
59 |
|
useGB = 0; |
60 |
|
useEAM = 0; |
61 |
|
|
62 |
+ |
myConfiguration = new SimState(); |
63 |
+ |
|
64 |
|
wrapMeSimInfo( this ); |
65 |
|
} |
66 |
|
|
67 |
+ |
|
68 |
+ |
SimInfo::~SimInfo(){ |
69 |
+ |
|
70 |
+ |
delete myConfiguration; |
71 |
+ |
|
72 |
+ |
map<string, GenericData*>::iterator i; |
73 |
+ |
|
74 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
75 |
+ |
delete (*i).second; |
76 |
+ |
|
77 |
+ |
} |
78 |
+ |
|
79 |
|
void SimInfo::setBox(double newBox[3]) { |
80 |
|
|
81 |
|
int i, j; |
94 |
|
|
95 |
|
void SimInfo::setBoxM( double theBox[3][3] ){ |
96 |
|
|
97 |
< |
int i, j, status; |
68 |
< |
double smallestBoxL, maxCutoff; |
97 |
> |
int i, j; |
98 |
|
double FortranHmat[9]; // to preserve compatibility with Fortran the |
99 |
|
// ordering in the array is as follows: |
100 |
|
// [ 0 3 6 ] |
102 |
|
// [ 2 5 8 ] |
103 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
104 |
|
|
105 |
+ |
|
106 |
+ |
if( !boxIsInit ) boxIsInit = 1; |
107 |
|
|
108 |
|
for(i=0; i < 3; i++) |
109 |
|
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
110 |
|
|
80 |
– |
cerr |
81 |
– |
<< "setting Hmat ->\n" |
82 |
– |
<< "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n" |
83 |
– |
<< "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n" |
84 |
– |
<< "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n"; |
85 |
– |
|
111 |
|
calcBoxL(); |
112 |
|
calcHmatInv(); |
113 |
|
|
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
< |
setFortranBoxSize(FortranHmat, FortranHmatI, &orthoRhombic); |
121 |
> |
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
122 |
|
|
98 |
– |
smallestBoxL = boxLx; |
99 |
– |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
100 |
– |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
101 |
– |
|
102 |
– |
maxCutoff = smallestBoxL / 2.0; |
103 |
– |
|
104 |
– |
if (rList > maxCutoff) { |
105 |
– |
sprintf( painCave.errMsg, |
106 |
– |
"New Box size is forcing neighborlist radius down to %lf\n", |
107 |
– |
maxCutoff ); |
108 |
– |
painCave.isFatal = 0; |
109 |
– |
simError(); |
110 |
– |
|
111 |
– |
rList = maxCutoff; |
112 |
– |
|
113 |
– |
sprintf( painCave.errMsg, |
114 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
115 |
– |
maxCutoff - 1.0 ); |
116 |
– |
painCave.isFatal = 0; |
117 |
– |
simError(); |
118 |
– |
|
119 |
– |
rCut = rList - 1.0; |
120 |
– |
|
121 |
– |
// list radius changed so we have to refresh the simulation structure. |
122 |
– |
refreshSim(); |
123 |
– |
} |
124 |
– |
|
125 |
– |
if (rCut > maxCutoff) { |
126 |
– |
sprintf( painCave.errMsg, |
127 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
128 |
– |
maxCutoff ); |
129 |
– |
painCave.isFatal = 0; |
130 |
– |
simError(); |
131 |
– |
|
132 |
– |
status = 0; |
133 |
– |
LJ_new_rcut(&rCut, &status); |
134 |
– |
if (status != 0) { |
135 |
– |
sprintf( painCave.errMsg, |
136 |
– |
"Error in recomputing LJ shifts based on new rcut\n"); |
137 |
– |
painCave.isFatal = 1; |
138 |
– |
simError(); |
139 |
– |
} |
140 |
– |
} |
123 |
|
} |
124 |
|
|
125 |
|
|
135 |
|
double theBox[3][3]; |
136 |
|
int i, j; |
137 |
|
|
138 |
< |
cerr << "Scaling box by " << scale << "\n"; |
138 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
139 |
|
|
140 |
|
for(i=0; i<3; i++) |
141 |
|
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
145 |
|
} |
146 |
|
|
147 |
|
void SimInfo::calcHmatInv( void ) { |
148 |
< |
|
148 |
> |
|
149 |
> |
int i,j; |
150 |
|
double smallDiag; |
151 |
|
double tol; |
152 |
|
double sanity[3][3]; |
156 |
|
// Check the inverse to make sure it is sane: |
157 |
|
|
158 |
|
matMul3( Hmat, HmatInv, sanity ); |
176 |
– |
|
177 |
– |
cerr << "sanity => \n" |
178 |
– |
<< sanity[0][0] << "\t" << sanity[0][1] << "\t" << sanity [0][2] << "\n" |
179 |
– |
<< sanity[1][0] << "\t" << sanity[1][1] << "\t" << sanity [1][2] << "\n" |
180 |
– |
<< sanity[2][0] << "\t" << sanity[2][1] << "\t" << sanity [2][2] |
181 |
– |
<< "\n"; |
159 |
|
|
160 |
|
// check to see if Hmat is orthorhombic |
161 |
|
|
248 |
|
outVec[1] = m[1][0]*a0 + m[1][1]*a1 + m[1][2]*a2; |
249 |
|
outVec[2] = m[2][0]*a0 + m[2][1]*a1 + m[2][2]*a2; |
250 |
|
} |
251 |
+ |
|
252 |
+ |
void SimInfo::transposeMat3(double in[3][3], double out[3][3]) { |
253 |
+ |
double temp[3][3]; |
254 |
+ |
int i, j; |
255 |
+ |
|
256 |
+ |
for (i = 0; i < 3; i++) { |
257 |
+ |
for (j = 0; j < 3; j++) { |
258 |
+ |
temp[j][i] = in[i][j]; |
259 |
+ |
} |
260 |
+ |
} |
261 |
+ |
for (i = 0; i < 3; i++) { |
262 |
+ |
for (j = 0; j < 3; j++) { |
263 |
+ |
out[i][j] = temp[i][j]; |
264 |
+ |
} |
265 |
+ |
} |
266 |
+ |
} |
267 |
|
|
268 |
+ |
void SimInfo::printMat3(double A[3][3] ){ |
269 |
+ |
|
270 |
+ |
std::cerr |
271 |
+ |
<< "[ " << A[0][0] << ", " << A[0][1] << ", " << A[0][2] << " ]\n" |
272 |
+ |
<< "[ " << A[1][0] << ", " << A[1][1] << ", " << A[1][2] << " ]\n" |
273 |
+ |
<< "[ " << A[2][0] << ", " << A[2][1] << ", " << A[2][2] << " ]\n"; |
274 |
+ |
} |
275 |
+ |
|
276 |
+ |
void SimInfo::printMat9(double A[9] ){ |
277 |
+ |
|
278 |
+ |
std::cerr |
279 |
+ |
<< "[ " << A[0] << ", " << A[1] << ", " << A[2] << " ]\n" |
280 |
+ |
<< "[ " << A[3] << ", " << A[4] << ", " << A[5] << " ]\n" |
281 |
+ |
<< "[ " << A[6] << ", " << A[7] << ", " << A[8] << " ]\n"; |
282 |
+ |
} |
283 |
+ |
|
284 |
+ |
|
285 |
+ |
void SimInfo::crossProduct3(double a[3],double b[3], double out[3]){ |
286 |
+ |
|
287 |
+ |
out[0] = a[1] * b[2] - a[2] * b[1]; |
288 |
+ |
out[1] = a[2] * b[0] - a[0] * b[2] ; |
289 |
+ |
out[2] = a[0] * b[1] - a[1] * b[0]; |
290 |
+ |
|
291 |
+ |
} |
292 |
+ |
|
293 |
+ |
double SimInfo::dotProduct3(double a[3], double b[3]){ |
294 |
+ |
return a[0]*b[0] + a[1]*b[1]+ a[2]*b[2]; |
295 |
+ |
} |
296 |
+ |
|
297 |
+ |
double SimInfo::length3(double a[3]){ |
298 |
+ |
return sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]); |
299 |
+ |
} |
300 |
+ |
|
301 |
|
void SimInfo::calcBoxL( void ){ |
302 |
|
|
303 |
|
double dx, dy, dz, dsq; |
278 |
– |
int i; |
304 |
|
|
305 |
|
// boxVol = Determinant of Hmat |
306 |
|
|
310 |
|
|
311 |
|
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
312 |
|
dsq = dx*dx + dy*dy + dz*dz; |
313 |
< |
boxLx = sqrt( dsq ); |
313 |
> |
boxL[0] = sqrt( dsq ); |
314 |
> |
//maxCutoff = 0.5 * boxL[0]; |
315 |
|
|
316 |
|
// boxLy |
317 |
|
|
318 |
|
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
319 |
|
dsq = dx*dx + dy*dy + dz*dz; |
320 |
< |
boxLy = sqrt( dsq ); |
320 |
> |
boxL[1] = sqrt( dsq ); |
321 |
> |
//if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
322 |
|
|
323 |
+ |
|
324 |
|
// boxLz |
325 |
|
|
326 |
|
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
327 |
|
dsq = dx*dx + dy*dy + dz*dz; |
328 |
< |
boxLz = sqrt( dsq ); |
328 |
> |
boxL[2] = sqrt( dsq ); |
329 |
> |
//if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
330 |
> |
|
331 |
> |
//calculate the max cutoff |
332 |
> |
maxCutoff = calcMaxCutOff(); |
333 |
|
|
334 |
+ |
checkCutOffs(); |
335 |
+ |
|
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
+ |
double SimInfo::calcMaxCutOff(){ |
340 |
+ |
|
341 |
+ |
double ri[3], rj[3], rk[3]; |
342 |
+ |
double rij[3], rjk[3], rki[3]; |
343 |
+ |
double minDist; |
344 |
+ |
|
345 |
+ |
ri[0] = Hmat[0][0]; |
346 |
+ |
ri[1] = Hmat[1][0]; |
347 |
+ |
ri[2] = Hmat[2][0]; |
348 |
+ |
|
349 |
+ |
rj[0] = Hmat[0][1]; |
350 |
+ |
rj[1] = Hmat[1][1]; |
351 |
+ |
rj[2] = Hmat[2][1]; |
352 |
+ |
|
353 |
+ |
rk[0] = Hmat[0][2]; |
354 |
+ |
rk[1] = Hmat[1][2]; |
355 |
+ |
rk[2] = Hmat[2][2]; |
356 |
+ |
|
357 |
+ |
crossProduct3(ri,rj, rij); |
358 |
+ |
distXY = dotProduct3(rk,rij) / length3(rij); |
359 |
+ |
|
360 |
+ |
crossProduct3(rj,rk, rjk); |
361 |
+ |
distYZ = dotProduct3(ri,rjk) / length3(rjk); |
362 |
+ |
|
363 |
+ |
crossProduct3(rk,ri, rki); |
364 |
+ |
distZX = dotProduct3(rj,rki) / length3(rki); |
365 |
+ |
|
366 |
+ |
minDist = min(min(distXY, distYZ), distZX); |
367 |
+ |
return minDist/2; |
368 |
+ |
|
369 |
+ |
} |
370 |
+ |
|
371 |
|
void SimInfo::wrapVector( double thePos[3] ){ |
372 |
|
|
373 |
< |
int i, j, k; |
373 |
> |
int i; |
374 |
|
double scaled[3]; |
375 |
|
|
376 |
|
if( !orthoRhombic ){ |
408 |
|
|
409 |
|
|
410 |
|
int SimInfo::getNDF(){ |
411 |
< |
int ndf_local, ndf; |
411 |
> |
int ndf_local; |
412 |
|
|
413 |
|
ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints; |
414 |
|
|
418 |
|
ndf = ndf_local; |
419 |
|
#endif |
420 |
|
|
421 |
< |
ndf = ndf - 3; |
421 |
> |
ndf = ndf - 3 - nZconstraints; |
422 |
|
|
423 |
|
return ndf; |
424 |
|
} |
425 |
|
|
426 |
|
int SimInfo::getNDFraw() { |
427 |
< |
int ndfRaw_local, ndfRaw; |
427 |
> |
int ndfRaw_local; |
428 |
|
|
429 |
|
// Raw degrees of freedom that we have to set |
430 |
|
ndfRaw_local = 3 * n_atoms + 3 * n_oriented; |
437 |
|
|
438 |
|
return ndfRaw; |
439 |
|
} |
440 |
< |
|
440 |
> |
|
441 |
> |
int SimInfo::getNDFtranslational() { |
442 |
> |
int ndfTrans_local; |
443 |
> |
|
444 |
> |
ndfTrans_local = 3 * n_atoms - n_constraints; |
445 |
> |
|
446 |
> |
#ifdef IS_MPI |
447 |
> |
MPI_Allreduce(&ndfTrans_local,&ndfTrans,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
448 |
> |
#else |
449 |
> |
ndfTrans = ndfTrans_local; |
450 |
> |
#endif |
451 |
> |
|
452 |
> |
ndfTrans = ndfTrans - 3 - nZconstraints; |
453 |
> |
|
454 |
> |
return ndfTrans; |
455 |
> |
} |
456 |
> |
|
457 |
|
void SimInfo::refreshSim(){ |
458 |
|
|
459 |
|
simtype fInfo; |
460 |
|
int isError; |
461 |
|
int n_global; |
462 |
|
int* excl; |
463 |
< |
|
382 |
< |
fInfo.rrf = 0.0; |
383 |
< |
fInfo.rt = 0.0; |
463 |
> |
|
464 |
|
fInfo.dielect = 0.0; |
465 |
|
|
386 |
– |
fInfo.rlist = rList; |
387 |
– |
fInfo.rcut = rCut; |
388 |
– |
|
466 |
|
if( useDipole ){ |
390 |
– |
fInfo.rrf = ecr; |
391 |
– |
fInfo.rt = ecr - est; |
467 |
|
if( useReactionField )fInfo.dielect = dielectric; |
468 |
|
} |
469 |
|
|
509 |
|
|
510 |
|
this->ndf = this->getNDF(); |
511 |
|
this->ndfRaw = this->getNDFraw(); |
512 |
+ |
this->ndfTrans = this->getNDFtranslational(); |
513 |
+ |
} |
514 |
|
|
515 |
+ |
|
516 |
+ |
void SimInfo::setRcut( double theRcut ){ |
517 |
+ |
|
518 |
+ |
if( !haveOrigRcut ){ |
519 |
+ |
haveOrigRcut = 1; |
520 |
+ |
origRcut = theRcut; |
521 |
+ |
} |
522 |
+ |
|
523 |
+ |
rCut = theRcut; |
524 |
+ |
checkCutOffs(); |
525 |
|
} |
526 |
|
|
527 |
+ |
void SimInfo::setEcr( double theEcr ){ |
528 |
+ |
|
529 |
+ |
if( !haveOrigEcr ){ |
530 |
+ |
haveOrigEcr = 1; |
531 |
+ |
origEcr = theEcr; |
532 |
+ |
} |
533 |
+ |
|
534 |
+ |
ecr = theEcr; |
535 |
+ |
checkCutOffs(); |
536 |
+ |
} |
537 |
+ |
|
538 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
539 |
+ |
|
540 |
+ |
est = theEst; |
541 |
+ |
setEcr( theEcr ); |
542 |
+ |
} |
543 |
+ |
|
544 |
+ |
|
545 |
+ |
void SimInfo::checkCutOffs( void ){ |
546 |
+ |
|
547 |
+ |
int cutChanged = 0; |
548 |
+ |
|
549 |
+ |
if( boxIsInit ){ |
550 |
+ |
|
551 |
+ |
//we need to check cutOffs against the box |
552 |
+ |
|
553 |
+ |
//detect the change of rCut |
554 |
+ |
if(( maxCutoff > rCut )&&(usePBC)){ |
555 |
+ |
if( rCut < origRcut ){ |
556 |
+ |
rCut = origRcut; |
557 |
+ |
|
558 |
+ |
if (rCut > maxCutoff) |
559 |
+ |
rCut = maxCutoff; |
560 |
+ |
|
561 |
+ |
sprintf( painCave.errMsg, |
562 |
+ |
"New Box size is setting the long range cutoff radius " |
563 |
+ |
"to %lf at time %lf\n", |
564 |
+ |
rCut, currentTime ); |
565 |
+ |
painCave.isFatal = 0; |
566 |
+ |
simError(); |
567 |
+ |
} |
568 |
+ |
} |
569 |
+ |
else if ((rCut > maxCutoff)&&(usePBC)) { |
570 |
+ |
sprintf( painCave.errMsg, |
571 |
+ |
"New Box size is setting the long range cutoff radius " |
572 |
+ |
"to %lf at time %lf\n", |
573 |
+ |
maxCutoff, currentTime ); |
574 |
+ |
painCave.isFatal = 0; |
575 |
+ |
simError(); |
576 |
+ |
rCut = maxCutoff; |
577 |
+ |
} |
578 |
+ |
|
579 |
+ |
|
580 |
+ |
//detect the change of ecr |
581 |
+ |
if( maxCutoff > ecr ){ |
582 |
+ |
if( ecr < origEcr ){ |
583 |
+ |
ecr = origEcr; |
584 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
585 |
+ |
|
586 |
+ |
sprintf( painCave.errMsg, |
587 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
588 |
+ |
"to %lf at time %lf\n", |
589 |
+ |
ecr, currentTime ); |
590 |
+ |
painCave.isFatal = 0; |
591 |
+ |
simError(); |
592 |
+ |
} |
593 |
+ |
} |
594 |
+ |
else if( ecr > maxCutoff){ |
595 |
+ |
sprintf( painCave.errMsg, |
596 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
597 |
+ |
"to %lf at time %lf\n", |
598 |
+ |
maxCutoff, currentTime ); |
599 |
+ |
painCave.isFatal = 0; |
600 |
+ |
simError(); |
601 |
+ |
ecr = maxCutoff; |
602 |
+ |
} |
603 |
+ |
|
604 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
605 |
+ |
|
606 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
607 |
+ |
|
608 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
609 |
+ |
|
610 |
+ |
if( cutChanged ){ |
611 |
+ |
|
612 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
613 |
+ |
} |
614 |
+ |
|
615 |
+ |
oldEcr = ecr; |
616 |
+ |
oldRcut = rCut; |
617 |
+ |
|
618 |
+ |
} else { |
619 |
+ |
// initialize this stuff before using it, OK? |
620 |
+ |
sprintf( painCave.errMsg, |
621 |
+ |
"Trying to check cutoffs without a box. Be smarter.\n" ); |
622 |
+ |
painCave.isFatal = 1; |
623 |
+ |
simError(); |
624 |
+ |
} |
625 |
+ |
|
626 |
+ |
} |
627 |
+ |
|
628 |
+ |
void SimInfo::addProperty(GenericData* prop){ |
629 |
+ |
|
630 |
+ |
map<string, GenericData*>::iterator result; |
631 |
+ |
result = properties.find(prop->getID()); |
632 |
+ |
|
633 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
634 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
635 |
+ |
|
636 |
+ |
if(result != properties.end()){ |
637 |
+ |
|
638 |
+ |
delete (*result).second; |
639 |
+ |
(*result).second = prop; |
640 |
+ |
|
641 |
+ |
} |
642 |
+ |
else{ |
643 |
+ |
|
644 |
+ |
properties[prop->getID()] = prop; |
645 |
+ |
|
646 |
+ |
} |
647 |
+ |
|
648 |
+ |
} |
649 |
+ |
|
650 |
+ |
GenericData* SimInfo::getProperty(const string& propName){ |
651 |
+ |
|
652 |
+ |
map<string, GenericData*>::iterator result; |
653 |
+ |
|
654 |
+ |
//string lowerCaseName = (); |
655 |
+ |
|
656 |
+ |
result = properties.find(propName); |
657 |
+ |
|
658 |
+ |
if(result != properties.end()) |
659 |
+ |
return (*result).second; |
660 |
+ |
else |
661 |
+ |
return NULL; |
662 |
+ |
} |
663 |
+ |
|
664 |
+ |
vector<GenericData*> SimInfo::getProperties(){ |
665 |
+ |
|
666 |
+ |
vector<GenericData*> result; |
667 |
+ |
map<string, GenericData*>::iterator i; |
668 |
+ |
|
669 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
670 |
+ |
result.push_back((*i).second); |
671 |
+ |
|
672 |
+ |
return result; |
673 |
+ |
} |
674 |
+ |
|
675 |
+ |
double SimInfo::matTrace3(double m[3][3]){ |
676 |
+ |
double trace; |
677 |
+ |
trace = m[0][0] + m[1][1] + m[2][2]; |
678 |
+ |
|
679 |
+ |
return trace; |
680 |
+ |
} |