ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/math/SquareMatrix3.hpp
Revision: 1753
Committed: Tue Jun 12 13:20:28 2012 UTC (12 years, 10 months ago) by gezelter
File size: 18652 byte(s)
Log Message:
Added a double dot tensor contraction.

File Contents

# User Rev Content
1 gezelter 507 /*
2 gezelter 246 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 tim 70 *
4 gezelter 246 * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9 gezelter 1390 * 1. Redistributions of source code must retain the above copyright
10 gezelter 246 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 gezelter 246 * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the
15     * distribution.
16     *
17     * This software is provided "AS IS," without a warranty of any
18     * kind. All express or implied conditions, representations and
19     * warranties, including any implied warranty of merchantability,
20     * fitness for a particular purpose or non-infringement, are hereby
21     * excluded. The University of Notre Dame and its licensors shall not
22     * be liable for any damages suffered by licensee as a result of
23     * using, modifying or distributing the software or its
24     * derivatives. In no event will the University of Notre Dame or its
25     * licensors be liable for any lost revenue, profit or data, or for
26     * direct, indirect, special, consequential, incidental or punitive
27     * damages, however caused and regardless of the theory of liability,
28     * arising out of the use of or inability to use software, even if the
29     * University of Notre Dame has been advised of the possibility of
30     * such damages.
31 gezelter 1390 *
32     * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33     * research, please cite the appropriate papers when you publish your
34     * work. Good starting points are:
35     *
36     * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37     * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38     * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).
39 gezelter 1665 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40     * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 tim 70 */
42 gezelter 246
43 tim 70 /**
44     * @file SquareMatrix3.hpp
45     * @author Teng Lin
46     * @date 10/11/2004
47     * @version 1.0
48     */
49 gezelter 507 #ifndef MATH_SQUAREMATRIX3_HPP
50 tim 99 #define MATH_SQUAREMATRIX3_HPP
51 tim 895 #include <vector>
52 tim 93 #include "Quaternion.hpp"
53 tim 70 #include "SquareMatrix.hpp"
54 tim 93 #include "Vector3.hpp"
55 tim 451 #include "utils/NumericConstant.hpp"
56 gezelter 1390 namespace OpenMD {
57 tim 70
58 gezelter 507 template<typename Real>
59     class SquareMatrix3 : public SquareMatrix<Real, 3> {
60     public:
61 tim 137
62 gezelter 507 typedef Real ElemType;
63     typedef Real* ElemPoinerType;
64 tim 70
65 gezelter 507 /** default constructor */
66     SquareMatrix3() : SquareMatrix<Real, 3>() {
67     }
68 tim 70
69 gezelter 507 /** Constructs and initializes every element of this matrix to a scalar */
70     SquareMatrix3(Real s) : SquareMatrix<Real,3>(s){
71     }
72 tim 151
73 gezelter 507 /** Constructs and initializes from an array */
74     SquareMatrix3(Real* array) : SquareMatrix<Real,3>(array){
75     }
76 tim 151
77    
78 gezelter 507 /** copy constructor */
79     SquareMatrix3(const SquareMatrix<Real, 3>& m) : SquareMatrix<Real, 3>(m) {
80     }
81 gezelter 246
82 gezelter 507 SquareMatrix3( const Vector3<Real>& eulerAngles) {
83     setupRotMat(eulerAngles);
84     }
85 tim 93
86 gezelter 507 SquareMatrix3(Real phi, Real theta, Real psi) {
87     setupRotMat(phi, theta, psi);
88     }
89 tim 93
90 gezelter 507 SquareMatrix3(const Quaternion<Real>& q) {
91     setupRotMat(q);
92 tim 113
93 gezelter 507 }
94 tim 93
95 gezelter 507 SquareMatrix3(Real w, Real x, Real y, Real z) {
96     setupRotMat(w, x, y, z);
97     }
98 tim 93
99 gezelter 507 /** copy assignment operator */
100     SquareMatrix3<Real>& operator =(const SquareMatrix<Real, 3>& m) {
101     if (this == &m)
102     return *this;
103     SquareMatrix<Real, 3>::operator=(m);
104     return *this;
105     }
106 tim 76
107 gezelter 246
108 gezelter 507 SquareMatrix3<Real>& operator =(const Quaternion<Real>& q) {
109     this->setupRotMat(q);
110     return *this;
111     }
112 gezelter 246
113 gezelter 1753
114 gezelter 507 /**
115     * Sets this matrix to a rotation matrix by three euler angles
116     * @ param euler
117     */
118     void setupRotMat(const Vector3<Real>& eulerAngles) {
119     setupRotMat(eulerAngles[0], eulerAngles[1], eulerAngles[2]);
120     }
121 tim 76
122 gezelter 507 /**
123     * Sets this matrix to a rotation matrix by three euler angles
124     * @param phi
125     * @param theta
126     * @psi theta
127     */
128     void setupRotMat(Real phi, Real theta, Real psi) {
129     Real sphi, stheta, spsi;
130     Real cphi, ctheta, cpsi;
131 tim 76
132 gezelter 507 sphi = sin(phi);
133     stheta = sin(theta);
134     spsi = sin(psi);
135     cphi = cos(phi);
136     ctheta = cos(theta);
137     cpsi = cos(psi);
138 tim 76
139 gezelter 507 this->data_[0][0] = cpsi * cphi - ctheta * sphi * spsi;
140     this->data_[0][1] = cpsi * sphi + ctheta * cphi * spsi;
141     this->data_[0][2] = spsi * stheta;
142 tim 93
143 gezelter 507 this->data_[1][0] = -spsi * ctheta - ctheta * sphi * cpsi;
144     this->data_[1][1] = -spsi * stheta + ctheta * cphi * cpsi;
145     this->data_[1][2] = cpsi * stheta;
146 tim 93
147 gezelter 507 this->data_[2][0] = stheta * sphi;
148     this->data_[2][1] = -stheta * cphi;
149     this->data_[2][2] = ctheta;
150     }
151 tim 93
152    
153 gezelter 507 /**
154     * Sets this matrix to a rotation matrix by quaternion
155     * @param quat
156     */
157     void setupRotMat(const Quaternion<Real>& quat) {
158     setupRotMat(quat.w(), quat.x(), quat.y(), quat.z());
159     }
160 tim 76
161 gezelter 507 /**
162     * Sets this matrix to a rotation matrix by quaternion
163     * @param w the first element
164     * @param x the second element
165     * @param y the third element
166     * @param z the fourth element
167     */
168     void setupRotMat(Real w, Real x, Real y, Real z) {
169     Quaternion<Real> q(w, x, y, z);
170     *this = q.toRotationMatrix3();
171     }
172 tim 76
173 tim 891 void setupSkewMat(Vector3<Real> v) {
174     setupSkewMat(v[0], v[1], v[2]);
175     }
176    
177     void setupSkewMat(Real v1, Real v2, Real v3) {
178     this->data_[0][0] = 0;
179     this->data_[0][1] = -v3;
180     this->data_[0][2] = v2;
181     this->data_[1][0] = v3;
182     this->data_[1][1] = 0;
183     this->data_[1][2] = -v1;
184     this->data_[2][0] = -v2;
185     this->data_[2][1] = v1;
186     this->data_[2][2] = 0;
187    
188    
189     }
190    
191    
192 gezelter 507 /**
193     * Returns the quaternion from this rotation matrix
194     * @return the quaternion from this rotation matrix
195     * @exception invalid rotation matrix
196     */
197     Quaternion<Real> toQuaternion() {
198     Quaternion<Real> q;
199     Real t, s;
200     Real ad1, ad2, ad3;
201     t = this->data_[0][0] + this->data_[1][1] + this->data_[2][2] + 1.0;
202 tim 76
203 tim 637 if( t > NumericConstant::epsilon ){
204 tim 93
205 gezelter 507 s = 0.5 / sqrt( t );
206     q[0] = 0.25 / s;
207     q[1] = (this->data_[1][2] - this->data_[2][1]) * s;
208     q[2] = (this->data_[2][0] - this->data_[0][2]) * s;
209     q[3] = (this->data_[0][1] - this->data_[1][0]) * s;
210     } else {
211 tim 93
212 tim 633 ad1 = this->data_[0][0];
213     ad2 = this->data_[1][1];
214     ad3 = this->data_[2][2];
215 tim 93
216 gezelter 507 if( ad1 >= ad2 && ad1 >= ad3 ){
217 tim 93
218 gezelter 507 s = 0.5 / sqrt( 1.0 + this->data_[0][0] - this->data_[1][1] - this->data_[2][2] );
219     q[0] = (this->data_[1][2] - this->data_[2][1]) * s;
220     q[1] = 0.25 / s;
221     q[2] = (this->data_[0][1] + this->data_[1][0]) * s;
222     q[3] = (this->data_[0][2] + this->data_[2][0]) * s;
223     } else if ( ad2 >= ad1 && ad2 >= ad3 ) {
224     s = 0.5 / sqrt( 1.0 + this->data_[1][1] - this->data_[0][0] - this->data_[2][2] );
225     q[0] = (this->data_[2][0] - this->data_[0][2] ) * s;
226     q[1] = (this->data_[0][1] + this->data_[1][0]) * s;
227     q[2] = 0.25 / s;
228     q[3] = (this->data_[1][2] + this->data_[2][1]) * s;
229     } else {
230 tim 93
231 gezelter 507 s = 0.5 / sqrt( 1.0 + this->data_[2][2] - this->data_[0][0] - this->data_[1][1] );
232     q[0] = (this->data_[0][1] - this->data_[1][0]) * s;
233     q[1] = (this->data_[0][2] + this->data_[2][0]) * s;
234     q[2] = (this->data_[1][2] + this->data_[2][1]) * s;
235     q[3] = 0.25 / s;
236     }
237     }
238 tim 93
239 gezelter 507 return q;
240 tim 93
241 gezelter 507 }
242 tim 93
243 gezelter 507 /**
244     * Returns the euler angles from this rotation matrix
245     * @return the euler angles in a vector
246     * @exception invalid rotation matrix
247     * We use so-called "x-convention", which is the most common definition.
248 cli2 1360 * In this convention, the rotation given by Euler angles (phi, theta,
249     * psi), where the first rotation is by an angle phi about the z-axis,
250     * the second is by an angle theta (0 <= theta <= 180) about the x-axis,
251     * and the third is by an angle psi about the z-axis (again).
252 gezelter 507 */
253     Vector3<Real> toEulerAngles() {
254     Vector3<Real> myEuler;
255     Real phi;
256     Real theta;
257     Real psi;
258     Real ctheta;
259     Real stheta;
260 tim 93
261 gezelter 507 // set the tolerance for Euler angles and rotation elements
262 tim 93
263 tim 963 theta = acos(std::min((RealType)1.0, std::max((RealType)-1.0,this->data_[2][2])));
264 gezelter 507 ctheta = this->data_[2][2];
265     stheta = sqrt(1.0 - ctheta * ctheta);
266 tim 93
267 cli2 1360 // when sin(theta) is close to 0, we need to consider
268     // singularity In this case, we can assign an arbitary value to
269     // phi (or psi), and then determine the psi (or phi) or
270     // vice-versa. We'll assume that phi always gets the rotation,
271     // and psi is 0 in cases of singularity.
272 gezelter 507 // we use atan2 instead of atan, since atan2 will give us -Pi to Pi.
273 cli2 1360 // Since 0 <= theta <= 180, sin(theta) will be always
274     // non-negative. Therefore, it will never change the sign of both of
275     // the parameters passed to atan2.
276 tim 93
277 cli2 1360 if (fabs(stheta) < 1e-6){
278 gezelter 507 psi = 0.0;
279     phi = atan2(-this->data_[1][0], this->data_[0][0]);
280     }
281     // we only have one unique solution
282     else{
283     phi = atan2(this->data_[2][0], -this->data_[2][1]);
284     psi = atan2(this->data_[0][2], this->data_[1][2]);
285     }
286 tim 93
287 gezelter 507 //wrap phi and psi, make sure they are in the range from 0 to 2*Pi
288     if (phi < 0)
289 cli2 1360 phi += 2.0 * M_PI;
290 tim 93
291 gezelter 507 if (psi < 0)
292 cli2 1360 psi += 2.0 * M_PI;
293 tim 93
294 gezelter 507 myEuler[0] = phi;
295     myEuler[1] = theta;
296     myEuler[2] = psi;
297 tim 93
298 gezelter 507 return myEuler;
299     }
300 tim 70
301 gezelter 507 /** Returns the determinant of this matrix. */
302     Real determinant() const {
303     Real x,y,z;
304 tim 101
305 gezelter 507 x = this->data_[0][0] * (this->data_[1][1] * this->data_[2][2] - this->data_[1][2] * this->data_[2][1]);
306     y = this->data_[0][1] * (this->data_[1][2] * this->data_[2][0] - this->data_[1][0] * this->data_[2][2]);
307     z = this->data_[0][2] * (this->data_[1][0] * this->data_[2][1] - this->data_[1][1] * this->data_[2][0]);
308 tim 101
309 gezelter 507 return(x + y + z);
310     }
311 gezelter 246
312 gezelter 507 /** Returns the trace of this matrix. */
313     Real trace() const {
314     return this->data_[0][0] + this->data_[1][1] + this->data_[2][2];
315     }
316 tim 101
317 gezelter 507 /**
318     * Sets the value of this matrix to the inversion of itself.
319     * @note since simple algorithm can be applied to inverse the 3 by 3 matrix, we hide the
320     * implementation of inverse in SquareMatrix class
321     */
322     SquareMatrix3<Real> inverse() const {
323     SquareMatrix3<Real> m;
324 tim 963 RealType det = determinant();
325 gezelter 1390 if (fabs(det) <= OpenMD::epsilon) {
326 gezelter 507 //"The method was called on a matrix with |determinant| <= 1e-6.",
327     //"This is a runtime or a programming error in your application.");
328 tim 895 std::vector<int> zeroDiagElementIndex;
329     for (int i =0; i < 3; ++i) {
330 gezelter 1390 if (fabs(this->data_[i][i]) <= OpenMD::epsilon) {
331 tim 895 zeroDiagElementIndex.push_back(i);
332     }
333     }
334 tim 70
335 tim 895 if (zeroDiagElementIndex.size() == 2) {
336     int index = zeroDiagElementIndex[0];
337     m(index, index) = 1.0 / this->data_[index][index];
338     }else if (zeroDiagElementIndex.size() == 1) {
339 tim 101
340 tim 895 int a = (zeroDiagElementIndex[0] + 1) % 3;
341     int b = (zeroDiagElementIndex[0] + 2) %3;
342 tim 963 RealType denom = this->data_[a][a] * this->data_[b][b] - this->data_[b][a]*this->data_[a][b];
343 tim 895 m(a, a) = this->data_[b][b] /denom;
344     m(b, a) = -this->data_[b][a]/denom;
345    
346     m(a,b) = -this->data_[a][b]/denom;
347     m(b, b) = this->data_[a][a]/denom;
348    
349     }
350    
351     /*
352     for(std::vector<int>::iterator iter = zeroDiagElementIndex.begin(); iter != zeroDiagElementIndex.end() ++iter) {
353 gezelter 1390 if (this->data_[*iter][0] > OpenMD::epsilon || this->data_[*iter][1] ||this->data_[*iter][2] ||
354     this->data_[0][*iter] > OpenMD::epsilon || this->data_[1][*iter] ||this->data_[2][*iter] ) {
355 tim 895 std::cout << "can not inverse matrix" << std::endl;
356     }
357     }
358     */
359     } else {
360    
361     m(0, 0) = this->data_[1][1]*this->data_[2][2] - this->data_[1][2]*this->data_[2][1];
362     m(1, 0) = this->data_[1][2]*this->data_[2][0] - this->data_[1][0]*this->data_[2][2];
363     m(2, 0) = this->data_[1][0]*this->data_[2][1] - this->data_[1][1]*this->data_[2][0];
364     m(0, 1) = this->data_[2][1]*this->data_[0][2] - this->data_[2][2]*this->data_[0][1];
365     m(1, 1) = this->data_[2][2]*this->data_[0][0] - this->data_[2][0]*this->data_[0][2];
366     m(2, 1) = this->data_[2][0]*this->data_[0][1] - this->data_[2][1]*this->data_[0][0];
367     m(0, 2) = this->data_[0][1]*this->data_[1][2] - this->data_[0][2]*this->data_[1][1];
368     m(1, 2) = this->data_[0][2]*this->data_[1][0] - this->data_[0][0]*this->data_[1][2];
369     m(2, 2) = this->data_[0][0]*this->data_[1][1] - this->data_[0][1]*this->data_[1][0];
370    
371     m /= det;
372     }
373 gezelter 507 return m;
374     }
375 tim 883
376     SquareMatrix3<Real> transpose() const{
377     SquareMatrix3<Real> result;
378    
379     for (unsigned int i = 0; i < 3; i++)
380     for (unsigned int j = 0; j < 3; j++)
381     result(j, i) = this->data_[i][j];
382    
383     return result;
384     }
385 gezelter 507 /**
386     * Extract the eigenvalues and eigenvectors from a 3x3 matrix.
387     * The eigenvectors (the columns of V) will be normalized.
388     * The eigenvectors are aligned optimally with the x, y, and z
389     * axes respectively.
390     * @param a symmetric matrix whose eigenvectors are to be computed. On return, the matrix is
391     * overwritten
392     * @param w will contain the eigenvalues of the matrix On return of this function
393     * @param v the columns of this matrix will contain the eigenvectors. The eigenvectors are
394     * normalized and mutually orthogonal.
395     * @warning a will be overwritten
396     */
397     static void diagonalize(SquareMatrix3<Real>& a, Vector3<Real>& w, SquareMatrix3<Real>& v);
398     };
399     /*=========================================================================
400 tim 76
401 tim 123 Program: Visualization Toolkit
402     Module: $RCSfile: SquareMatrix3.hpp,v $
403 tim 99
404 tim 123 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
405     All rights reserved.
406     See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
407 tim 101
408 gezelter 507 This software is distributed WITHOUT ANY WARRANTY; without even
409     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
410     PURPOSE. See the above copyright notice for more information.
411 tim 101
412 gezelter 507 =========================================================================*/
413     template<typename Real>
414     void SquareMatrix3<Real>::diagonalize(SquareMatrix3<Real>& a, Vector3<Real>& w,
415     SquareMatrix3<Real>& v) {
416     int i,j,k,maxI;
417     Real tmp, maxVal;
418     Vector3<Real> v_maxI, v_k, v_j;
419 tim 101
420 gezelter 507 // diagonalize using Jacobi
421 gezelter 1600 SquareMatrix3<Real>::jacobi(a, w, v);
422 gezelter 507 // if all the eigenvalues are the same, return identity matrix
423     if (w[0] == w[1] && w[0] == w[2] ) {
424     v = SquareMatrix3<Real>::identity();
425     return;
426     }
427 tim 101
428 gezelter 507 // transpose temporarily, it makes it easier to sort the eigenvectors
429     v = v.transpose();
430 tim 123
431 gezelter 507 // if two eigenvalues are the same, re-orthogonalize to optimally line
432     // up the eigenvectors with the x, y, and z axes
433     for (i = 0; i < 3; i++) {
434     if (w((i+1)%3) == w((i+2)%3)) {// two eigenvalues are the same
435     // find maximum element of the independant eigenvector
436     maxVal = fabs(v(i, 0));
437     maxI = 0;
438     for (j = 1; j < 3; j++) {
439     if (maxVal < (tmp = fabs(v(i, j)))){
440     maxVal = tmp;
441     maxI = j;
442     }
443     }
444 tim 123
445 gezelter 507 // swap the eigenvector into its proper position
446     if (maxI != i) {
447     tmp = w(maxI);
448     w(maxI) = w(i);
449     w(i) = tmp;
450 tim 101
451 gezelter 507 v.swapRow(i, maxI);
452     }
453     // maximum element of eigenvector should be positive
454     if (v(maxI, maxI) < 0) {
455     v(maxI, 0) = -v(maxI, 0);
456     v(maxI, 1) = -v(maxI, 1);
457     v(maxI, 2) = -v(maxI, 2);
458     }
459 tim 101
460 gezelter 507 // re-orthogonalize the other two eigenvectors
461     j = (maxI+1)%3;
462     k = (maxI+2)%3;
463 tim 101
464 gezelter 507 v(j, 0) = 0.0;
465     v(j, 1) = 0.0;
466     v(j, 2) = 0.0;
467     v(j, j) = 1.0;
468 tim 101
469 gezelter 507 /** @todo */
470     v_maxI = v.getRow(maxI);
471     v_j = v.getRow(j);
472     v_k = cross(v_maxI, v_j);
473     v_k.normalize();
474     v_j = cross(v_k, v_maxI);
475     v.setRow(j, v_j);
476     v.setRow(k, v_k);
477 tim 101
478    
479 gezelter 507 // transpose vectors back to columns
480     v = v.transpose();
481     return;
482     }
483     }
484 tim 101
485 gezelter 507 // the three eigenvalues are different, just sort the eigenvectors
486     // to align them with the x, y, and z axes
487 tim 101
488 gezelter 507 // find the vector with the largest x element, make that vector
489     // the first vector
490     maxVal = fabs(v(0, 0));
491     maxI = 0;
492     for (i = 1; i < 3; i++) {
493     if (maxVal < (tmp = fabs(v(i, 0)))) {
494     maxVal = tmp;
495     maxI = i;
496     }
497     }
498 tim 101
499 gezelter 507 // swap eigenvalue and eigenvector
500     if (maxI != 0) {
501     tmp = w(maxI);
502     w(maxI) = w(0);
503     w(0) = tmp;
504     v.swapRow(maxI, 0);
505     }
506     // do the same for the y element
507     if (fabs(v(1, 1)) < fabs(v(2, 1))) {
508     tmp = w(2);
509     w(2) = w(1);
510     w(1) = tmp;
511     v.swapRow(2, 1);
512     }
513 tim 101
514 gezelter 507 // ensure that the sign of the eigenvectors is correct
515     for (i = 0; i < 2; i++) {
516     if (v(i, i) < 0) {
517     v(i, 0) = -v(i, 0);
518     v(i, 1) = -v(i, 1);
519     v(i, 2) = -v(i, 2);
520     }
521     }
522 tim 70
523 gezelter 507 // set sign of final eigenvector to ensure that determinant is positive
524     if (v.determinant() < 0) {
525     v(2, 0) = -v(2, 0);
526     v(2, 1) = -v(2, 1);
527     v(2, 2) = -v(2, 2);
528 tim 123 }
529 gezelter 246
530 gezelter 507 // transpose the eigenvectors back again
531     v = v.transpose();
532     return ;
533     }
534 gezelter 246
535 gezelter 507 /**
536     * Return the multiplication of two matrixes (m1 * m2).
537     * @return the multiplication of two matrixes
538     * @param m1 the first matrix
539     * @param m2 the second matrix
540     */
541     template<typename Real>
542     inline SquareMatrix3<Real> operator *(const SquareMatrix3<Real>& m1, const SquareMatrix3<Real>& m2) {
543     SquareMatrix3<Real> result;
544 gezelter 246
545 gezelter 507 for (unsigned int i = 0; i < 3; i++)
546     for (unsigned int j = 0; j < 3; j++)
547     for (unsigned int k = 0; k < 3; k++)
548     result(i, j) += m1(i, k) * m2(k, j);
549 gezelter 246
550 gezelter 507 return result;
551     }
552 gezelter 246
553 gezelter 507 template<typename Real>
554     inline SquareMatrix3<Real> outProduct(const Vector3<Real>& v1, const Vector3<Real>& v2) {
555     SquareMatrix3<Real> result;
556    
557     for (unsigned int i = 0; i < 3; i++) {
558     for (unsigned int j = 0; j < 3; j++) {
559     result(i, j) = v1[i] * v2[j];
560     }
561     }
562 gezelter 246
563 gezelter 507 return result;
564     }
565 gezelter 246
566    
567 tim 963 typedef SquareMatrix3<RealType> Mat3x3d;
568     typedef SquareMatrix3<RealType> RotMat3x3d;
569 tim 93
570 gezelter 1390 } //namespace OpenMD
571 tim 93 #endif // MATH_SQUAREMATRIX_HPP
572 tim 123

Properties

Name Value
svn:keywords Author Id Revision Date