--- branches/development/src/math/RectMatrix.hpp 2012/10/22 20:42:10 1808 +++ branches/development/src/math/RectMatrix.hpp 2013/02/20 15:39:39 1850 @@ -35,7 +35,7 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ @@ -568,16 +568,18 @@ namespace OpenMD { * V_alpha = \sum_\beta \left[ A_{\alpha+1,\beta} * B_{\alpha+2,\beta} -A_{\alpha+2,\beta} * B_{\alpha+2,\beta} \right] * \f] - * where \f[\alpha+1\f] and \f[\alpha+2\f] are regarded as cyclic permuations of the - * matrix indices (i.e. for a 3x3 matrix, when \f[\alpha = 2\f], \f[\alpha + 1 = 3 \f], - * and \f[\alpha + 2 = 1 \f] ). + + * where \f[\alpha+1\f] and \f[\alpha+2\f] are regarded as cyclic + * permuations of the matrix indices (i.e. for a 3x3 matrix, when + * \f[\alpha = 2\f], \f[\alpha + 1 = 3 \f], and \f[\alpha + 2 = 1 \f] ). * * @param t1 first matrix * @param t2 second matrix * @return the cross product (vector product) of t1 and t2 */ template - inline Vector cross( const RectMatrix& t1, const RectMatrix& t2 ) { + inline Vector cross( const RectMatrix& t1, + const RectMatrix& t2 ) { Vector result; unsigned int i1; unsigned int i2; @@ -585,12 +587,10 @@ namespace OpenMD { for (unsigned int i = 0; i < Row; i++) { i1 = (i+1)%Row; i2 = (i+2)%Row; - - for (unsigned int j =0; j < Col; j++) { - result[i] = t1(i1,j) * t2(i2,j) - t1(i2,j) * t2(i1,j); + for (unsigned int j = 0; j < Col; j++) { + result[i] += t1(i1,j) * t2(i2,j) - t1(i2,j) * t2(i1,j); } - } - + } return result; }