diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp index a0fc6642699bd16d07afa8eea9220eea08039730..dacb574119f61fe4c78f4cc9c1a8901d9ec921b4 100644 --- a/src/cluster/cluster.cpp +++ b/src/cluster/cluster.cpp @@ -282,9 +282,9 @@ void cluster(string config_file, string data_file, string output_path) { tppoan.open(tppoan_name.c_str(), ios::out | ios::binary); if (tppoan.is_open()) { #ifdef USE_LAPACK - printf("INFO: should use LAPACK calls.\n"); + printf("INFO: using LAPACK calls.\n"); #else - printf("INFO: should use fall-back lucin() calls.\n"); + printf("INFO: using fall-back lucin() calls.\n"); #endif tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int)); diff --git a/src/include/algebraic.h b/src/include/algebraic.h index 8c0cf1242a06aaa3d95885bd05cb02ef357ccca7..a72d94da8fe27fd32c42045f09699a827add455d 100644 --- a/src/include/algebraic.h +++ b/src/include/algebraic.h @@ -10,13 +10,17 @@ * legacy serial function implementation is used as a fall-back. */ -#ifndef lapack_int -#define lapack_int int64_t -#endif - #ifndef INCLUDE_ALGEBRAIC_H_ #define INCLUDE_ALGEBRAIC_H_ +#ifndef np_int +#ifndef lapack_int +#define np_int int64_t +#else +#define np_int lapack_int +#endif +#endif + /*! \brief Perform in-place matrix inversion. * * \param mat: Matrix of complex. The matrix to be inverted (must be a square matrix). @@ -25,6 +29,6 @@ * \param max_size: `lapack_int` The maximum expected size (required by some call-backs, * optional, defaults to 0). */ -void invert_matrix(std::complex<double> **mat, lapack_int size, int &ier, lapack_int max_size=0); +void invert_matrix(std::complex<double> **mat, np_int size, int &ier, np_int max_size=0); #endif diff --git a/src/include/clu_subs.h b/src/include/clu_subs.h index 6420e619cb682c3a7384d34f2a2788aeda122878..6e0587d982b999b1fc907cb7434c21ac5d14718f 100644 --- a/src/include/clu_subs.h +++ b/src/include/clu_subs.h @@ -15,6 +15,14 @@ #ifndef INCLUDE_CLU_SUBS_H_ #define INCLUDE_CLU_SUBS_H_ +#ifndef np_int +#ifndef lapack_int +#define np_int int64_t +#else +#define np_int lapack_int +#endif +#endif + /*! \brief Compute the asymmetry-corrected scattering cross-section of a cluster. * * This function computes the product between the geometrical asymmetry parameter and @@ -158,7 +166,7 @@ void hjv( * \param n: `int64_t` * \param ier: `int &` */ -void lucin(std::complex<double> **am, const int64_t nddmst, int64_t n, int &ier); +void lucin(std::complex<double> **am, const np_int nddmst, np_int n, int &ier); /*! \brief Compute the average extinction cross-section. * diff --git a/src/libnptm/algebraic.cpp b/src/libnptm/algebraic.cpp index a1c420315ee5535df368f4c9a6736e6f068ecd9d..9f81015f45a1dc1a37c75e8d3472ae01fc82d248 100644 --- a/src/libnptm/algebraic.cpp +++ b/src/libnptm/algebraic.cpp @@ -5,26 +5,26 @@ #include <complex> -#ifndef INCLUDE_ALGEBRAIC_H_ -#include "../include/algebraic.h" -#endif - #ifndef INCLUDE_LAPACK_CALLS_H_ #include "lapacke.h" #include "../include/lapack_calls.h" #endif +#ifndef INCLUDE_ALGEBRAIC_H_ +#include "../include/algebraic.h" +#endif + // >>> FALL-BACK FUNCTIONS DECLARATION <<< // -extern void lucin(std::complex<double> **mat, int64_t max_size, int64_t size, int &ier); +extern void lucin(std::complex<double> **mat, np_int max_size, np_int size, int &ier); // >>> END OF FALL-BACK FUNCTIONS <<< // using namespace std; -void invert_matrix(std::complex<double> **mat, lapack_int size, int &ier, lapack_int max_size) { +void invert_matrix(std::complex<double> **mat, np_int size, int &ier, np_int max_size) { ier = 0; #ifdef USE_LAPACK zinvert(mat, size, ier); #else - lucin(mat, (int64_t)max_size, (int64_t)size, ier); + lucin(mat, max_size, size, ier); #endif } diff --git a/src/libnptm/clu_subs.cpp b/src/libnptm/clu_subs.cpp index 48f087b919e66fa7b53326b50d09b7774b3f3bd8..377677d897495bf402b2002b7bb585cd3aa38c5c 100644 --- a/src/libnptm/clu_subs.cpp +++ b/src/libnptm/clu_subs.cpp @@ -892,7 +892,7 @@ void hjv( delete[] rfn; } -void lucin(std::complex<double> **am, const int64_t nddmst, int64_t n, int &ier) { +void lucin(std::complex<double> **am, const np_int nddmst, np_int n, int &ier) { /* NDDMST FIRST DIMENSION OF AM AS DECLARED IN DIMENSION * STATEMENT. * N NUMBER OF ROWS IN AM. diff --git a/src/libnptm/lapack_calls.cpp b/src/libnptm/lapack_calls.cpp index 462bdaeca05486556cb43e44d093cc1e9f41914a..43efcce8f7b0d159172f2c14e645bf65324444b5 100644 --- a/src/libnptm/lapack_calls.cpp +++ b/src/libnptm/lapack_calls.cpp @@ -19,8 +19,8 @@ void zinvert(std::complex<double> **mat, lapack_int n, int &jer) { lapack_int* IPIV = new lapack_int[n](); - LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV); - LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV); + if (!LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV)) jer = 1; + if (!LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV)) jer = 2; for (lapack_int i = 0; i < n; i++) { for (lapack_int j = 0; j < n; j++) { lapack_int idx = i + n * j;