GithubHelp home page GithubHelp logo

dirichlet-numerics's Introduction

Dirichlet .NET Number Theory Library

Dirichlet is an opensource number theory library for .NET.

Much more is coming but the initial release provides high-performance 128 bit signed and unsigned data types. Who needs 128 bit integers? If 64 bit numbers are too small but BigInteger is too slow, then these data types are for you.

If you want to see the parent project that this came from, see Dirichlet.

dirichlet-numerics's People

Contributors

danzel avatar ricksladkey avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dirichlet-numerics's Issues

Asking about this paper https://arxiv.org/pdf/1206.3369.pdf

I face up with a problem (https://codeforces.com/blog/entry/93981) that use your paper (https://arxiv.org/pdf/1206.3369.pdf) and in theory I have proved it can be solved very fast (https://math.stackexchange.com/questions/4230187/faster-algorithm-for-counting-non-negative-tripplea-b-c-satisfied-a-b-c) but I failed to achieved it (https://ideone.com/yMi8tu).

Can we discuss about this interesting math problem ? Or maybe I discuss about your paper ?

And by the way, I found that in your paper there is a little mistake, would you want to hear me pointing out it ?

Port to .net standard 2.0 and nuget

will put package and distribution into one liner.
i can do that if you will give me right to repo modification.
really simplifies project files and allows build on linux-mac.

Possible bug in ConvertToFloat, ConvertToDouble

I've just had a quick look at the code and saw a possible error:

    public static float ConvertToFloat(ref UInt128 a)
    {
        if (a.s1 == 0)
            return a.s0;
        return a.s1 * (float)ulong.MaxValue + a.s0; // looks wrong, should be:
        // return a.s1 * (float)Math.Pow(2,64) + a.s0;
    }

    public static double ConvertToDouble(ref UInt128 a)
    {
        if (a.s1 == 0)
            return a.s0;
        return a.s1 * (double)ulong.MaxValue + a.s0; // same here:
        // return a.s1 * Math.Pow(2,64) + a.s0;
    }

And better extract Math.Pow to a constant.

minor bug in ProbablePrime

I think there may be a minor bug in

public static bool IsProbablePrime(ulong n)

in the Primality.cs file. I think

if ((n & 1) == 0) 
    return false;

should be

if ((n & 1) == 0)
    return (n==2);

otherwise, it will incorrectly return false for

ulong n = 2;
bool isPrime = IsProbablePrime(n);

Multiply instead of divide

    public static void Divide(out Int128 c, ref Int128 a, int b)
        {
            if (a.IsNegative)
            {
                UInt128 aneg;
                UInt128.Negate(out aneg, ref a.v);
                if (b < 0)
                    UInt128.Multiply(out c.v, ref aneg, (uint)(-b));
                else
                {
                    UInt128.Multiply(out c.v, ref aneg, (uint)b);
                    UInt128.Negate(ref c.v);
                }
            }
            else
            {
                if (b < 0)
                {
                    UInt128.Multiply(out c.v, ref a.v, (uint)(-b));
                    UInt128.Negate(ref c.v);
                }
                else
                    UInt128.Multiply(out c.v, ref a.v, (uint)b);
            }
            Debug.Assert((BigInteger)c == (BigInteger)a / (BigInteger)b);
        }

Use `in` keyword and `Unsafe` for perf

Usage of in may improve perf for 128 bit

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-generic-modifier

Custom numbers via in and Unsafe seems best option avail in C# for num (as fast as using enum wrapper hack).

https://gitlab.com/dotnet-fun/dotnet-system-numerics-algebra/blob/master/benchmarks/UnsafeRefFloat.cs

https://gitlab.com/dotnet-fun/dotnet-system-numerics-algebra/blob/master/benchmarks/UnsafeFloat.cs

Some operations may became 4x faster.

Add BDN tests.

I you will give me right. I may add BDN tests for current state of lib.

I have another options just use my work and modify there and publish onto nuget. I guess pulls will be slow option.

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.