GithubHelp home page GithubHelp logo

mpoly's Introduction

mpoly - a simple header-only C++ polynomial root finder

Usage

There's a single polynomial class available with two functions: evaluate and find_roots

Here's an example:

// define the cubic polynomial: x^3 - 3x^2 + x + 2
auto cubic = mpoly::polynomial<double, 3>({ 1., -3., 1., 2. });

// find all roots between -10 and 10
// returns a vector containing all the roots in the interval
auto roots = cubic.find_roots(-10., 10.);

// That's it! You can double check the roots using evaluate if needed
for (double x : roots)
{
    double y = cubic.evaluate(x);
    // y should be close to zero
}

How to use the library in your project

Clean and modern CMake way

Add this piece of code in your CMake file:

find_package(mpoly REQUIRED)

target_link_library(your_target PRIVATE mpoly::mpoly)

You should be able to include mpoly.h in your code

Quick and dirty way

Just copy mpoly.h in your source tree

How fast and stable is it?

It hasn't been tested extensively but it should be fairly stable and fast if you are looking for roots inside a known interval.
If you tested it and found a bug, feel free to open an issue or a pull request, I'm happy to take a look.

Sources

mpoly's People

Contributors

meakk avatar

Watchers

 avatar  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.