Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
Fixed some style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Sep 25, 2018
1 parent 26b9099 commit 4b5336c
Show file tree
Hide file tree
Showing 16 changed files with 2,157 additions and 9,680 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "Disabled"
}
2 changes: 1 addition & 1 deletion bin/build_linux-release
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ cmake -G "Unix Makefiles" .. -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYP
make && \
ctest && \
make install && \
cpack -G "TGZ"
cpack -G "TGZ"

popd
2 changes: 1 addition & 1 deletion bin/check_style
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pushd `pwd`

cd ..

find . -type f | grep -v -e ".txt" -e ".git" -e "build/" -e "install/" -e "test/" | xargs ./bin/checkpatch.pl -f --no-tree --no-summary --terse --show-types --subjective --ignore LONG_LINE,OPEN_BRACE,ELSE_AFTER_BRACE,MACRO_WITH_FLOW_CONTROL,CAMELCASE,LINE_SPACING,SPACING,PREFER_KERNEL_TYPES
find . -type f | grep -v -e ".txt" -e ".git" -e "build/" -e "install/" -e "test/" -e "cml/include/cml/const/" -e "cml/include/cml/math/consts.h" -e "cml/include/cml/statistics/" -e "cml/include/cml/_common/machine.h" | xargs ./bin/checkpatch -f --no-tree --no-summary --terse --show-types --subjective --ignore SPDX_LICENSE_TAG,COMPLEX_MACRO,LEADING_SPACE,CODE_INDENT,MACRO_WITH_FLOW_CONTROL,NEW_TYPEDEFS,FUNCTION_ARGUMENTS

popd
File renamed without changes.
6 changes: 3 additions & 3 deletions cml/include/cml/_common/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

/* For compilers that don't have the builtin _Bool type. */
#if ((defined(_MSC_VER) && _MSC_VER < 1800) || \
(defined __GNUC__&& defined __STDC_VERSION__ && \
__STDC_VERSION__ < 199901L && __GNUC__ < 3)) \
&& !defined(_lint)
(defined __GNUC__ && defined __STDC_VERSION__ && \
__STDC_VERSION__ < 199901L && __GNUC__ < 3)) && \
!defined(_lint)
typedef unsigned char _Bool;
#endif

Expand Down
2 changes: 1 addition & 1 deletion cml/include/cml/_common/default.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#define CML_RANGE_CHECK 0 /* turn off range checking by default internally */
#endif

#define RETURN_IF_NULL(x) if (!x) { return; }
#define RETURN_IF_NULL(x) do { if (!(x)) return; } while (0)

/* Quick boolean definition */
#ifdef CML_NO_STDBOOL
Expand Down
99 changes: 50 additions & 49 deletions cml/include/cml/_private/templates_on.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* If BASE is undefined we use function names like cml_name()
and assume that we are using doubles.
If BASE is defined we used function names like cml_BASE_name()
and use BASE as the base datatype */
* and assume that we are using doubles.
*
* If BASE is defined we used function names like cml_BASE_name()
* and use BASE as the base datatype
*/

#if defined(BASE_CML_COMPLEX_LONG)
#define BASE cml_complex_long_double
Expand All @@ -15,8 +16,8 @@
#define IN_FORMAT "%Lg"
#define OUT_FORMAT "%Lg"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0L,0.0L}}
#define ONE {{1.0L,0.0L}}
#define ZERO { { 0.0L, 0.0L } }
#define ONE { { 1.0L, 0.0L } }
#define BASE_EPSILON CML_DBL_EPSILON

#elif defined(BASE_CML_COMPLEX)
Expand All @@ -32,8 +33,8 @@
#define IN_FORMAT "%lg"
#define OUT_FORMAT "%g"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0,0.0}}
#define ONE {{1.0,0.0}}
#define ZERO { { 0.0, 0.0 } }
#define ONE { { 1.0, 0.0 } }
#define BASE_EPSILON CML_DBL_EPSILON

#elif defined(BASE_CML_COMPLEX_FLOAT)
Expand All @@ -46,8 +47,8 @@
#define IN_FORMAT "%g"
#define OUT_FORMAT "%g"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0F,0.0F}}
#define ONE {{1.0F,0.0F}}
#define ZERO { { 0.0F, 0.0F } }
#define ONE { { 1.0F, 0.0F } }
#define BASE_EPSILON CML_FLT_EPSILON

#elif defined(BASE_CML_QUATERNION_LONG)
Expand All @@ -61,8 +62,8 @@
#define IN_FORMAT "%Lg"
#define OUT_FORMAT "%Lg"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0L,0.0L,0.0L,0.0L}}
#define ONE {{1.0L,0.0L,0.0L,0.0L}}
#define ZERO { { 0.0L, 0.0L, 0.0L, 0.0L } }
#define ONE { { 1.0L, 0.0L, 0.0L, 0.0L } }
#define BASE_EPSILON CML_DBL_EPSILON

#elif defined(BASE_CML_QUATERNION)
Expand All @@ -75,8 +76,8 @@
#define IN_FORMAT "%lg"
#define OUT_FORMAT "%g"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0,0.0,0.0,0.0}}
#define ONE {{1.0,0.0,0.0,0.0}}
#define ZERO { { 0.0, 0.0, 0.0, 0.0 } }
#define ONE { { 1.0, 0.0, 0.0, 0.0 } }
#define BASE_EPSILON CML_DBL_EPSILON

#elif defined(BASE_CML_QUATERNION_FLOAT)
Expand All @@ -89,8 +90,8 @@
#define IN_FORMAT "%g"
#define OUT_FORMAT "%g"
#define ATOMIC_IO ATOMIC
#define ZERO {{0.0F,0.0F,0.0F,0.0F}}
#define ONE {{1.0F,0.0F,0.0F,0.0F}}
#define ZERO { { 0.0F, 0.0F, 0.0F, 0.0F } }
#define ONE { { 1.0F, 0.0F, 0.0F, 0.0F } }
#define BASE_EPSILON CML_FLT_EPSILON

#elif defined(BASE_LONG_DOUBLE)
Expand Down Expand Up @@ -232,66 +233,66 @@
#error unknown BASE_ directive in source.h
#endif

#define CONCAT2x(a,b) a ## _ ## b
#define CONCAT2(a,b) CONCAT2x(a,b)
#define CONCAT3x(a,b,c) a ## _ ## b ## _ ## c
#define CONCAT3(a,b,c) CONCAT3x(a,b,c)
#define CONCAT4x(a,b,c,d) a ## _ ## b ## _ ## c ## _ ## d
#define CONCAT4(a,b,c,d) CONCAT4x(a,b,c,d)
#define CONCAT2x(a, b) a ## _ ## b
#define CONCAT2(a, b) CONCAT2x(a, b)
#define CONCAT3x(a, b, c) a ## _ ## b ## _ ## c
#define CONCAT3(a, b, c) CONCAT3x(a, b, c)
#define CONCAT4x(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d
#define CONCAT4(a, b, c, d) CONCAT4x(a, b, c, d)

#ifndef USE_QUALIFIER
#define QUALIFIER
#endif

#ifdef USE_QUALIFIER
#if defined(BASE_DOUBLE)
#define FUNCTION(dir,name) CONCAT3(dir,QUALIFIER,name)
#define FUNCTION(dir, name) CONCAT3(dir, QUALIFIER, name)
#define TYPE(dir) dir
#define VIEW(dir,name) CONCAT2(dir,name)
#define VIEW(dir, name) CONCAT2(dir, name)
#define QUALIFIED_TYPE(dir) QUALIFIER dir
#define QUALIFIED_VIEW(dir,name) CONCAT3(dir,QUALIFIER,name)
#define QUALIFIED_VIEW(dir, name) CONCAT3(dir, QUALIFIER, name)
#else
#define FUNCTION(a,c) CONCAT4(a,SHORT,QUALIFIER,c)
#define TYPE(dir) CONCAT2(dir,SHORT)
#define VIEW(dir,name) CONCAT3(dir,SHORT,name)
#define QUALIFIED_TYPE(dir) QUALIFIER CONCAT2(dir,SHORT)
#define QUALIFIED_VIEW(dir,name) CONCAT4(dir,SHORT,QUALIFIER,name)
#define FUNCTION(a, c) CONCAT4(a, SHORT, QUALIFIER, c)
#define TYPE(dir) CONCAT2(dir, SHORT)
#define VIEW(dir, name) CONCAT3(dir, SHORT, name)
#define QUALIFIED_TYPE(dir) QUALIFIER CONCAT2(dir, SHORT)
#define QUALIFIED_VIEW(dir, name) CONCAT4(dir, SHORT, QUALIFIER, name)
#endif
#if defined(BASE_CML_COMPLEX)
#define REAL_TYPE(dir) dir
#define REAL_VIEW(dir,name) CONCAT2(dir,name)
#define REAL_VIEW(dir, name) CONCAT2(dir, name)
#define QUALIFIED_REAL_TYPE(dir) QUALIFIER dir
#define QUALIFIED_REAL_VIEW(dir,name) CONCAT3(dir,QUALIFIER,name)
#define QUALIFIED_REAL_VIEW(dir, name) CONCAT3(dir, QUALIFIER, name)
#else
#define REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
#define REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
#define QUALIFIED_REAL_TYPE(dir) QUALIFIER CONCAT2(dir,SHORT_REAL)
#define QUALIFIED_REAL_VIEW(dir,name) CONCAT4(dir,SHORT_REAL,QUALIFIER,name)
#define REAL_TYPE(dir) CONCAT2(dir, SHORT_REAL)
#define REAL_VIEW(dir, name) CONCAT3(dir, SHORT_REAL, name)
#define QUALIFIED_REAL_TYPE(dir) QUALIFIER CONCAT2(dir, SHORT_REAL)
#define QUALIFIED_REAL_VIEW(dir, name) CONCAT4(dir, SHORT_REAL, QUALIFIER, name)
#endif
#else
#if defined(BASE_DOUBLE)
#define FUNCTION(dir,name) CONCAT2(dir,name)
#define FUNCTION(dir, name) CONCAT2(dir, name)
#define TYPE(dir) dir ## _t
#define VIEW(dir,name) CONCAT2(dir,name)
#define VIEW(dir, name) CONCAT2(dir, name)
#define QUALIFIED_TYPE(dir) TYPE(dir)
#define QUALIFIED_VIEW(dir,name) CONCAT2(dir,name)
#define QUALIFIED_VIEW(dir, name) CONCAT2(dir, name)
#else
#define FUNCTION(a,c) CONCAT3(a,SHORT,c)
#define TYPE(dir) CONCAT3(dir,SHORT,t)
#define VIEW(dir,name) CONCAT3(dir,SHORT,name)
#define FUNCTION(a, c) CONCAT3(a, SHORT, c)
#define TYPE(dir) CONCAT3(dir, SHORT, t)
#define VIEW(dir, name) CONCAT3(dir, SHORT, name)
#define QUALIFIED_TYPE(dir) TYPE(dir)
#define QUALIFIED_VIEW(dir,name) CONCAT3(dir,SHORT,name)
#define QUALIFIED_VIEW(dir, name) CONCAT3(dir, SHORT, name)
#endif
#if defined(BASE_CML_COMPLEX)
#define REAL_TYPE(dir) dir
#define REAL_VIEW(dir,name) CONCAT2(dir,name)
#define REAL_VIEW(dir, name) CONCAT2(dir, name)
#define QUALIFIED_REAL_TYPE(dir) dir
#define QUALIFIED_REAL_VIEW(dir,name) CONCAT2(dir,name)
#define QUALIFIED_REAL_VIEW(dir, name) CONCAT2(dir, name)
#else
#define REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
#define REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
#define QUALIFIED_REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
#define QUALIFIED_REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
#define REAL_TYPE(dir) CONCAT2(dir, SHORT_REAL)
#define REAL_VIEW(dir, name) CONCAT3(dir, SHORT_REAL, name)
#define QUALIFIED_REAL_TYPE(dir) CONCAT2(dir, SHORT_REAL)
#define QUALIFIED_REAL_VIEW(dir, name) CONCAT3(dir, SHORT_REAL, name)
#endif
#endif

Expand Down
53 changes: 23 additions & 30 deletions cml/include/cml/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,45 @@
#include <cml/_common/machine.h>
#undef _CML_COMMON_H_

typedef struct
{
union
{
typedef struct {
union {
long double p[2];
long double parts[2];
struct
{
struct {
long double re;
long double im;
};
struct
{
struct {
long double real;
long double imaginary;
};
};
} cml_complex_long_double_t;

typedef struct
{
union
{
typedef struct {
union {
double p[2];
double parts[2];
struct
{
struct {
double re;
double im;
};
struct
{
struct {
double real;
double imaginary;
};
};
} cml_complex_t;

typedef struct
{
union
{
typedef struct {
union {
float p[2];
float parts[2];
struct
{
struct {
float re;
float im;
};
struct
{
struct {
float real;
float imaginary;
};
Expand Down Expand Up @@ -85,12 +73,17 @@ __CML_END_DECLS
#define CIMAG(_x) ((_x).p[1])

#define CML_COMPLEX_P(zp) ((zp)->p)
#define CML_COMPLEX_P_REAL(zp) ((zp)->p[0])
#define CML_COMPLEX_P_IMAG(zp) ((zp)->p[1])
#define CML_COMPLEX_EQ(z1,z2) (((z1).p[0] == (z2).p[0]) && ((z1).p[1] == (z2).p[1]))
#define CML_COMPLEX_P_REAL(zp) ((zp)->p[0])
#define CML_COMPLEX_P_IMAG(zp) ((zp)->p[1])
#define CML_COMPLEX_EQ(z1, z2) \
((((z1).p[0] == (z2).p[0]) && ((z1).p[1] == (z2).p[1])))

#define CML_SET_COMPLEX(zp,x,y) do {(zp)->p[0]=(x); (zp)->p[1]=(y);} while(0)
#define CML_SET_REAL(zp,x) do {(zp)->p[0]=(x);} while(0)
#define CML_SET_IMAG(zp,y) do {(zp)->p[1]=(y);} while(0)
#define CML_SET_COMPLEX(zp, x, y) do { \
(zp)->p[0] = (x); \
(zp)->p[1] = (y); \
} while (0)

#define CML_SET_REAL(zp, x) (zp)->p[0] = (x)
#define CML_SET_IMAG(zp, y) (zp)->p[1] = (y)

#endif
34 changes: 15 additions & 19 deletions cml/include/cml/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __CML_BEGIN_DECLS
double cml_nan(void);
double cml_inf(void);
double cml_ninf(void);
char* cml_as_string(double);
char *cml_as_string(double);

#include <cml/math/basic.h>
#include <cml/math/classification.h>
Expand All @@ -39,39 +39,35 @@ char* cml_as_string(double);

/* Definition of an arbitrary function with parameters */

typedef struct
{
double (* function)(double x, void *params);
typedef struct {
double (*function)(double x, void *params);
void *params;
} cml_function_t;

#define CML_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)

#define CML_FN_EVAL(F, x) (*((F)->function))(x, (F)->params)

/* Definition of an arbitrary function returning two values, r1, r2 */

typedef struct
{
double (* f)(double x, void *params);
double (* df)(double x, void *params);
void (* fdf)(double x, void *params, double * f, double * df);
typedef struct {
double (*f)(double x, void *params);
double (*df)(double x, void *params);
void (*fdf)(double x, void *params, double *f, double *df);
void *params;
} cml_function_fdf_t;

#define CML_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
#define CML_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
#define CML_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))

#define CML_FN_FDF_EVAL_F(FDF, x) (*((FDF)->f))(x, (FDF)->params)
#define CML_FN_FDF_EVAL_DF(FDF, x) (*((FDF)->df))(x, (FDF)->params)
#define CML_FN_FDF_EVAL_F_DF(FDF, x, y, dy) \
(*((FDF)->fdf))(x, (FDF)->params, (y), (dy))

/* Definition of an arbitrary vector-valued function with parameters */

typedef struct
{
int (* function)(double x, double y[], void *params);
typedef struct {
int (*function)(double x, double y[], void *params);
void *params;
} cml_function_vec_t;

#define CML_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
#define CML_FN_VEC_EVAL(F, x, y) (*((F)->function))(x, y, (F)->params)

__CML_END_DECLS

Expand Down
4 changes: 2 additions & 2 deletions cml/include/cml/minmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ __CML_BEGIN_DECLS
/* Define MAX and MIN macros/functions if they don't exist. */

/* plain old macros for general use */
#define CML_MAX(a,b) ((a) > (b) ? (a) : (b))
#define CML_MIN(a,b) ((a) < (b) ? (a) : (b))
#define CML_MAX(a, b) ((a) > (b) ? (a) : (b))
#define CML_MIN(a, b) ((a) < (b) ? (a) : (b))

__CML_END_DECLS

Expand Down
Loading

0 comments on commit 4b5336c

Please sign in to comment.