Giter Site home page Giter Site logo

lj-mu / codipack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scicompkl/codipack

0.0 1.0 0.0 895 KB

Fast gradient evaluation in C++ based on Expression Templates.

License: GNU General Public License v3.0

Makefile 1.49% C++ 95.18% Shell 0.18% C 3.14%

codipack's Introduction

CoDiPack

CoDiPack (Code Differentiation Package) is a tool for gradient evaluation in computer programs. It supports the features:

  • Forward mode of Algorithmic Differentiation(AD)
  • Reverse mode of Algorithmic Differentiation(AD)
  • Different tape implementations
  • An AdjointMPI interface
  • External functions
  • Higher order derivatives

The design principle for CoDiPack is that it is easy to use. However, it also gives experienced AD developers the full access to all the data structures.

The Scientific Computing Group at the TU Kaiserslautern develops CoDiPack and will enhance and extend CoDiPack in the future. There is a newsletter available at [email protected]

Build Status

Usage

CoDiPack is a header only library. The only file the user needs to include is codi.hpp. The only other requirement is a c++11 compliant compiler where one usually needs to specify '--std=c++11' in the compiler arguments. CoDiPack is tested with gcc and the intel compiler.

The file codi.hpp defines the datatypes RealForward, RealReverse, RealReverseUnchecked and several others. The RealForward type implements the forward mode of AD and the RealReverse type implements the reverse mode of AD. The third type is also an implementation of the reverse mode of AD but it should only be used by experienced users. For each type there is also a type with single precession e.g. RealForwardFloat.

For further details please visit our CoDiPack web page.

Miscellaneous information

Debugging with gdb

The ActiveReal type contains the tape as a static member. GDB prints the information of these members in its default settings, which makes the output quite verbose. We recommend to disable the output of the static class members. This can be done with

set print static-members off

Intel compiler options

Because CoDiPack relies on inlining of the compiler the performance can drop if it is not done or ignored. Therefore we recomend to force inlining of CoDiPack with the option

-DCODI_UseForcedInlines 

Hello World Example

A very small and simple example for the use of the RealForward type is the code:

    #include <codi.hpp>
    #include <iostream>

    int main(int nargs, char** args) {
      codi::RealForward x = 4.0;
      x.setGradient(1.0);

      codi::RealForward y = x * x;

      std::cout << "f(4.0) = " << y << std::endl;
      std::cout << "df/dx(4.0) = " << y.getGradient() << std::endl;

      return 0;
    }

It is compiled with

  g++  -I<path to codi>/include --std=c++11 -g -o forward forward.cpp

for the gcc compiler or with

  icpc  -I<path to codi>/include --std=c++11 -g -o forward forward.cpp

for the intel compiler.

Please visit the tutorial page for further information.

codipack's People

Contributors

maxsagebaum avatar talbring avatar mmoelle1 avatar

Watchers

James Cloos avatar

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.