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

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Dec 9, 2018
2 parents dbe25d4 + 7d9bace commit ee6a54b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CMathL

[![Mentioned in Awesome C](https://awesome.re/mentioned-badge.svg)](https://github.com/aleksandar-todorovic/awesome-c#numerical)
[![Build Status](https://travis-ci.org/ScientificC/cmathl.svg?branch=master)](https://travis-ci.org/ScientificC/cmathl) [![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)

CMathL _(CML)_ is a pure-C math library with a great variety of mathematical functions. It is almost 100% C89/C90 compliant.
Expand Down
21 changes: 7 additions & 14 deletions cml/src/math/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,13 @@ cml_abs(double x)
double
cml_ared_a(double x, double a)
{
double z;

z = cml_div(x, a);

return x - z*a;
return x - a * cml_div(x, a);
}

double
cml_ared(double x)
{
double z, k;

z = cml_div(x, M_TAU);
k = z * M_TAU;

return x - k;
return x - cml_div(x, M_TAU) * M_TAU;
}


Expand Down Expand Up @@ -141,19 +132,21 @@ cml_inverse(double x)
double
cml_mod(double x, double y)
{
return x - y*cml_div(x, y);
return x - y * cml_div(x, y);
}


double
cml_opposite(double x)
{
return (double) -x;
return -x;
}


double
cml_sgn(double x)
{
return (double) (x >= 0.0 ? 1.0 : -1.0);
return x >= 0.0 ?
1.0 :
-1.0;
}
7 changes: 5 additions & 2 deletions cml/src/math/classification.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ __CML_EXTERN_INLINE bool
__isinteger(double x)
{
mint_t x_int = (mint_t) x;

return cml_isnull(x - x_int);
}

Expand All @@ -51,7 +52,9 @@ cml_cmp(double x1, double x2, double epsilon)
/* Find exponent of largest absolute value */

{
double max = (cml_abs(x1) > cml_abs(x2)) ? x1 : x2;
double max = cml_abs(x1) > cml_abs(x2) ?
x1 :
x2;

cml_frexp(max, &exponent);
}
Expand Down Expand Up @@ -80,7 +83,7 @@ cml_cmp(double x1, double x2, double epsilon)
bool
cml_equal(double x, double y)
{
return cml_abs(x - y) < CML_FLT_EPSILON;
return cml_nearequal(x, y, CML_FLT_EPSILON);
}


Expand Down
6 changes: 2 additions & 4 deletions cml/src/math/hyperbolic.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ cml_asinh(double x)
double
cml_atanh(double x)
{
double y, h;
double y;

y = cml_abs(x);
h = cml_isgreater(1.0, y) ?
return cml_isgreater(1.0, y) ?
(double) __cml_atanh(x, 1e4) :
cml_nan();

return h;
}


Expand Down

0 comments on commit ee6a54b

Please sign in to comment.