Coder Social home page Coder Social logo

szymonmaszke / numpp Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 1.0 963 KB

Research library for compile time optimization

License: MIT License

C++ 95.73% Makefile 1.54% Python 2.59% Shell 0.10% Dockerfile 0.04%
cpp numerical-methods numerical-optimization numerical-library compilation compile-time cpp17 research-project research-paper research

numpp's Introduction

numpp

Build Docker image Style
Build Status Docker Status Codacy Badge

numpp is an open source, template only, numerical library aimed at maximizing runtime efficiency by performing every calculation during the compilation step.

Currently it consists of:

  • three differentiation ways (symbolic, automatic, finite difference),
  • linear algebra structures (matrix dense, sparse, vector)
  • root finding methods (bisection, newton, halley)
  • krylov subspace methods (conjugate gradient, preconditioned conjugate gradient)

It trims the runtime by using cutting edge C++17 features, template metaprogramming, numerical ideas seen in recent numerical research papers and many others.

Usage Example:

1. Differentiating cos(x1)*sin(x2) two times with respect to x1 and y2.

#include"numpp/differentiation/symbolic.hpp"
namespace nds = numpp::differentiation::symbolic; //Removes redundant namespace

using Function = decltype(cos(nds::x<0>{})*sin(nds::x<1>{})); //Create function type
using Derivative = differentiate<Function, 2>::with_respect_to<0,1>; //Differentiate type

int main(){
  std::cout << Derivative::calculate(std::array<double, 2>{3, 5}; //Evaluate derivative at point x1 = 3, x2 = 5
  return 0;
}

How does it compare?

1. Most promising module

Best looking part is, without a doubt, symbolic differentiation.

Thanks to researchers from this paper and some improvements of mine, it seems, that it can achieve around 10x speedup or more in derivative evaluations against SymPy which approaches efficiency of hand-coded derivatives. When it comes to memory it should use 0b as it's only type based.

For thorough compilation times comparison, I urge you to check their scientific paper!

Credits for the squeezer idea and being first to publish it go to academics mentioned above.

2. Overall Runtime speedup

30 x speedups in matrix multiplication is not uncommon (compared to Eigen), and binaries created are shorter by about the same amount. In other areas, for example numerical differentiation, speed up over GNU Scientific Library can exceed 50x.

3. Compilation times

I'm not going to lie, this is the place, where some modules loses to the competition. In the case of matrix multiplication, memory bandwith and lack of parallelism during compilation may slow the matrix operations even by a few seconds.

Installation:

1. Normal installation

Just clone this repository into your /usr/include/ path or other performing the same functionality. It needs GCC7.0 or more for it to work. It should work for Clang as well, but it wasn't thoroughly tests

2. Dockerized installation

If your distro doesn't have GCC7.0 just run the Docker image provided in the banner at the top via command:

$ docker run -i -t vyzyv/numpp:latest /bin/bash

to enter the container, which has everything you need to run your applications based on numpp.

Documentation:

For more specific informations about what the library has to offer check below:

Documentation

For in-depth dissertation of provided functionality check the paper below and others linked inside:

Contributions:

Currently looking for contributors with interesting numerical ideas and all those willing to perform additional testing, expand documentation or implement their/someones (with permission and credits)

numpp's People

Contributors

codacy-badger avatar lklemens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

isuruf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.