Skip to content

Commit a263c83

Browse files
Switch to using pragma once for header files, and replace multiple definitions of WIDE_PI constant with use of math library M_PIl
Co-Authored-By: David Ignacio Cortee <[email protected]>
1 parent 16534ec commit a263c83

17 files changed

+58
-85
lines changed

native/include/a_clib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "a_random.h"
88
#include "c_vectormath.h"
99

10-
#define WIDE_PI 3.1415926535897932384626433832795L
10+
1111

1212
// ----------------------------------------------------------------------------
1313
// From exch.c

native/include/a_random.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
#ifndef __FIDIMAG_RANDOM__
2-
#define __FIDIMAG_RANDOM__
3-
4-
5-
6-
//#include<omp.h>
7-
8-
#define WIDE_PI 3.1415926535897932384626433832795L
1+
#pragma once
92

103
//=================================================
114
//random number, mt19937
@@ -14,7 +7,7 @@ typedef struct {
147
unsigned int matrix[2];// = { 0, 0x9908b0dfU};
158
int index_t;
169
int seed;
17-
10+
1811
} mt19937_state;
1912

2013
#define MT19973_RAND_MAX 4294967295u
@@ -29,5 +22,3 @@ int rand_int_n(mt19937_state *state, int n);
2922
void gauss_random_vector(mt19937_state *state, double *x, int n);
3023

3124
void uniform_random_sphere(mt19937_state *state, double *spin, int n);
32-
33-
#endif

native/include/c_clib.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
2-
32
#include <math.h>
43
#include<omp.h>
5-
#define WIDE_PI 3.1415926535897932384626433832795L
4+
65

76
// ----------------------------------------------------------------------------
87
// From: llg.c

native/include/c_demagcoef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma once
12
/* This file demag_oommf.h is taken from the OOMMF project (oommf/app/oxs/ext/demagcoef.h
23
downloaded from http://math.nist.gov/oommf/dist/oommf12a5rc_20120928.tar.gz)
34
with slightly modifications (change OC_REALWIDE to double)

native/include/c_dipolar.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
#pragma once
12
#include<math.h>
23
#include<complex>
34
#include<fftw3.h>
45
#include "c_vectormath.h"
5-
//#include<omp.h>
6-
7-
#define WIDE_PI 3.1415926535897932384626433832795L
8-
96

107
enum Type_Nij {
118
Tensor_xx, Tensor_yy, Tensor_zz, Tensor_xy, Tensor_xz, Tensor_yz
@@ -24,9 +21,9 @@ typedef struct {
2421
int lenx;
2522
int leny;
2623
int lenz;
27-
24+
2825
int total_length;
29-
26+
3027
//TODO: free tensors after obtaining NXX to save memory?
3128
double *tensor_xx;
3229
double *tensor_yy;
@@ -42,7 +39,7 @@ typedef struct {
4239
std::complex<double> *Nxy;
4340
std::complex<double> *Nxz;
4441
std::complex<double> *Nyz;
45-
42+
4643
std::complex<double> *Mx;
4744
std::complex<double> *My;
4845
std::complex<double> *Mz;
@@ -56,7 +53,7 @@ typedef struct {
5653
double *hx;
5754
double *hy;
5855
double *hz;
59-
56+
6057
//we need three plans
6158
fftw_plan tensor_plan;
6259
fftw_plan m_plan;
@@ -68,7 +65,7 @@ fft_demag_plan *create_plan(void);
6865
void finalize_plan(fft_demag_plan * plan);
6966
void init_plan(fft_demag_plan *plan, double dx, double dy,
7067
double dz, int nx, int ny, int nz);
71-
void compute_dipolar_tensors(fft_demag_plan * plan);
68+
void compute_dipolar_tensors(fft_demag_plan * plan);
7269
void compute_demag_tensors(fft_demag_plan * plan);
7370
void create_fftw_plan(fft_demag_plan * plan);
7471

@@ -111,4 +108,3 @@ void run_step1(ode_solver *s, double *m, double *h, double *m_pred, double *T,
111108
double *alpha, double *mu_s_inv, int *pins);
112109
void run_step2(ode_solver *s, double *m_pred, double *h, double *m, double *T,
113110
double *alpha, double *mu_s_inv, int *pins);
114-

native/include/c_nebm_geodesic_lib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "math.h"
2-
#define WIDE_PI 3.1415926535897932384626433832795L
32

43
double compute_geodesic_GreatCircle(double * A, double * B,
54
int n_dofs_image,

native/include/c_nebm_lib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "math.h"
2-
#define WIDE_PI 3.1415926535897932384626433832795L
32

43
void compute_tangents_C(double * ys, double * energy,
54
double * tangents, int image_num, int nodes

native/include/c_nebm_spherical_lib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "math.h"
2-
#define WIDE_PI 3.1415926535897932384626433832795L
32

43
void normalise_spherical(double * a, int n);
54

native/include/c_tensor_2dpbc.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ inline double RR(double x,double y,double z)
77
inline double R(double x,double y,double z)
88
{return sqrt(x*x+y*y+z*z);}
99

10-
//------------------------------------------------------------------------------
10+
//------------------------------------------------------------------------------
1111

1212
//------------------------------------------------------------------------------
1313
//about Nxxinf
1414

15-
inline double
15+
inline double
1616
fxx(double x,double y,double z)
1717
{
1818
double t1,t2,t3,t5;
@@ -49,7 +49,7 @@ inline double fzz(double x,double y,double z){
4949
}
5050

5151

52-
inline double
52+
inline double
5353
Nzzinf(double x,double y,double z,double X0,double Y0)
5454
{
5555
return fzz(x+X0,y+Y0,z)+fzz(x-X0,y-Y0,z)-fzz(x+X0,y-Y0,z)-fzz(x-X0,y+Y0,z);
@@ -97,7 +97,7 @@ inline double Nyzinf(double x,double y,double z,double X0,double Y0){
9797
//------------------------------------------------------------------------------
9898
//------------------------------------------------------------------------------
9999
//about Nxxdipole
100-
inline double
100+
inline double
101101
DemagNxxDipolar(double x,double y,double z)
102102
{
103103
double t1 = x*x;
@@ -109,7 +109,7 @@ double t8 = sqrt(t6);
109109
return -(2.0 * t1 - t3 - t4) / (t8 * t7);
110110
}
111111

112-
inline double
112+
inline double
113113
DemagNxyDipolar(double x,double y,double z)
114114
{
115115
double t6 = RR(x,y,z);
@@ -125,4 +125,3 @@ double DemagTensorAsymptotic(enum Type_Nij comp,double x,double y,double z,doubl
125125
double DemagTensorDipolar(enum Type_Nij comp,double x,double y,double z);
126126

127127
double DemagTensorInfinite(enum Type_Nij comp,double x,double y,double z,double X0,double Y0);
128-

native/include/m_baryakhtar_clib.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#include<math.h>
22

3-
//#include<omp.h>
4-
5-
#define WIDE_PI 3.1415926535897932384626433832795L
63
#define MU0 1.25663706143591728850e-6
74

85
void compute_laplace_m(double *m, double *field, double *Ms, double dx, double dy, double dz,

0 commit comments

Comments
 (0)