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 #25 from CMATHL/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ulises-jeremias committed Mar 30, 2018
2 parents 6761162 + 766ec9e commit c327201
Show file tree
Hide file tree
Showing 184 changed files with 7,851 additions and 1,366 deletions.
14 changes: 0 additions & 14 deletions .appveyor.yml

This file was deleted.

9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ compiler:
env:
- FLAGS=""
- FLAGS="-DCML_NO_MATH=ON -DCML_NO_STDBOOL=ON -DCML_NO_STDINT=ON"
- C_FLAGS=""
- C_FLAGS="-std=c89"

script:
- mkdir build
- cd build
- cmake --version
- cmake -trace --warn-uninitialized --warn-unused_vars -Wdev -G "Unix Makefiles" .. -DCML_BUILD_TESTS=ON $FLAGS
- cmake -trace --warn-uninitialized --warn-unused_vars -Wdev -G "Unix Makefiles" .. -DCML_BUILD_TESTS=ON $FLAGS -DCMAKE_C_FLAGS=$C_FLAGS
- make && ctest
- ./test/test_cml
- echo "Tests for static library"
- ./test/test_cml_static
- echo "Tests for shared library"
- ./test/test_cml_shared

addons:
apt:
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.0)

FILE(STRINGS "VERSION" CML_VERSION)

PROJECT(cml
LANGUAGES C
VERSION 1.9.10)
VERSION ${CML_VERSION})


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

[![Build Status](https://travis-ci.org/CMATHL/cml.svg?branch=master)](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)
[![Build Status](https://travis-ci.org/CMATHL/cml.svg?branch=master)](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)

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

You can read the following [docs](http://cml.readthedocs.io/) to learn more about CML.
You can read the [documentation](http://cml.readthedocs.io/) to learn more about CML.

## Table of Contents

- [**Using the CML**](#using-the-cmathl)
- [**Running Tests**](#running-tests)
- [**Configuration Macros**](#configuration-macros)
- [**Using the CML**](#using-the-cmathl)
- [**Running Tests**](#running-tests)
- [**Configuration Macros**](#configuration-macros)

- [Bool Type](#bool-type)
- [Integer Type](#integer-type)
- [Float Point Type](#float-point-type)
- [Math Functions Aliases](#math-functions-aliases)
- [Math Library](#math-library)
- [Bool Type](#bool-type)
- [Integer Type](#integer-type)
- [Float Point Type](#float-point-type)
- [Math Functions Aliases](#math-functions-aliases)
- [Math Library](#math-library)

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

- [**Documentation**](#documentation)

- [**Can I trust this math library?**](#can-i-trust-this-math-library)
- [**Build Options**](#build-options)
- [**Documentation**](#documentation)
- [**Can I trust this math library?**](#can-i-trust-this-math-library)

## Using the CML

Expand All @@ -39,7 +37,7 @@ $ make && make install

[_Build Options_](#build-options)

You can read more about in the following [file](./docs/USING_THE_REFERENCE.md).
You can read more about in the following [chapter](http://cml.readthedocs.io/en/latest/usage.html) of the documentation.

## Running Tests

Expand All @@ -60,16 +58,14 @@ $ make && ctest

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

- `CML_NO_ALIASES`
- `CML_NO_MATH`
- `CML_NO_STDBOOL`
- `CML_NO_STDINT`
- `CML_NO_ALIASES`
- `CML_NO_MATH`
- `CML_NO_STDBOOL`
- `CML_NO_STDINT`

You can define these macros during compilation time with flags:

```
cmake .. -DCML_NO_STDBOOL=ON -DCML_NO_MATH=ON -DCML_LONG_DOUBLE_MATH=ON
```
cmake .. -DCML_NO_STDBOOL=ON -DCML_NO_MATH=ON

### Bool Type

Expand All @@ -95,35 +91,35 @@ By default, cml will use some math functions from the header `math.h` if it is a

## Build Options

- CML_BUILD_SHARED: (Default ON) Controls if the shared library is built
- CML_BUILD_SHARED: (Default ON) Controls if the shared library is built

```shell
$ cmake .. -DCML_BUILD_SHARED=ON
$ cmake .. -DCML_BUILD_SHARED=OFF
```

- CML_BUILD_STATIC: (Default ON) Controls if the static library is built
- CML_BUILD_STATIC: (Default ON) Controls if the static library is built

```shell
$ cmake .. -DCML_BUILD_STATIC=ON
$ cmake .. -DCML_BUILD_STATIC=OFF
```

- CML_BUILD_TESTS: (Default ON) Build the unit tests
- CML_BUILD_TESTS: (Default ON) Build the unit tests

```shell
$ cmake .. -DCML_BUILD_TESTS=ON
$ cmake .. -DCML_BUILD_TESTS=OFF
```

- CMAKE_BUILD_TYPE: (Default Release) Set this to 'Release' or 'Debug'
- CMAKE_BUILD_TYPE: (Default Release) Set this to 'Release' or 'Debug'

```shell
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
```

- CMAKE_INSTALL_PREFIX: (Default /usr/local) Allows you to specify where `make install` sends the output.
- CMAKE_INSTALL_PREFIX: (Default /usr/local) Allows you to specify where `make install` sends the output.

```shell
$ cmake .. -DCMAKE_INSTALL_PREFIX=~/cml/
Expand All @@ -133,8 +129,8 @@ $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/

## Documentation

A great way to learn how to use the library is to review the [unit tests](./test/) and [documentation](http://cml.readthedocs.io/).
A great way to learn how to use the library is to review the [unit tests](./test/), [examples](./example) and [documentation](http://cml.readthedocs.io/).

## Can I trust this math library?

A goal of the unit tests is to test each function against `CML_FLT_EPSILON` which is defined in cml.h, currently in the interval `[1e-5, 1e-7]`, depending on the mathematical precision. A number of functions do not yet have unit tests proving epsilon, but more are coming.
A goal of the unit tests is to test each function against `CML_FLT_EPSILON` and `CML_DBL_EPSILON` which are defined in cml.h, currently as `1.1920928955078125e-07` and `0.2204460492503131e-16`, respectively. A number of functions do not yet have unit tests proving epsilon, but more are coming.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.10.4
16 changes: 16 additions & 0 deletions bin/build_linux_cc_mingw64
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

pushd `pwd`

cd ..
rm -rf build
mkdir build
cd build

cmake -G "Unix Makefiles" .. -DCMAKE_INSTALL_PREFIX=../install -DCML_BUILD_STATIC=ON -DCML_BUILD_SHARED=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake
make && \
ctest && \
make install && \
cpack -G "TGZ"

popd
13 changes: 13 additions & 0 deletions bin/build_win32.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ECHO ON
PUSHD "%~dp0"

cd ..
rmdir /s /q build
mkdir build
cd build
cmake -trace --warn-unitialized --warn-unused_vars -G "NMake Makefiles" .. -DCMAKE_INSTALL_PREFIX=../install -DCML_BUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Release
nmake
ctest
cpack -G "ZIP"

POPD
8 changes: 0 additions & 8 deletions cmake/CMLFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
OPTION(CML_SINGLE_PRECISION "Use single-precision floating point values" BOOL:FALSE)
IF(CML_SINGLE_PRECISION)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCML_SINGLE_PRECISION=\"${CML_SINGLE_PRECISION}\"")
MESSAGE(STATUS "Using single-precision floating point values")
ELSE()
MESSAGE(STATUS "Using double-precision floating point values")
ENDIF()

OPTION(CML_NO_ALIASES "Use math functions aliases" BOOL:FALSE)
IF(CML_NO_ALIASES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCML_NO_ALIASES=\"${CML_NO_ALIASES}\"")
Expand Down
7 changes: 6 additions & 1 deletion cmake/CMakeBuildFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include(CheckCXXCompilerFlag)

if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC$" OR "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
SET(CMAKE_COMPILER_IS_WINDOWS 1)
endif()

if("${CMAKE_C_COMPILER}" MATCHES "clang$" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_COMPILER_IS_CLANG 1)
endif()
Expand All @@ -12,7 +16,8 @@ if(CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_CLANG)
FIND_LIBRARY(LIBM m)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wpointer-arith -Werror -Wcast-qual -Wcast-align")
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wpointer-arith -Werror -Wcast-qual -Wcast-align")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wpointer-arith -Werror -Wcast-qual")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-braces")
endif()

Expand Down
114 changes: 2 additions & 112 deletions cml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,120 +11,10 @@ SET(CML_MAIN_HEADERS
include/cml.hpp
)

SET(CML_SRCS
src/errno/error.c
src/errno/message.c
src/errno/stream.c
src/errno/strerrno.c
src/complex/trigonometric.c
src/complex/hyperbolic.c
src/complex/basic.c
src/complex/exponentiation.c
src/complex/init.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/init.c
src/easings/exponential.c
src/easings/quadratic.c
src/easings/quartic.c
src/easings/linear.c
src/easings/cubic.c
src/easings/back.c
src/easings/bounce.c
src/easings/quintic.c
src/easings/sine.c
src/easings/elastic.c
src/easings/circular.c
src/quaternion/basic.c
src/quaternion/classification.c
src/quaternion/exponentiation.c
src/quaternion/parity.c
src/quaternion/init.c
src/ieee/endian.c
src/ieee/make_rep.c
src/ieee/print.c
src/ieee/standardize.c
src/deriv/deriv.c
src/diff/diff.c
)
SOURCE_GROUP(cml FILES ${CML_SRCS})

SET(CML_TESTS_SRCS
test/main.c
)
SOURCE_GROUP(Tests FILES ${CML_TESTS_SRCS})

IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
MESSAGE(STATUS "No CMAKE_BUILD_TYPE specified, using default RELEASE")
ENDIF()
MESSAGE(STATUS "Built type is set to ${CMAKE_BUILD_TYPE}")

IF(CMAKE_COMPILER_IS_WINDOWS)
SET(CMAKE_DEBUG_POSTFIX d)
ENDIF()

INCLUDE(../cmake/CMakeBuildFlags.cmake)

SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

OPTION(CML_BUILD_STATIC "Build static library" ON)
IF(CML_BUILD_STATIC)
ADD_LIBRARY(cml_static STATIC ${CML_SRCS})
SET_TARGET_PROPERTIES(cml_static PROPERTIES LINKER_LANGUAGE C)
if(CMAKE_COMPILER_IS_GNUC)
SET_TARGET_PROPERTIES(cml_static PROPERTIES OUTPUT_NAME "cml")
endif()
list(APPEND CML_LIB_TARGET cml_static)
SET_TARGET_PROPERTIES(cml_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(APPLE)
SET_TARGET_PROPERTIES(cml_static PROPERTIES MACOSX_RPATH ON)
ENDIF()
ENDIF()


OPTION(CML_BUILD_SHARED "Build shared library" ON)
IF(CML_BUILD_SHARED)
ADD_LIBRARY(cml SHARED ${CML_SRCS})
SET_TARGET_PROPERTIES(cml PROPERTIES LINKER_LANGUAGE C)
SET_TARGET_PROPERTIES(cml PROPERTIES VERSION ${PROJECT_VERSION})
#SET_TARGET_PROPERTIES(cml PROPERTIES SOVERSION 1)
list(APPEND CML_LIB_TARGET cml)
SET_TARGET_PROPERTIES(cml PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(LINUX)
# shared library should link to libm
FIND_LIBRARY(M_LIB m)
TARGET_LINK_LIBRARIES(cml ${M_LIB})
ENDIF()
IF(APPLE)
SET_TARGET_PROPERTIES(cml PROPERTIES MACOSX_RPATH ON)
ENDIF()
#IF(CMAKE_COMPILER_IS_WINDOWS)
# SET_TARGET_PROPERTIES(cml PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
#ENDIF()
ENDIF()


IF(NOT CML_BUILD_STATIC AND NOT CML_BUILD_SHARED)
MESSAGE(FATAL_ERROR "Both shared and static libraries are disabled. Please specify one or the other or both.")
ENDIF(NOT CML_BUILD_STATIC AND NOT CML_BUILD_SHARED)

IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(LIB_SUFFIX "64")
ENDIF()
add_subdirectory(src)

INSTALL(TARGETS ${CML_LIB_TARGET}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
INSTALL(FILES ${CML_MAIN_HEADERS} DESTINATION include)
INSTALL(DIRECTORY include/cml/ DESTINATION include/cml)
INSTALL(DIRECTORY include/cml DESTINATION include)


#IF(CMAKE_COMPILER_IS_WINDOWS AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
Expand Down
18 changes: 13 additions & 5 deletions cml/include/cml.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#ifndef CML_H
#define CML_H
#ifndef _CML_H_
#define _CML_H_

#define _CML_COMMON_H_
#include <cml/_common/default.h>
#include <cml/_common/inline.h>
#include <cml/_common/machine.h>
#undef _CML_COMMON_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>

#if defined CML_NO_ALIASES || defined __CML_NO_GENERIC
Expand All @@ -15,11 +18,16 @@
#include <cml/tgmath.h>
#endif

#include <cml/block.h>
#include <cml/const.h>
#include <cml/complex.h>
#include <cml/deriv.h>
#include <cml/diff.h>
#include <cml/easings.h>
#include <cml/quaternion.h>
#include <cml/roots.h>
#include <cml/sort.h>
#include <cml/specfunc.h>
#include <cml/statistics.h>

#endif

0 comments on commit c327201

Please sign in to comment.