--- trunk/src/math/SquareMatrix.hpp 2009/11/25 20:02:06 1390 +++ trunk/src/math/SquareMatrix.hpp 2013/08/05 21:46:11 1924 @@ -35,8 +35,9 @@ * * [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). - * [4] Vardeman & Gezelter, in progress (2009). + * [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). */ /** @@ -56,8 +57,8 @@ namespace OpenMD { /** * @class SquareMatrix SquareMatrix.hpp "math/SquareMatrix.hpp" * @brief A square matrix class - * @template Real the element type - * @template Dim the dimension of the square matrix + * \tparam Real the element type + * \tparam Dim the dimension of the square matrix */ template class SquareMatrix : public RectMatrix { @@ -124,7 +125,7 @@ namespace OpenMD { Real det; return det; } - + /** Returns the trace of this matrix. */ Real trace() const { Real tmp = 0; @@ -162,6 +163,19 @@ namespace OpenMD { return false; return true; + } + + /** + * Returns a column vector that contains the elements from the + * diagonal of m in the order R(0) = m(0,0), R(1) = m(1,1), and so + * on. + */ + Vector diagonals() const { + Vector result; + for (unsigned int i = 0; i < Dim; i++) { + result(i) = this->data_[i][i]; + } + return result; } /** Tests if this matrix is the unit matrix. */ @@ -199,7 +213,7 @@ namespace OpenMD { * @return true if success, otherwise return false * @param a symmetric matrix whose eigenvectors are to be computed. On return, the matrix is * overwritten - * @param w will contain the eigenvalues of the matrix On return of this function + * @param d will contain the eigenvalues of the matrix On return of this function * @param v the columns of this matrix will contain the eigenvectors. The eigenvectors are * normalized and mutually orthogonal. */ @@ -338,6 +352,10 @@ namespace OpenMD { //// this is NEVER called if ( i >= VTK_MAX_ROTATIONS ) { std::cout << "vtkMath::Jacobi: Error extracting eigenfunctions" << std::endl; + if (n > 4) { + delete[] b; + delete[] z; + } return 0; }