Skip to content

Commit

Permalink
run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Feb 6, 2023
1 parent 630eb81 commit 50a6555
Show file tree
Hide file tree
Showing 7 changed files with 1,122 additions and 1,244 deletions.
24 changes: 24 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BasedOnStyle: LLVM
IndentWidth: 2
UseTab: Never
IndentCaseLabels: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
ColumnLimit: 100
Standard: Cpp03
SortIncludes: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
24 changes: 13 additions & 11 deletions check.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@

/* some useful error-checking macros: */

#define CHECK(condition, message) do { \
if (!(condition)) { \
fprintf(stderr, "harminv: failure on line %d of " __FILE__ ": " \
message "\n", __LINE__); exit(EXIT_FAILURE); \
} \
} while (0)
#define CHECK(condition, message) \
do { \
if (!(condition)) { \
fprintf(stderr, "harminv: failure on line %d of " __FILE__ ": " message "\n", __LINE__); \
exit(EXIT_FAILURE); \
} \
} while (0)

#define CHK_MALLOC(p, t, n) do { \
size_t CHK_MALLOC_n_tmp = (n); \
(p) = (t *) malloc(sizeof(t) * CHK_MALLOC_n_tmp); \
CHECK((p) || CHK_MALLOC_n_tmp == 0, "out of memory!"); \
} while (0)
#define CHK_MALLOC(p, t, n) \
do { \
size_t CHK_MALLOC_n_tmp = (n); \
(p) = (t *)malloc(sizeof(t) * CHK_MALLOC_n_tmp); \
CHECK((p) || CHK_MALLOC_n_tmp == 0, "out of memory!"); \
} while (0)

#endif /* CHECK_H */
51 changes: 25 additions & 26 deletions harminv-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
without it. Alternatively, use the complex<double> STL class in
C++. */

# include <complex.h>
#include <complex.h>
#endif

#include "harminv.h"
Expand All @@ -34,45 +34,44 @@ typedef harminv_complex cmplx; /* shortcut */

/* define extended precision (long double) cmplxl type */
#if defined(HAVE_LONG_DOUBLE) && !defined(__cplusplus)
# if defined(__cplusplus)
# include <complex>
#if defined(__cplusplus)
#include <complex>
typedef std::complex<long double> cmplxl; /* problematic w/some C++ comp's */

# elif defined(_Complex_I) && defined(complex) && defined(I)
#elif defined(_Complex_I) && defined(complex) && defined(I)
/* C99 <complex.h> header was included before harminv.h */
typedef long double _Complex cmplxl;

# endif
#endif
#else
typedef cmplx cmplxl;
#endif


#ifdef __cplusplus
# define I cmplx(0,1)
# define creal(c) real(c)
# define cimag(c) imag(c)
# define cabs(c) abs(c)
# define carg(c) arg(c)
# define cexp(c) exp(c)
# define csqrt(c) sqrt(c)
# define clog(c) log(c)
#define I cmplx(0, 1)
#define creal(c) real(c)
#define cimag(c) imag(c)
#define cabs(c) abs(c)
#define carg(c) arg(c)
#define cexp(c) exp(c)
#define csqrt(c) sqrt(c)
#define clog(c) log(c)
#else
# ifndef HAVE_CARG /* Cray doesn't have this for some reason */
# define carg(c) atan2(cimag(c), creal(c))
# endif
#ifndef HAVE_CARG /* Cray doesn't have this for some reason */
#define carg(c) atan2(cimag(c), creal(c))
#endif
#endif

struct harminv_data_struct {
const cmplx *c;
int n, K, J, nfreqs;
double fmin, fmax;
cmplx *z;
cmplx *U0, *U1;
cmplxl *G0, *G0_M, *D0; /* cached G, G_M, and D arrays for U0 */
cmplx *B, *u; /* eigen-solutions of U1*B = u*U0*B */
cmplx *amps; /* mode amplitudes */
double *errs; /* relative "error" estimates */
const cmplx *c;
int n, K, J, nfreqs;
double fmin, fmax;
cmplx *z;
cmplx *U0, *U1;
cmplxl *G0, *G0_M, *D0; /* cached G, G_M, and D arrays for U0 */
cmplx *B, *u; /* eigen-solutions of U1*B = u*U0*B */
cmplx *amps; /* mode amplitudes */
double *errs; /* relative "error" estimates */
};

#endif /* HARMINV_INT_H */
Loading

0 comments on commit 50a6555

Please sign in to comment.