Commit 80c8faa2 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Start transition to complex.h

parent 3f4e2807
Loading
Loading
Loading
Loading
+34 −32
Original line number Original line Diff line number Diff line
/* Distributed under the terms of GPLv3 or later. See COPYING for details. */

/*! \file Commons.h
/*! \file Commons.h
 *
 *
 * \brief C++ porting of common data structures.
 * \brief C++ porting of common data structures.
@@ -42,15 +44,15 @@ protected:
	int nlmmt;
	int nlmmt;
public:
public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **rmi;
	dcomplex **rmi;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **rei;
	dcomplex **rei;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **w;
	dcomplex **w;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *fsas;
	dcomplex *fsas;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **vints;
	dcomplex **vints;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double *sscs;
	double *sscs;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
@@ -80,7 +82,7 @@ public:
	//! \brief Vector of numbers of spherical layers.
	//! \brief Vector of numbers of spherical layers.
	int *nshl;
	int *nshl;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> ***sas;
	dcomplex ***sas;


	/*! \brief C1 instance constructor.
	/*! \brief C1 instance constructor.
	 *
	 *
@@ -105,13 +107,13 @@ class C2 {
	int nhspo;
	int nhspo;
public:
public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *ris;
	dcomplex *ris;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *dlri;
	dcomplex *dlri;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *dc0;
	dcomplex *dc0;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vkt;
	dcomplex *vkt;
	//! Vector of scaled sizes. QUESTION: correct?
	//! Vector of scaled sizes. QUESTION: correct?
	double *vsz;
	double *vsz;


@@ -133,9 +135,9 @@ public:
class C3 {
class C3 {
public:
public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> tfsas;
	dcomplex tfsas;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **tsas;
	dcomplex **tsas;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double gcs;
	double gcs;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
@@ -210,35 +212,35 @@ protected:
	void allocate_vectors(C4 *c4);
	void allocate_vectors(C4 *c4);
public:
public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vh;
	dcomplex *vh;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vj0;
	dcomplex *vj0;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vj;
	dcomplex *vj;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vyhj;
	dcomplex *vyhj;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vyj0;
	dcomplex *vyj0;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **am0m;
	dcomplex **am0m;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vint;
	dcomplex *vint;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vintm;
	dcomplex *vintm;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **vints;
	dcomplex **vints;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *vintt;
	dcomplex *vintt;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **fsac;
	dcomplex **fsac;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **sac;
	dcomplex **sac;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **fsacm;
	dcomplex **fsacm;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double *scsc;
	double *scsc;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *scscp;
	dcomplex *scscp;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double *ecsc;
	double *ecsc;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
@@ -246,11 +248,11 @@ public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double *scscm;
	double *scscm;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *ecscp;
	dcomplex *ecscp;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *scscpm;
	dcomplex *scscpm;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> *ecscpm;
	dcomplex *ecscpm;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	double *v3j0;
	double *v3j0;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
@@ -296,11 +298,11 @@ protected:
	int sam_size_0;
	int sam_size_0;
public:
public:
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **gis;
	dcomplex **gis;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **gls;
	dcomplex **gls;
	//! \brief QUESTION: definition?
	//! \brief QUESTION: definition?
	std::complex<double> **sam;
	dcomplex **sam;


	/*! \brief C9 instance constructor.
	/*! \brief C9 instance constructor.
	 *
	 *
+11 −9
Original line number Original line Diff line number Diff line
/* Distributed under the terms of GPLv3 or later. See COPYING for details. */

/*! \file TransitionMatrix.h
/*! \file TransitionMatrix.h
 *
 *
 * \brief Representation of the Transition Matrix.
 * \brief Representation of the Transition Matrix.
@@ -19,7 +21,7 @@ class TransitionMatrix {
  //! External medium refractive index.
  //! External medium refractive index.
  double exri;
  double exri;
  //! Vectorized matrix elements.
  //! Vectorized matrix elements.
  std::complex<double> *elements;
  dcomplex *elements;
  //! Sphere radius.
  //! Sphere radius.
  double sphere_radius;
  double sphere_radius;
  //! Matrix shape
  //! Matrix shape
@@ -66,11 +68,11 @@ class TransitionMatrix {
   * \param _lm: `int` Maximum field expansion order.
   * \param _lm: `int` Maximum field expansion order.
   * \param _vk: `double` Wave number in scale units.
   * \param _vk: `double` Wave number in scale units.
   * \param _exri: `double` External medium refractive index.
   * \param _exri: `double` External medium refractive index.
   * \param _elements: `complex<double> *` Vectorized elements of the matrix.
   * \param _elements: `complex double *` Vectorized elements of the matrix.
   * \param _radius: `double` Radius for the single sphere case (defaults to 0.0).
   * \param _radius: `double` Radius for the single sphere case (defaults to 0.0).
   */
   */
  TransitionMatrix(
  TransitionMatrix(
		   int _is, int _lm, double _vk, double _exri, std::complex<double> *_elements,
		   int _is, int _lm, double _vk, double _exri, dcomplex *_elements,
		   double _radius=0.0
		   double _radius=0.0
  );
  );


@@ -82,13 +84,13 @@ class TransitionMatrix {
   * \param _lm: `int` Maximum field expansion order.
   * \param _lm: `int` Maximum field expansion order.
   * \param _vk: `double` Wave number in scale units.
   * \param _vk: `double` Wave number in scale units.
   * \param _exri: `double` External medium refractive index.
   * \param _exri: `double` External medium refractive index.
   * \param _rmi: Matrix of complex.
   * \param _rmi: `complex double **`
   * \param _rei: Matrix of complex.
   * \param _rei: `complex double **`
   * \param _sphere_radius: `double` Radius of the sphere.
   * \param _sphere_radius: `double` Radius of the sphere.
   */
   */
  TransitionMatrix(
  TransitionMatrix(
		   int _lm, double _vk, double _exri, std::complex<double> **_rmi,
		   int _lm, double _vk, double _exri, dcomplex **_rmi,
		   std::complex<double> **_rei, double _sphere_radius
		   dcomplex **_rei, double _sphere_radius
  );
  );


  /*! \brief Transition Matrix instance constructor for a cluster of spheres.
  /*! \brief Transition Matrix instance constructor for a cluster of spheres.
@@ -100,9 +102,9 @@ class TransitionMatrix {
   * \param _lm: `int` Maximum field expansion order.
   * \param _lm: `int` Maximum field expansion order.
   * \param _vk: `double` Wave number in scale units.
   * \param _vk: `double` Wave number in scale units.
   * \param _exri: `double` External medium refractive index.
   * \param _exri: `double` External medium refractive index.
   * \param _am0m: Matrix of complex.
   * \param _am0m: `complex double **`
   */
   */
  TransitionMatrix(int _nlemt, int _lm, double _vk, double _exri, std::complex<double> **_am0m);
  TransitionMatrix(int _nlemt, int _lm, double _vk, double _exri, dcomplex **_am0m);


  /*! \brief Transition Matrix instance destroyer.
  /*! \brief Transition Matrix instance destroyer.
   */
   */
+4 −2
Original line number Original line Diff line number Diff line
/* Distributed under the terms of GPLv3 or later. See COPYING for details. */

/*! \file algebraic.h
/*! \file algebraic.h
 *
 *
 * \brief Declaration of algebraic functions with different call-backs.
 * \brief Declaration of algebraic functions with different call-backs.
@@ -23,12 +25,12 @@


/*! \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: `complex double **` The matrix to be inverted (must be a square matrix).
 * \param size: `lapack_int` The size of the matrix (i.e. the number of its rows or columns).
 * \param size: `lapack_int` The size of the matrix (i.e. the number of its rows or columns).
 * \param ier: `int &` Reference to an integer variable for returning a result flag.
 * \param ier: `int &` Reference to an integer variable for returning a result flag.
 * \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, np_int size, int &ier, np_int max_size=0);
void invert_matrix(dcomplex **mat, np_int size, int &ier, np_int max_size=0);


#endif
#endif
+3 −1
Original line number Original line Diff line number Diff line
/* Distributed under the terms of GPLv3 or later. See COPYING for details. */

/*! \file lapack_calss.h
/*! \file lapack_calss.h
 *
 *
 * \brief C++ interface to LAPACK calls.
 * \brief C++ interface to LAPACK calls.
@@ -16,6 +18,6 @@
 * \param n: `lapack_int` The number of rows and columns of the [n x n] matrix.
 * \param n: `lapack_int` The number of rows and columns of the [n x n] matrix.
 * \param jer: `int &` Reference to an integer return flag.
 * \param jer: `int &` Reference to an integer return flag.
 */
 */
void zinvert(std::complex<double> **mat, lapack_int n, int &jer);
void zinvert(dcomplex **mat, lapack_int n, int &jer);


#endif
#endif
+39 −39
Original line number Original line Diff line number Diff line
/* Distributed under the terms of GPLv3 or later. See COPYING for details. */

/*! \file sph_subs.h
/*! \file sph_subs.h
 *
 *
 * \brief C++ porting of SPH functions and subroutines.
 * \brief C++ porting of SPH functions and subroutines.
@@ -35,11 +37,11 @@ void aps(double ****zpv, int li, int nsph, C1 *c1, double sqk, double *gaps);
 * backward recurrence. This is the `CSPHJ` implementation of the `specfun` library.
 * backward recurrence. This is the `CSPHJ` implementation of the `specfun` library.
 *
 *
 * \param n: `int` Order of the function.
 * \param n: `int` Order of the function.
 * \param z: `complex<double>` Argument of the function.
 * \param z: `complex double` Argument of the function.
 * \param nm: `int &` Highest computed order.
 * \param nm: `int &` Highest computed order.
 * \param csj: Vector of complex. The desired function \f$j\f$.
 * \param csj: `complex double *` The desired function \f$j\f$.
 */
 */
void cbf(int n, std::complex<double> z, int &nm, std::complex<double> csj[]);
void cbf(int n, dcomplex z, int &nm, dcomplex *csj);


/*! \brief Clebsch-Gordan coefficients.
/*! \brief Clebsch-Gordan coefficients.
 *
 *
@@ -56,10 +58,10 @@ double cg1(int lmpml, int mu, int l, int m);


/*! \brief Conjugate of a double precision complex number
/*! \brief Conjugate of a double precision complex number
 *
 *
 * \param z: `complex<double>` The input complex number.
 * \param z: `complex double` The input complex number.
 * \return result: `complex<double>` The conjugate of the input number.
 * \return result: `complex double` The conjugate of the input number.
 */
 */
std::complex<double> dconjg(std::complex<double> z);
dcomplex dconjg(dcomplex z);


/*! \brief Comute the continuous variation of the refractive index and of its radial derivative.
/*! \brief Comute the continuous variation of the refractive index and of its radial derivative.
 *
 *
@@ -95,11 +97,11 @@ void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2);
 * \param c2: `C2 *` Pointer to a `C2` data structure.
 * \param c2: `C2 *` Pointer to a `C2` data structure.
 * \param jer: `int &` Reference to integer error code variable.
 * \param jer: `int &` Reference to integer error code variable.
 * \param lcalc: `int &` Reference to integer variable recording the maximum expansion order accounted for.
 * \param lcalc: `int &` Reference to integer variable recording the maximum expansion order accounted for.
 * \param arg: `complex<double> &`
 * \param arg: `complex double &`
 */
 */
void dme(
void dme(
	 int li, int i, int npnt, int npntts, double vk, double exdc, double exri,
	 int li, int i, int npnt, int npntts, double vk, double exdc, double exri,
	 C1 *c1, C2 *c2, int &jer, int &lcalc, std::complex<double> &arg
	 C1 *c1, C2 *c2, int &jer, int &lcalc, dcomplex &arg
);
);


/*! \brief Bessel function calculation control parameters.
/*! \brief Bessel function calculation control parameters.
@@ -118,11 +120,11 @@ double envj(int n, double x);
 * This function computes the Mueller Transformation Matrix, or Phase Matrix. See
 * This function computes the Mueller Transformation Matrix, or Phase Matrix. See
 * Sec. 2.8.1 of Borghese, Denti & Saija (2007).
 * Sec. 2.8.1 of Borghese, Denti & Saija (2007).
 *
 *
 * \param vint: Vector of complex.
 * \param vint: `complex double *`
 * \param cmullr: `double **`
 * \param cmullr: `double **`
 * \param cmul: `double **`
 * \param cmul: `double **`
 */
 */
void mmulc(std::complex<double> *vint, double **cmullr, double **cmul);
void mmulc(dcomplex *vint, double **cmullr, double **cmul);


/*! \brief Starting point for Bessel function magnitude.
/*! \brief Starting point for Bessel function magnitude.
 *
 *
@@ -168,14 +170,14 @@ void orunve(double *u1, double *u2, double *u3, int iorth, double torth);
 *
 *
 * \param up: `double *`
 * \param up: `double *`
 * \param un: `double *`
 * \param un: `double *`
 * \param ylm: Vector of complex. Field polar spherical harmonics.
 * \param ylm: `complex double *` Field polar spherical harmonics.
 * \param inpol: `int` Incident field polarization type (0 - linear; 1 - circular).
 * \param inpol: `int` Incident field polarization type (0 - linear; 1 - circular).
 * \param lw: `int`
 * \param lw: `int`
 * \param isq: `int`
 * \param isq: `int`
 * \param c1: `C1 *` Pointer to a `C1` data structure.
 * \param c1: `C1 *` Pointer to a `C1` data structure.
 */
 */
void pwma(
void pwma(
	  double *up, double *un, std::complex<double> *ylm, int inpol, int lw,
	  double *up, double *un, dcomplex *ylm, int inpol, int lw,
	  int isq, C1 *c1
	  int isq, C1 *c1
);
);


@@ -189,14 +191,14 @@ void pwma(
 * \param li: `int` Maximum field expansion order.
 * \param li: `int` Maximum field expansion order.
 * \param nsph: `int` Number of spheres.
 * \param nsph: `int` Number of spheres.
 * \param c1: `C1 *` Pointer to `C1` data structure.
 * \param c1: `C1 *` Pointer to `C1` data structure.
 * \param tqse: Matrix of complex.
 * \param tqse: `double **`
 * \param tqspe: Matrix of complex.
 * \param tqspe: `complex double **`
 * \param tqss: Matrix of complex.
 * \param tqss: `double **`
 * \param tqsps: Matrix of complex.
 * \param tqsps: `complex double **`
 */
 */
void rabas(
void rabas(
	   int inpol, int li, int nsph, C1 *c1, double **tqse, std::complex<double> **tqspe,
	   int inpol, int li, int nsph, C1 *c1, double **tqse, dcomplex **tqspe,
	   double **tqss, std::complex<double> **tqsps
	   double **tqss, dcomplex **tqsps
);
);


/*! \brief Real Bessel Function.
/*! \brief Real Bessel Function.
@@ -219,18 +221,17 @@ void rbf(int n, double x, int &nm, double sj[]);
 *
 *
 * \param npntmo: `int`
 * \param npntmo: `int`
 * \param step: `double`
 * \param step: `double`
 * \param dcc: `complex<double>`
 * \param dcc: `complex double`
 * \param x: `double &`
 * \param x: `double &`
 * \param lpo: `int`
 * \param lpo: `int`
 * \param y1: `complex<double> &`
 * \param y1: `complex double &`
 * \param y2: `complex<double> &`
 * \param y2: `complex double &`
 * \param dy1: `complex<double> &`
 * \param dy1: `complex double &`
 * \param dy2: `complex<double> &`
 * \param dy2: `complex double &`
 */
 */
void rkc(
void rkc(
	 int npntmo, double step, std::complex<double> dcc, double &x, int lpo,
	 int npntmo, double step, dcomplex dcc, double &x, int lpo,
	 std::complex<double> &y1, std::complex<double> &y2, std::complex<double> &dy1,
	 dcomplex &y1, dcomplex &y2, dcomplex &dy1, dcomplex &dy2
	 std::complex<double> &dy2
);
);


/*! \brief Transition layer radial function and derivative.
/*! \brief Transition layer radial function and derivative.
@@ -242,16 +243,15 @@ void rkc(
 * \param step: `double`
 * \param step: `double`
 * \param x: `double &`
 * \param x: `double &`
 * \param lpo: `int`
 * \param lpo: `int`
 * \param y1: `complex<double> &`
 * \param y1: `complex double &`
 * \param y2: `complex<double> &`
 * \param y2: `complex double &`
 * \param dy1: `complex<double> &`
 * \param dy1: `complex double &`
 * \param dy2: `complex<double> &`
 * \param dy2: `complex double &`
 * \param c2: `C2 *` Pointer to a `C2` data structure.
 * \param c2: `C2 *` Pointer to a `C2` data structure.
 */
 */
void rkt(
void rkt(
	 int npntmo, double step, double &x, int lpo, std::complex<double> &y1,
	 int npntmo, double step, double &x, int lpo, dcomplex &y1,
	 std::complex<double> &y2, std::complex<double> &dy1, std::complex<double> &dy2,
	 dcomplex &y2, dcomplex &dy1, dcomplex &dy2, C2 *c2
	 C2 *c2
);
);


/*! \brief Spherical Bessel functions.
/*! \brief Spherical Bessel functions.
@@ -262,9 +262,9 @@ void rkt(
 * \param n: `int` Order of the function (from 0 up).
 * \param n: `int` Order of the function (from 0 up).
 * \param x: `double` Argumento of the function (\f$x > 0\f$).
 * \param x: `double` Argumento of the function (\f$x > 0\f$).
 * \param nm: `int &` Highest computed order.
 * \param nm: `int &` Highest computed order.
 * \param sy: `double[]` The desired function \f$y\f$.
 * \param sy: `double *` The desired function \f$y\f$.
 */
 */
void rnf(int n, double x, int &nm, double sy[]);
void rnf(int n, double x, int &nm, double *sy);


/*! \brief Spherical harmonics for given direction.
/*! \brief Spherical harmonics for given direction.
 *
 *
@@ -276,11 +276,11 @@ void rnf(int n, double x, int &nm, double sy[]);
 * \param cosrph: `double` Cosine of direction's azimuth.
 * \param cosrph: `double` Cosine of direction's azimuth.
 * \param sinrph: `double` Sine of direction's azimuth.
 * \param sinrph: `double` Sine of direction's azimuth.
 * \param ll: `int` L value expansion order.
 * \param ll: `int` L value expansion order.
 * \param ylm: Vector of complex. The requested spherical harmonics.
 * \param ylm: `complex double *` The requested spherical harmonics.
 */
 */
void sphar(
void sphar(
	   double cosrth, double sinrth, double cosrph, double sinrph,
	   double cosrth, double sinrth, double cosrph, double sinrph,
	   int ll, std::complex<double> *ylm
	   int ll, dcomplex *ylm
);
);


/*! \brief Compute scattering, absorption and extinction cross-sections.
/*! \brief Compute scattering, absorption and extinction cross-sections.
@@ -288,14 +288,14 @@ void sphar(
 * This function computes the scattering, absorption and extinction cross-sections in terms
 * This function computes the scattering, absorption and extinction cross-sections in terms
 * of Forward Scattering Amplitudes. See Sec. 4.2.1 in Borghese, Denti & Saija (2007).
 * of Forward Scattering Amplitudes. See Sec. 4.2.1 in Borghese, Denti & Saija (2007).
 *
 *
 * \param tfsas: `complex<double> &`
 * \param tfsas: `complex double &`
 * \param nsph: `int` Number of spheres.
 * \param nsph: `int` Number of spheres.
 * \param lm: `int` Maximum field expansion order.
 * \param lm: `int` Maximum field expansion order.
 * \param vk: `double` Wave number in scale units.
 * \param vk: `double` Wave number in scale units.
 * \param exri: `double` External medium refractive index.
 * \param exri: `double` External medium refractive index.
 * \param c1: `C1 *` Pointer to a `C1` data structure.
 * \param c1: `C1 *` Pointer to a `C1` data structure.
 */
 */
void sscr0(std::complex<double> &tfsas, int nsph, int lm, double vk, double exri, C1 *c1);
void sscr0(dcomplex &tfsas, int nsph, int lm, double vk, double exri, C1 *c1);


/*! \brief C++ Compute the scattering amplitude and the scattered field intensity.
/*! \brief C++ Compute the scattering amplitude and the scattered field intensity.
 *
 *
Loading