newarp_TridiagEigen_bones.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. namespace newarp
  16. {
  17. //! Calculate the eigenvalues and eigenvectors of a symmetric tridiagonal matrix.
  18. //! This class is a wrapper of the Lapack functions `_steqr`.
  19. template<typename eT>
  20. class TridiagEigen
  21. {
  22. private:
  23. blas_int n;
  24. Col<eT> main_diag; // Main diagonal elements of the matrix
  25. Col<eT> sub_diag; // Sub-diagonal elements of the matrix
  26. Mat<eT> evecs; // To store eigenvectors
  27. bool computed;
  28. public:
  29. //! Default constructor. Computation can
  30. //! be performed later by calling the compute() method.
  31. inline TridiagEigen();
  32. //! Constructor to create an object that calculates the eigenvalues
  33. //! and eigenvectors of a symmetric tridiagonal matrix `mat_obj`.
  34. inline TridiagEigen(const Mat<eT>& mat_obj);
  35. //! Compute the eigenvalue decomposition of a symmetric tridiagonal matrix.
  36. inline void compute(const Mat<eT>& mat_obj);
  37. //! Retrieve the eigenvalues.
  38. inline Col<eT> eigenvalues();
  39. //! Retrieve the eigenvectors.
  40. inline Mat<eT> eigenvectors();
  41. };
  42. } // namespace newarp