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

Commit

Permalink
Merge pull request #21 from CMATHL/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ulises-jeremias committed Feb 24, 2018
2 parents 92ae704 + cc5210c commit cae7882
Show file tree
Hide file tree
Showing 113 changed files with 1,264 additions and 1,220 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ compiler:

env:
- FLAGS=""
- FLAGS="-DCML_LONG_DOUBLE_MATH=ON"
- FLAGS="-DCML_NO_MATH=ON -DCML_NO_STDBOOL=ON -DCML_NO_STDINT=ON"
- FLAGS="-DCML_LONG_DOUBLE_MATH=ON -DCML_NO_MATH=ON -DCML_NO_STDBOOL=ON -DCML_NO_STDINT=ON"


script:
- mkdir build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)

PROJECT(cml
LANGUAGES C
VERSION 1.9.8)
VERSION 1.9.10)


INCLUDE(${CMAKE_SOURCE_DIR}/cmake/CPackConfig.cmake)
Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cml

[![Build Status](https://travis-ci.org/CMATHL/cml.svg?branch=development)](https://travis-ci.org/CMATHL/cml) [![Documentation Status](https://readthedocs.org/projects/cml/badge/?version=latest)](http://cml.readthedocs.io/en/latest/?badge=latest) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![Version: v1.9.8](https://img.shields.io/badge/Version-v1.9.8-blue.svg)
[![Build Status](https://travis-ci.org/CMATHL/cml.svg?branch=development)](https://travis-ci.org/CMATHL/cml) [![Documentation Status](https://readthedocs.org/projects/cml/badge/?version=latest)](http://cml.readthedocs.io/en/latest/?badge=latest) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![Version: v1.9.10](https://img.shields.io/badge/Version-v1.9.10-blue.svg)

CML is a pure-C math library with a great variety of mathematical functions. It is almost 100% C89/C90 compliant.

Expand All @@ -15,10 +15,8 @@ You can read the following [docs](http://cml.readthedocs.io/) to learn more abou
- [Bool Type](#bool-type)
- [Integer Type](#integer-type)
- [Float Point Type](#float-point-type)
- [Long Double Type](#long-double-type)
- [Math Functions Aliases](#math-functions-aliases)
- [Math Library](#math-library)
- [Math Precision](#math-precision)

- [**Build Options**](#build-options)

Expand Down Expand Up @@ -62,13 +60,10 @@ $ make && ctest

CML can be configured with the following preprocessors (described in the following sections of this document):

- `CML_LONG_DOUBLE_MATH`
- `CML_NO_ALIASES`
- `CML_NO_MATH`
- `CML_NO_STDBOOL`
- `CML_NO_STDINT`
- `mfloat_t`
- `mint_t`

You can define these macros during compilation time with flags:

Expand All @@ -86,7 +81,7 @@ By default, `mint_t` is a `int32_t` if the header `stdint.h` is available. If th

### Float Point Type

The float type used by CML is defined by the macro `mfloat_t`, which is by default `double`.
The float type used by CML is by default `double`.

### Math Functions Aliases

Expand All @@ -98,10 +93,6 @@ By defining `CML_NO_ALIASES`, these aliases will not be defined, leaving only th

By default, cml will use some math functions from the header `math.h` if it is available. If the header `math.h` is not avaliable, disabled by defining `CML_NO_MATH`, cml will use its own definition of them.

### Math Precision

By default, the library will have double precision for the internal definition of its functions. Then, this precision could be changed to the extended double precision and, at the same time, `mfloat_t` will be defined _(if possible)_ as `long double`. This precision can be simply extended by defining the macro `CML_LONG_DOUBLE_MATH`.

## Build Options

- CML_BUILD_SHARED: (Default ON) Controls if the shared library is built
Expand Down
16 changes: 0 additions & 16 deletions cmake/CMLFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ ELSE()
MESSAGE(STATUS "Using math functions aliases")
ENDIF()

OPTION(CML_LONG_DOUBLE_MATH "Use long double-precision floating point values" BOOL:TRUE)
IF(CML_LONG_DOUBLE_MATH)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCML_LONG_DOUBLE_MATH=\"${CML_LONG_DOUBLE_MATH}\"")
MESSAGE(STATUS "Using long double-precision floating point values")
ELSE()
MESSAGE(STATUS "Using double-precision floating point values")
ENDIF()

OPTION(CML_NO_STDBOOL "Use stdbool.h" BOOL:FALSE)
IF(CML_NO_STDBOOL)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCML_NO_STDBOOL=\"${CML_NO_ALIASES}\"")
Expand All @@ -41,11 +33,3 @@ IF(CML_NO_MATH)
ELSE()
MESSAGE(STATUS "Using math.h")
ENDIF()

IF(mint_t)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dmint_t=\"${mint_t}\"")
ENDIF()

IF(mfloat_t)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dmfloat_t=\"${mfloat_t}\"")
ENDIF()
24 changes: 12 additions & 12 deletions cml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ SET(CML_SRCS
src/errno/message.c
src/errno/stream.c
src/errno/strerrno.c
src/math/complex/trigonometric.c
src/math/complex/hyperbolic.c
src/math/complex/basic.c
src/math/complex/exponentiation.c
src/math/complex.c
src/math/real/nearest-integer.c
src/math/real/trigonometric.c
src/math/real/power.c
src/math/real/exponential.c
src/math/real/hyperbolic.c
src/math/real/basic.c
src/math/real/classification.c
src/complex/trigonometric.c
src/complex/hyperbolic.c
src/complex/basic.c
src/complex/exponentiation.c
src/complex/complex.c
src/math/nearest-integer.c
src/math/trigonometric.c
src/math/power.c
src/math/exponential.c
src/math/hyperbolic.c
src/math/basic.c
src/math/classification.c
src/math/real.c
src/easings/exponential.c
src/easings/quadratic.c
Expand Down
44 changes: 13 additions & 31 deletions cml/include/cml.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
#ifndef CML_H
#define CML_H

#include "cml/config.h"
#include "cml/default.h"
#include "cml/errno.h"
#include "cml/ieee.h"
#include "cml/inline.h"
#include "cml/machine.h"
#include "cml/minmax.h"

#ifndef PREDEF_STANDARD_C11
#undef __CML_NO_GENERIC
#define __CML_NO_GENERIC
#endif

#define __CML_ARGS_FIRST(A, ...) A

#ifndef __CML_TYPE
#define __CML_TYPE(__e, __t) \
__builtin_types_compatible_p(__typeof(__e), __t)
#endif

#ifndef __CML_SAME_TYPE
#define __CML_SAME_TYPE(__a, __b) \
__builtin_types_compatible_p(__typeof(__a), __typeof(__b))
#endif

#include <cml/config.h>
#include <cml/default.h>
#include <cml/errno.h>
#include <cml/ieee.h>
#include <cml/inline.h>
#include <cml/machine.h>
#include <cml/minmax.h>

#if defined CML_NO_ALIASES || defined __CML_NO_GENERIC
#include "cml/math.h"
#include <cml/math.h>
#else
#include "cml/tgmath.h"
#include <cml/tgmath.h>
#endif

#include "cml/deriv.h"
#include "cml/diff.h"
#include "cml/easings.h"
#include "cml/structures.h"
#include <cml/deriv.h>
#include <cml/diff.h>
#include <cml/easings.h>
#include <cml/structures.h>

#endif
6 changes: 3 additions & 3 deletions cml/include/cml/math/bool.h → cml/include/cml/bool.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef CML_H
#error "Never use <cml/math/bool.h> directly; include <cml.h> instead."
#error "Never use <cml/bool.h> directly; include <cml.h> instead."
#endif

#ifndef CML_MATH_TYPES_BOOL_H
#define CML_MATH_TYPES_BOOL_H
#ifndef CML_BOOL_H
#define CML_BOOL_H

#ifndef __cplusplus

Expand Down
73 changes: 56 additions & 17 deletions cml/include/cml/math/complex.h → cml/include/cml/complex.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
#ifndef CML_H
#error "Never use <cml/math/complex.h> directly; include <cml.h> instead."
#endif

#ifndef CML_COMPLEX_H
#define CML_COMPLEX_H

#define CML_H
#include <cml/default.h>
#include <cml/inline.h>
#include <cml/machine.h>

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

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

typedef struct _complex_float
{
union
{
float p[2];
float parts[2];
struct
{
float re;
float im;
};
struct
{
float real;
float imaginary;
};
};
} complex_float_t;

__CML_BEGIN_DECLS

complex_t complex(real_t, real_t);
complex_t complex_polar(real_t, real_t);
complex_t complex(double, double);
complex_t complex_polar(double, double);
complex_t complex_zero();
complex_t complex_nan();
complex_t complex_inf();
Expand All @@ -37,11 +76,11 @@ char* complex_as_string(complex_t);

__CML_END_DECLS

#include "complex/basic.h"
#include "complex/error.h"
#include "complex/exponentiation.h"
#include "complex/hyperbolic.h"
#include "complex/trigonometric.h"
#include <cml/complex/basic.h>
#include <cml/complex/error.h>
#include <cml/complex/exponentiation.h>
#include <cml/complex/hyperbolic.h>
#include <cml/complex/trigonometric.h>

#ifndef CML_NO_ALIASES
#define creal(X) (X).re
Expand Down
30 changes: 30 additions & 0 deletions cml/include/cml/complex/basic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CML_COMPLEX_BASIC_FUNC_H
#define CML_COMPLEX_BASIC_FUNC_H

__CML_BEGIN_DECLS

double complex_abs(complex_t);
double complex_arg(complex_t);
double complex_logabs(complex_t);

complex_t complex_add(complex_t, complex_t);
complex_t complex_conj(complex_t);
complex_t complex_div(complex_t, complex_t);
complex_t complex_inverse(complex_t);
complex_t complex_mul(complex_t, complex_t);
complex_t complex_scalar_mul(complex_t, double);
complex_t complex_sub(complex_t, complex_t);

complex_t complex_add_real(complex_t, double); /* r=a+x */
complex_t complex_sub_real(complex_t, double); /* r=a-x */
complex_t complex_mul_real(complex_t, double); /* r=a*x */
complex_t complex_div_real(complex_t, double); /* r=a/x */

complex_t complex_add_imag(complex_t, double); /* r=a+iy */
complex_t complex_sub_imag(complex_t, double); /* r=a-iy */
complex_t complex_mul_imag(complex_t, double); /* r=a*iy */
complex_t complex_div_imag(complex_t, double); /* r=a/iy */

__CML_END_DECLS

#endif
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ complex_t complex_exp(complex_t);
complex_t complex_log_b(complex_t, complex_t);
complex_t complex_log(complex_t);
complex_t complex_sqrt(complex_t);
complex_t complex_sqrt_real(real_t);
complex_t complex_sqrt_real(double);
complex_t complex_pow(complex_t, complex_t);
complex_t complex_pow_real(complex_t, real_t);
complex_t complex_pow_real(complex_t, double);

__CML_END_DECLS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ complex_t complex_csch(complex_t);
complex_t complex_coth(complex_t);
complex_t complex_asinh(complex_t);
complex_t complex_acosh(complex_t);
complex_t complex_acosh_real(real_t);
complex_t complex_acosh_real(double);
complex_t complex_atanh(complex_t);
complex_t complex_atanh_real(real_t);
complex_t complex_atanh_real(double);
complex_t complex_asech(complex_t);
complex_t complex_acsch(complex_t);
complex_t complex_acoth(complex_t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ complex_t complex_sin(complex_t);
complex_t complex_tan(complex_t);

complex_t complex_asin(complex_t);
complex_t complex_asin_real(real_t);
complex_t complex_asin_real(double);
complex_t complex_acos(complex_t);
complex_t complex_acos_real(real_t);
complex_t complex_acos_real(double);
complex_t complex_atan(complex_t);
complex_t complex_asec(complex_t);
complex_t complex_asec_real(real_t);
complex_t complex_asec_real(double);
complex_t complex_acsc(complex_t);
complex_t complex_acsc_real(real_t);
complex_t complex_acsc_real(double);
complex_t complex_acot(complex_t);

__CML_END_DECLS
Expand Down
14 changes: 5 additions & 9 deletions cml/include/cml/const.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#ifndef CML_H
#error "Never use <cml/const.h> directly; include <cml.h> instead."
#endif

#ifndef CML_CONST_H
#define CML_CONST_H

#include "const/num.h"
#include <cml/const/num.h>

#include "const/cgs.h"
#include "const/mks.h"
#include <cml/const/cgs.h>
#include <cml/const/mks.h>

#include "const/cgsm.h"
#include "const/mksa.h"
#include <cml/const/cgsm.h>
#include <cml/const/mksa.h>

#endif

0 comments on commit cae7882

Please sign in to comment.