GithubHelp home page GithubHelp logo

Support for rust_decimal about smartcore HOT 2 OPEN

smartcorelib avatar smartcorelib commented on August 29, 2024
Support for rust_decimal

from smartcore.

Comments (2)

VolodymyrOrlov avatar VolodymyrOrlov commented on August 29, 2024

The trait math::num::RealNumber is largely based on num-traits Float. This is the biggest obstacle in bringing rust_decimal:: Decimal into Smartcore so far, but it is possible if you are willing to refactor Smartcore's code a bit.

Take a look at https://github.com/smartcorelib/smartcore/blob/development/src/math/num.rs#L13. All you need to bring a new numerical type into Smartcore is to make sure this type implements num_traits::float::Float and a handful of additional functions defined in Smartcore.

One way you can do it is by working together with the author of rust_decimal, Paul Mason, to see whether is it possible to add implementation of num_traits::float::Float for rust_decimal::Decimal. Please note that you won't be able to keep implementation of num_traits::float::Float for rust_decimal::Decimal in Smartcore since Rust won't let you implement a trait on a type if both the trait and the type are not local to the crate.

Anther possibility is to refactor Smartcore's code and get rid of Float in the signature of math::num::RealNumber by moving all the methods we need from Float directly into the trait.

I would start from reaching out to Paul to discuss possibility of extending rust_decimal::Decimal with implementation of Float. If it is not possible I would consider refactoring Smartcore.

from smartcore.

julama avatar julama commented on August 29, 2024

Sounds like a good plan. Thanks for the explanations!

from smartcore.

Related Issues (20)

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.