Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders Wenhaug committed Mar 25, 2016
2 parents 6a67f7b + 9f88cea commit 2c877c0
Show file tree
Hide file tree
Showing 234 changed files with 10,658 additions and 10,423 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ build/
*.pspline
*.poly
*.datatable

# Auxiliary, temporary and log files related to LaTeX
docs/**/*.aux
docs/**/*.log
docs/**/*.out
docs/**/*.toc
docs/**/*.gz
docs/**/*.bbl
docs/**/*.blg
docs/**/*.*~
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## Changelog

#### Version 3.0
- Removed class for polynomial regression (PolynomialRegression).
- Removed class for radial basis function approximation (RBFApproximant)
- Updated MATLAB and Python examples
- Added a new builder class for B-splines (BSpline::Builder)
- Changed default architecture to x86-64
- Added support for equidistant knot vectors (still experimental)
- Added support for selecting the number of basis functions when constructing a B-spline
- Added support for building splines with a regularization term (as an alternative to the P-spline)
- Replaced all assertions with exceptions
- Reworked MATLAB, Python, and C interfaces
- Changed to Eigen version 3.2.8
- Updated documentation

#### Version 2.0
- Automatic knot vector selection using moving average
- Added PolynomialRegression (including MatLab interface)
Expand Down
88 changes: 50 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ project(SPLINTER CXX)
cmake_minimum_required(VERSION 2.8)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)

# Read the SPLINTER version from version.txt
file(STRINGS "version.txt" VERSION)
# Read the SPLINTER version from version file
file(STRINGS "version" VERSION)

# Default configuration values
set(DEFAULT_BUILD_TYPE "Release")
set(DEFAULT_ARCH "x86")
set(DEFAULT_ARCH "x86-64")
set(DEFAULT_HEADER_INSTALL_DIRECTORY "include")
set(DEFAULT_LIBRARY_INSTALL_DIRECTORY "lib")
set(DEFAULT_EIGEN_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Eigen)
Expand All @@ -34,10 +34,17 @@ else()
endif()

# Detect compiler
string(COMPARE EQUAL "Clang" ${CMAKE_CXX_COMPILER_ID} CLANG)
string(COMPARE EQUAL "GNU" ${CMAKE_CXX_COMPILER_ID} GCC)
string(COMPARE EQUAL "Intel" ${CMAKE_CXX_COMPILER_ID} INTEL)
string(COMPARE EQUAL "MSVC" ${CMAKE_CXX_COMPILER_ID} MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CLANG 1)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CLANG 1)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GCC 1)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(INTEL 1)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(MSVC 1)
endif()

# Set build type
if(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -101,11 +108,14 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ox")

elseif(GCC OR CLANG)
# Treat warning return-type as error to avoid undefined behaviour
# when a non-void function does not return a value.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m${BITNESS} -std=c++11 -Werror=return-type")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-long-long")
# TODO: Intel flags
# Treat warning return-type as error to avoid undefined behaviour
# when a non-void function does not return a value.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m${BITNESS} -std=c++11 -Werror=return-type")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-long-long")

elseif(INTEL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m${BITNESS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
endif()

if(NOT EIGEN_DIRECTORY)
Expand All @@ -132,56 +142,54 @@ include_directories(${EIGEN_DIRECTORY})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/test)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Catch)

set(CINTERFACE_SRC_LIST
include/cinterface/cinterface.h
include/cinterface/utilities.h
src/cinterface/bspline.cpp
src/cinterface/bsplinebuilder.cpp
src/cinterface/cinterface.cpp
src/cinterface/datatable.cpp
src/cinterface/utilities.cpp
)
# These are the sources we need for compilation of the library
set(SRC_LIST
include/approximant.h
include/bsplineapproximant.h
${CINTERFACE_SRC_LIST}
include/bspline.h
include/bsplinebasis.h
include/bsplinebasis1d.h
include/cinterface.h
include/datasample.h
include/knots.h
include/bsplinebuilder.h
include/datapoint.h
include/datatable.h
include/function.h
include/definitions.h
include/linearsolvers.h
include/mykroneckerproduct.h
include/polynomialapproximant.h
include/psplineapproximant.h
include/rbfapproximant.h
include/rbfterm.h
include/serializer.h
include/utilities.h
src/bsplineapproximant.cpp
include/saveable.h
src/bspline.cpp
src/bsplinebasis.cpp
src/bsplinebasis1d.cpp
src/cinterface.cpp
src/datasample.cpp
src/knots.cpp
src/bsplinebuilder.cpp
src/datapoint.cpp
src/datatable.cpp
src/function.cpp
src/mykroneckerproduct.cpp
src/polynomialapproximant.cpp
src/psplineapproximant.cpp
src/rbfapproximant.cpp
src/serializer.cpp
src/utilities.cpp
)
set(TEST_SRC_LIST
${SRC_LIST}
test/main.cpp
test/approximation/bsplineapproximant.cpp
test/approximation/psplineapproximant.cpp
test/approximation/rbfapproximant.cpp
test/approximation/polynomialapproximant.cpp
test/approximation/bspline.cpp
test/approximation/pspline.cpp
test/general/bspline.cpp
test/general/datatable.cpp
test/general/utilities.cpp
test/serialization/datatable.cpp
test/serialization/bsplineapproximant.cpp
test/serialization/psplineapproximant.cpp
test/serialization/rbfapproximant.cpp
test/serialization/polynomialapproximant.cpp

test/serialization/bspline.cpp
test/operatoroverloads.h
test/operatoroverloads.cpp
test/testfunction.h
Expand All @@ -190,7 +198,11 @@ set(TEST_SRC_LIST
test/testfunctions.cpp
test/testingutilities.h
test/testingutilities.cpp
)
test/bsplinetestingutilities.h
test/bsplinetestingutilities.cpp
test/serialization/eigentypes.cpp
test/unit/bsplinebasis1d.cpp
test/unit/knots.cpp)

set(SHARED_LIBRARY ${PROJECT_NAME_LOWER}-${VERSION})
set(STATIC_LIBRARY ${PROJECT_NAME_LOWER}-static-${VERSION})
Expand Down Expand Up @@ -221,7 +233,7 @@ install(
# Version file (used for deducing the name of the binary when loading it)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/splinter-matlab/version ${VERSION})
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cinterface.h
FILES include/cinterface/cinterface.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/splinter-matlab/include
)
install(
Expand All @@ -244,7 +256,7 @@ install(
# Version file (used for deducing the name of the binary when loading it)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/splinter-python/version ${VERSION})
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cinterface.h
FILES include/cinterface/cinterface.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/splinter-python/include
)
install(
Expand Down
35 changes: 13 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
##SPLINTER
SPLINTER (SPLine INTERpolation) is a library for multivariate function approximation implemented in C++. The library can be used for function approximation, regression, data smoothing, and much more. Currently, the library contains the following implementations:
SPLINTER (SPLine INTERpolation) is a library for *multivariate function approximation with splines*. The library can be used for function approximation, regression, data smoothing, data reduction, and much more. Spline approximations are represented by a speedy C++ implementation of the tensor product B-spline.

1. [tensor product B-splines](http://en.wikipedia.org/wiki/B-spline),
2. [radial basis functions](http://en.wikipedia.org/wiki/Radial_basis_function), including the [thin plate spline](http://en.wikipedia.org/wiki/Thin_plate_spline), and
3. [polynomial regression](http://en.wikipedia.org/wiki/Polynomial_regression).

The coefficients in these models are computed using ordinary least squares (OLS). The name of the library, SPLINTER, originates from the tensor product B-spline implementation, which was the first of the methods to be implemented.

The B-spline may approximate any sampled multivariate function. The user may construct a linear (degree 1), quadratic (degree 2), cubic (degree 3) or higher degree B-spline that smoothes or interpolates the data. The B-spline is constructed from the samples by solving a linear system. On a modern desktop computer the practical limit on the number of samples is about 100 000 when constructing a B-spline. This translates to a practical limit of 6-7 variables. Evaluation time, however, is independent of the number of samples due to the local support property of B-splines. That is, only samples neighbouring the evaluation point affect the B-spline value. Evaluation do however scale with the degree and number of variables of the B-spline.

The user may create a penalized B-spline (P-spline) that smooths the data instead of interpolating it. The construction of a P-spline is more computationally demanding than the B-spline - a large least-square problem must be solved - bringing the practical limit on the number of samples down to about 10 000.

When sampling is expensive and/or scattered (not on a grid) a radial basis function may be utilized for function approximation. The user should expect a high computational cost for constructing and evaluating a radial basis function spline, even with a modest number of samples (up to about 1 000 samples).
The B-spline consists of piecewise polynomial basis functions, offering a high flexibility and smoothness. The B-spline can be fitted to data using ordinary least squares (OLS), possibly with regularization. The library also offers construction of penalized splines (P-splines).

![Illustration of a B-spline](assets/bspline.png)
Figure: Illustration of a cubic B-spline generated with the SPLINTER library.
Figure: Illustration of a bicubic B-spline generated with the SPLINTER library.

###Sharing
SPLINTER is the result of several years of development towards a fast and general library for multivariate function approximation. The initial intention with the library was to build splines for use in mathematical programming (nonlinear optimization). Thus, some effort has been put into functionality that supports this, e.g. Jacobian and Hessian computations for the B-spline.
SPLINTER is the result of several years of development towards a fast and general library for multivariate function approximation. The initial intention with the library was to build splines for use in mathematical programming (nonlinear optimization). Thus, some effort has been put into functionality that supports this, e.g. Jacobian and Hessian computations for the B-spline.

By making SPLINTER publicly available we hope to help anyone looking for a multivariate function approximation library. In return, we expect nothing but your suggestions, improvements, and feature requests. If you use SPLINTER in a scientific work we kindly ask you to cite it. You can cite it as shown in the bibtex entry below (remember to update the date accessed).
```
@misc{SPLINTER,
title={{SPLINTER: a library for multivariate function approximation}},
title={{SPLINTER: a library for multivariate function approximation with splines}},
author={Bjarne Grimstad and others},
howpublished={\url{http://github.com/bgrimstad/splinter}},
year={2015},
note={Accessed: 2015-05-16}
}
```
###Contributing
Everyone is welcome to use and contribute to SPLINTER. We believe that collective effort over time is the only way to create a great library: one that makes multivariate function approximation more accessible to the programming community.
Everyone is welcome to use and contribute to SPLINTER. We believe that collective effort over time is the only way to create a great library: one that makes multivariate function approximation with splines more accessible to practitioners and researchers.

The current goals with the library are:

1. To make the library more accessible by improving the interfaces and documentation
2. To improve the current code via testing
3. To implement new function approximation methods such as Kriging
2. To implement new features
3. To improve the current code via testing

The simplest way to contribute to SPLINTER is to use it and give us feedback on the experience. If you would like to contribute by coding, you can get started by picking a suitable issue from the [list of issues](https://github.com/bgrimstad/splinter/issues). The issues are labeled with the type of work (`Bug`, `Docs`, `Enhancement`, `New feature`, `Refactoring`, `Tests`) and level of difficulty (`Beginner`, `Intermediate`, `Advanced`). Some issues are also labeled as `Critical`, which means that they deserve our attention and prioritization.

Expand All @@ -45,7 +35,8 @@ A standards compliant C++11 compiler.

###Guides
* [Basic usage](docs/basic_usage.md)
* [Compilation](docs/compile.md)
* [MatLab interface](docs/MATLAB.md)
* [Python interface](docs/python.md)
* [C interface](docs/C.md)
* [C++ interface](docs/cpp_interface.md)
* [MatLab interface](docs/matlab_interface.md)
* [Python interface](docs/python_interface.md)
* [C interface](docs/c_interface.md)
* [Compilation](docs/compile.md)
Binary file added assets/bspline_degrees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bspline_regularization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 0 additions & 69 deletions docs/C.md

This file was deleted.

Loading

0 comments on commit 2c877c0

Please sign in to comment.