All Projects → SGSSGene → d_rive

SGSSGene / d_rive

Licence: Unlicense license
c++17 compile time math(derivation/integration)

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to d rive

zerolib-flixel
Some helper classes for HaxeFlixel that I like to use ✨
Stars: ✭ 28 (+75%)
Mutual labels:  math
matrixgl
Yet another matrix library for WebGL
Stars: ✭ 25 (+56.25%)
Mutual labels:  math
dart-more
More Dart — Literally.
Stars: ✭ 81 (+406.25%)
Mutual labels:  math
compile-time-printer
Prints values and types during compilation!
Stars: ✭ 45 (+181.25%)
Mutual labels:  compile-time
btc-bash-ng
math and bitcoin tools in gnu bc and bash
Stars: ✭ 25 (+56.25%)
Mutual labels:  math
react-native-math-view
Math view for react native! No WebView!
Stars: ✭ 49 (+206.25%)
Mutual labels:  math
livebook
Automate code & data workflows with interactive Elixir notebooks
Stars: ✭ 3,402 (+21162.5%)
Mutual labels:  math
mml-book-chinese
mml-book-chinese《Mathematics For Machine Learning》机器学习中的数学 中文版
Stars: ✭ 113 (+606.25%)
Mutual labels:  math
HLML
Auto-generated maths library for C and C++ based on HLSL/Cg
Stars: ✭ 23 (+43.75%)
Mutual labels:  math
Unchained
A fully type safe, compile time only units library.
Stars: ✭ 70 (+337.5%)
Mutual labels:  compile-time
DecFP.jl
Julia IEEE decimal floating-point via the Intel decimal-float library
Stars: ✭ 49 (+206.25%)
Mutual labels:  math
python-baseconv
Python module to convert numbers from base 10 integers to base X strings and back again.
Stars: ✭ 40 (+150%)
Mutual labels:  math
30secondchallenge
Inspired by the newspaper puzzle my wife's grandma tests me with each time I visit.
Stars: ✭ 19 (+18.75%)
Mutual labels:  math
nim-mathexpr
Tiny math expression evaluator library implemented in pure Nim
Stars: ✭ 58 (+262.5%)
Mutual labels:  math
good-reads
List of inspiring articles, blogs, tutorials and books. Tech stuff.
Stars: ✭ 14 (-12.5%)
Mutual labels:  math
kalker
Kalker/kalk is a calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
Stars: ✭ 1,237 (+7631.25%)
Mutual labels:  math
TensorFlow
Swift high-level API for TensorFlow.
Stars: ✭ 49 (+206.25%)
Mutual labels:  math
speedy-math
An application which allows user (small kids) to practice basic Mathematics operations
Stars: ✭ 28 (+75%)
Mutual labels:  math
Math
考研数学,数学一,包括高等数学、线性代数、概率统计
Stars: ✭ 300 (+1775%)
Mutual labels:  math
units
A lightweight compile-time, header-only, dimensional analysis and unit conversion library built on c++11 with no dependencies
Stars: ✭ 17 (+6.25%)
Mutual labels:  compile-time

d_rive

forthebadge forthebadge

Compile time math expressions with c++17.

  • standard math addition, subtraction, multiplication, division
  • sin, cos, pow, ln, sign, abs, max and min
  • derivation
  • integration

Check example1.cpp and exampleQuat.cpp for more exciting examples.. To try the examples use a modern compiler and compile the .cpp file g++ -std=c++17 example.cpp.

Examples

(Assume you have using namespace d_rive set)

Lets start with something simple, a constant. Constant have to be written with the _c suffix. that allows us to do everything at compile time. (f() = 5)

    auto f = 5_c;
    std::cout << f << "\n";
    std::cout << f() << "\n";

Lets define a polynomial and print the polynomial (f(x) = x² + 2x + 3)

    auto f = x<0>*x<0> + 2_c * x<0> + 3_c;
    std::cout << f << "\n";

Now lets evaluate it with 5 as x<0> (f(x) = x² + 2x + 3):

    auto f = x<0>*x<0> + 2_c * x<0> + 3_c;
    std::cout << f(5) << "\n";

Easy, right? But what if we need the derivative? (f2 = f')

    auto f2 = derive(f);
    std::cout << f2 << "\n";
    std::cout << f2(5) << "\n";

Derivative of derivates is also possible (f3 = f2')

    auto f3 = derive(f2);
    std::cout << f3 << "\n";

Integrating? (F' = f)

    auto F = integrate(f);
    std::cout << F << "\n";
    std::cout << F(5) << "\n";

Compile time roots? (sqrt(2))

    std::cout << (2_c^0.5_c) << "\n";

Multiple variables: (f(x0, x1, x2) = x0*x1 + x2)

    auto f = x<0>*x<1> + x<2>;
    std::cout << f(1, 2, 3) << "\n";
    std::cout << f << "\n";
    std::cout << derive(f, x<1>) << "\n"; // derives for x<1> instead x<0>

Lets go crazy:

    auto f = 10_c + ((3_c * x<0>) ^ (0.5_c * x<1> * x<2> - x<1>));
    std::cout << derive(f, x<0>) << "\n";
    std::cout << derive(f, x<1>) << "\n";
    std::cout << derive(f, x<2>) << "\n";
    std::cout << integrate(f, x<0>) << "\n";
    std::cout << integrate(f, x<1>) << "\n";
    std::cout << integrate(f, x<2>) << "\n";
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].