Eigen.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _Eigen_h_
  2. #define _Eigen_h_
  3. /* Eigen.h
  4. *
  5. * Copyright (C) 1993-2018 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Collection.h"
  21. #include "Graphics.h"
  22. #include "Strings_.h"
  23. #include "Eigen_def.h"
  24. autoEigen Eigen_create (integer numberOfEigenvalues, integer dimension);
  25. void Eigen_init (Eigen me, integer numberOfEigenvalues, integer dimension);
  26. void Eigen_initFromSymmetricMatrix (Eigen me, constMAT a);
  27. void Eigen_initFromSquareRoot (Eigen me, constMAT a);
  28. /*
  29. Calculate eigenstructure for symmetric matrix A'A (e.g. covariance matrix),
  30. when only A is given.
  31. Precondition: numberOfRows > 1
  32. Method: SVD.
  33. */
  34. void Eigen_initFromSquareRootPair (Eigen me, constMAT a, constMAT b);
  35. /*
  36. Calculate eigenstructure for A'Ax - lambda B'Bx = 0
  37. Preconditions: numberOfRows >= numberOfColumns &&
  38. numberOfRows_b >= numberOfColumns
  39. Method: Generalized SVD.
  40. */
  41. integer Eigen_getNumberOfEigenvectors (Eigen me);
  42. integer Eigen_getDimensionOfComponents (Eigen me);
  43. double Eigen_getCumulativeContributionOfComponents (Eigen me, integer from, integer to);
  44. integer Eigen_getDimensionOfFraction (Eigen me, double fraction);
  45. double Eigen_getEigenvectorElement (Eigen me, integer ivec, integer element);
  46. double Eigen_getSumOfEigenvalues (Eigen me, integer from, integer to);
  47. void Eigen_sort (Eigen me);
  48. /*
  49. Sort eigenvalues and corresponding eigenvectors in decreasing order.
  50. */
  51. void Eigen_invertEigenvector (Eigen me, integer ivec);
  52. void Eigen_drawEigenvalues (Eigen me, Graphics g, integer first, integer last, double ymin, double ymax,
  53. bool fractionOfTotal, bool cumulative, double size_mm, conststring32 mark, bool garnish);
  54. void Eigen_drawEigenvector (Eigen me, Graphics g, integer ivec, integer first, integer last, double minimum, double maximum, bool weigh,
  55. double size_mm, conststring32 mark, bool connect, char32 **rowLabels, bool garnish);
  56. /*
  57. Draw eigenvector. When rowLabels != nullptr, draw row text labels on bottom axis.
  58. */
  59. /**
  60. Adapt the sign of each eigenvector except the first
  61. in such a way that it correlates positively with the first eigenvector.
  62. */
  63. void Eigens_alignEigenvectors (OrderedOf<structEigen>* me);
  64. double Eigens_getAngleBetweenEigenplanes_degrees (Eigen me, Eigen thee);
  65. /*
  66. Get angle between the eigenplanes, spanned by the first two eigenvectors, .
  67. */
  68. #endif /* _Eigen_h_ */