-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from saudzahirr/eigen
Add thirdParty libs
- Loading branch information
Showing
369 changed files
with
165,675 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024 Saud Zahir | ||
* | ||
* This file is part of vonMises. | ||
* | ||
* vonMises is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License. | ||
* | ||
* vonMises is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT | ||
* License for more details. | ||
*/ | ||
|
||
|
||
#include "eigen_API.h" | ||
|
||
/** | ||
* @file | ||
* Eigen value problem solver using deflation method power iteration | ||
*/ | ||
|
||
void solveEigenValueProblem(double** A, int size) { | ||
void solveEigenValueProblem(double** A, size_t size, double* eigenvalues, double** eigenvectors) { | ||
INFO("----------------------------------------------"); | ||
INFO("CMake Version :: {}", CMake_VERSION); | ||
INFO("GCC Version :: {}", gcc_VERSION); | ||
INFO("OMP max threads :: {}", omp_get_max_threads()); | ||
INFO("----------------------------------------------"); | ||
|
||
MatrixXd _A = convertToEigenMatrix(A, size); | ||
// Power Iteration with Deflation | ||
for (int i = 0; i < size; i++) { | ||
double* x = VonMisesIterationMethod(A, size); | ||
double c = RayleighQuotient(A, x, size); | ||
DEBUG_OUTFILE("*EIGEN_VALUE: " + to_string(c)); | ||
DEBUG_OUTFILE("*EIGEN_VECTOR: " + getVectorString(x, size)); | ||
cout << endl; | ||
A = matrixSub(A, matrixScalarProduct(outerProduct(x, size, x, size), size, size, c), size, size); | ||
delete[] x; | ||
for (size_t a = 0; a < size; a++) { | ||
double start_time = clocktime(); | ||
VectorXd x = vonMisesIterationMethod(_A); | ||
DEBUG("Execution time for Von Mises Method: {} seconds", deltaTime(start_time)); | ||
start_time = clocktime(); | ||
double c = rayleighQuotient(_A, x); | ||
DEBUG("Execution time for Rayleigh Quotient Method: {} seconds", deltaTime(start_time)); | ||
// Store the computed eigenvalue | ||
eigenvalues[a] = c; | ||
|
||
// Store the eigenvector | ||
for (size_t i = 0; i < size; i++) { | ||
eigenvectors[a][i] = x(i); | ||
} | ||
_A = _A - c * (x * x.transpose()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.