Skip to content
Snippets Groups Projects
Commit f2cee38f authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Introduce the np_int definition

parent a7749125
Branches
Tags
No related merge requests found
...@@ -282,9 +282,9 @@ void cluster(string config_file, string data_file, string output_path) { ...@@ -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); tppoan.open(tppoan_name.c_str(), ios::out | ios::binary);
if (tppoan.is_open()) { if (tppoan.is_open()) {
#ifdef USE_LAPACK #ifdef USE_LAPACK
printf("INFO: should use LAPACK calls.\n"); printf("INFO: using LAPACK calls.\n");
#else #else
printf("INFO: should use fall-back lucin() calls.\n"); printf("INFO: using fall-back lucin() calls.\n");
#endif #endif
tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&iavm), sizeof(int));
tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&isam), sizeof(int));
......
...@@ -10,13 +10,17 @@ ...@@ -10,13 +10,17 @@
* legacy serial function implementation is used as a fall-back. * legacy serial function implementation is used as a fall-back.
*/ */
#ifndef lapack_int
#define lapack_int int64_t
#endif
#ifndef INCLUDE_ALGEBRAIC_H_ #ifndef INCLUDE_ALGEBRAIC_H_
#define 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. /*! \brief Perform in-place matrix inversion.
* *
* \param mat: Matrix of complex. The matrix to be inverted (must be a square matrix). * \param mat: Matrix of complex. The matrix to be inverted (must be a square matrix).
...@@ -25,6 +29,6 @@ ...@@ -25,6 +29,6 @@
* \param max_size: `lapack_int` The maximum expected size (required by some call-backs, * \param max_size: `lapack_int` The maximum expected size (required by some call-backs,
* optional, defaults to 0). * 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 #endif
...@@ -15,6 +15,14 @@ ...@@ -15,6 +15,14 @@
#ifndef INCLUDE_CLU_SUBS_H_ #ifndef INCLUDE_CLU_SUBS_H_
#define 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. /*! \brief Compute the asymmetry-corrected scattering cross-section of a cluster.
* *
* This function computes the product between the geometrical asymmetry parameter and * This function computes the product between the geometrical asymmetry parameter and
...@@ -158,7 +166,7 @@ void hjv( ...@@ -158,7 +166,7 @@ void hjv(
* \param n: `int64_t` * \param n: `int64_t`
* \param ier: `int &` * \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. /*! \brief Compute the average extinction cross-section.
* *
......
...@@ -5,26 +5,26 @@ ...@@ -5,26 +5,26 @@
#include <complex> #include <complex>
#ifndef INCLUDE_ALGEBRAIC_H_
#include "../include/algebraic.h"
#endif
#ifndef INCLUDE_LAPACK_CALLS_H_ #ifndef INCLUDE_LAPACK_CALLS_H_
#include "lapacke.h" #include "lapacke.h"
#include "../include/lapack_calls.h" #include "../include/lapack_calls.h"
#endif #endif
#ifndef INCLUDE_ALGEBRAIC_H_
#include "../include/algebraic.h"
#endif
// >>> FALL-BACK FUNCTIONS DECLARATION <<< // // >>> 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 <<< // // >>> END OF FALL-BACK FUNCTIONS <<< //
using namespace std; 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; ier = 0;
#ifdef USE_LAPACK #ifdef USE_LAPACK
zinvert(mat, size, ier); zinvert(mat, size, ier);
#else #else
lucin(mat, (int64_t)max_size, (int64_t)size, ier); lucin(mat, max_size, size, ier);
#endif #endif
} }
...@@ -892,7 +892,7 @@ void hjv( ...@@ -892,7 +892,7 @@ void hjv(
delete[] rfn; 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 /* NDDMST FIRST DIMENSION OF AM AS DECLARED IN DIMENSION
* STATEMENT. * STATEMENT.
* N NUMBER OF ROWS IN AM. * N NUMBER OF ROWS IN AM.
......
...@@ -19,8 +19,8 @@ void zinvert(std::complex<double> **mat, lapack_int n, int &jer) { ...@@ -19,8 +19,8 @@ void zinvert(std::complex<double> **mat, lapack_int n, int &jer) {
lapack_int* IPIV = new lapack_int[n](); lapack_int* IPIV = new lapack_int[n]();
LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV); if (!LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV)) jer = 1;
LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV); if (!LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV)) jer = 2;
for (lapack_int i = 0; i < n; i++) { for (lapack_int i = 0; i < n; i++) {
for (lapack_int j = 0; j < n; j++) { for (lapack_int j = 0; j < n; j++) {
lapack_int idx = i + n * j; lapack_int idx = i + n * j;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment