Skip to content

Commit

Permalink
Merge pull request #24 from saudzahirr/Fix-build
Browse files Browse the repository at this point in the history
Fix build
  • Loading branch information
saudzahirr authored Aug 31, 2024
2 parents ad06770 + 41b9aa2 commit 2138136
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: Linux Build and Test

on:
push:
branches:
branches:
- master
- Fix-build
- Fix-ci/cd-pipeline
pull_request:
branches:
branches:
- master
- Fix-ci/cd-pipeline

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
push:
branches:
- master
- Fix-build
- Fix-ci/cd-pipeline
pull_request:
branches:
- master
- Fix-ci/cd-pipeline

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion src/vonmises/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
"""

import ctypes
import os
import sys
from pathlib import Path


sys_version = f"{sys.version_info.major}{sys.version_info.minor}"
if sys.platform == "win32":
shared_file_path = Path(
sys.prefix,
"bin",
"libvonmises.dll",
)
os.add_dll_directory(str(shared_file_path))
vonmises_lib = ctypes.CDLL(str(shared_file_path), winmode=0)
elif sys.platform == "linux":
shared_file_path = Path(sys.prefix, "lib", "libvonmises.so")
Expand Down
8 changes: 4 additions & 4 deletions src/vonmiseslib/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include <ctime>
#endif

#define DEBUG(msg, ...) fmt::print(__TIME__ ": DEBUG : " msg "\n", ##__VA_ARGS__)
#define INFO(msg, ...) fmt::print(__TIME__ ": INFO : " msg "\n", ##__VA_ARGS__)
#define WARNING(msg, ...) fmt::print(__TIME__ ": WARNING : " msg "\n", ##__VA_ARGS__)
#define ERROR(msg, ...) fmt::print(__TIME__ ": ERROR : " msg "\n", ##__VA_ARGS__)
#define DEBUG_OUT(msg, ...) fmt::print(__TIME__ ": DEBUG : " msg "\n", ##__VA_ARGS__)
#define INFO_OUT(msg, ...) fmt::print(__TIME__ ": INFO : " msg "\n", ##__VA_ARGS__)
#define WARNING_OUT(msg, ...) fmt::print(__TIME__ ": WARNING : " msg "\n", ##__VA_ARGS__)
#define ERROR_OUT(msg, ...) fmt::print(__TIME__ ": ERROR : " msg "\n", ##__VA_ARGS__)

using namespace std;

Expand Down
4 changes: 2 additions & 2 deletions src/vonmiseslib/rayleigh_quotient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@


double rayleighQuotient(const MatrixXd& A, const VectorXd& x) {
INFO("Calculating eigenvalue using Rayleigh Quotient ...");
INFO_OUT("Calculating eigenvalue using Rayleigh Quotient ...");

double k = (A * x).dot(x) / x.dot(x);

DEBUG("Eigenvalue: {}", k);
DEBUG_OUT("Eigenvalue: {}", k);

return k;
}
14 changes: 7 additions & 7 deletions src/vonmiseslib/vonMises_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
*/

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("----------------------------------------------");
INFO_OUT("----------------------------------------------");
INFO_OUT("CMake Version :: {}", CMake_VERSION);
INFO_OUT("GCC Version :: {}", gcc_VERSION);
INFO_OUT("OMP max threads :: {}", omp_get_max_threads());
INFO_OUT("----------------------------------------------");

MatrixXd _A = convertToEigenMatrix(A, size);
// Power Iteration with Deflation
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));
DEBUG_OUT("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));
DEBUG_OUT("Execution time for Rayleigh Quotient Method: {} seconds", deltaTime(start_time));
// Store the computed eigenvalue
eigenvalues[a] = c;

Expand Down
6 changes: 3 additions & 3 deletions src/vonmiseslib/von_mises.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

VectorXd vonMisesIterationMethod(const MatrixXd& A) {

INFO("Starting Von Mises Method ...");
INFO("Initializing random vector for Von Mises iteration ...");
INFO_OUT("Starting Von Mises Method ...");
INFO_OUT("Initializing random vector for Von Mises iteration ...");

int n = A.rows();
VectorXd x = VectorXd::Zero(n);
Expand Down Expand Up @@ -49,7 +49,7 @@ VectorXd vonMisesIterationMethod(const MatrixXd& A) {

double epsilon = (x - u).norm();
if (epsilon == 0 || epsilon < TOLERANCE) {
DEBUG("Dominant Eigenvector converged at {} iterations.", a);
DEBUG_OUT("Dominant Eigenvector converged at {} iterations.", a);

return x;
}
Expand Down

0 comments on commit 2138136

Please sign in to comment.