NumericalMethods.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <NumericalMethods/Eigenanalysis.h>
  9. #include <NumericalMethods/Optimization.h>
  10. #include <Optimization/SolverBFGS.h>
  11. #include <Eigenanalysis/Solver3x3.h>
  12. namespace NumericalMethods
  13. {
  14. namespace Optimization
  15. {
  16. SolverResult SolverBFGS(const Function& function, const AZStd::vector<double>& initialGuess)
  17. {
  18. return MinimizeBFGS(function, initialGuess);
  19. }
  20. }
  21. namespace Eigenanalysis
  22. {
  23. SolverResult<Real, 3> Solver3x3RealSymmetric(const SquareMatrix<Real, 3>& matrix)
  24. {
  25. // The matrix must be symmetric.
  26. if (matrix[0][1] == matrix[1][0] && matrix[0][2] == matrix[2][0] && matrix[1][2] == matrix[2][1])
  27. {
  28. return NonIterativeSymmetricEigensolver3x3(
  29. matrix[0][0], matrix[0][1], matrix[0][2],
  30. matrix[1][1], matrix[1][2],
  31. matrix[2][2]
  32. );
  33. }
  34. else
  35. {
  36. return SolverResult<Real, 3>{SolverOutcome::FailureInvalidInput};
  37. }
  38. }
  39. }
  40. } // namespace NumericalMethods