RationalNumerics icon indicating copy to clipboard operation
RationalNumerics copied to clipboard

Consolidate duplicate configuration

Open kant2002 opened this issue 3 years ago • 14 comments
trafficstars

Configuration applied both to Debug and Release, so I merge this settings. Obviously unrelated to bug, but cannot resist and not cleanup

kant2002 avatar Jul 31 '22 02:07 kant2002

Hello, no problem, would you like to work together?

c-ohle avatar Jul 31 '22 02:07 c-ohle

I already figure out the issue with drag drop. FYI: Also on RC1 you have to implement bunch of methods and properties and Pi property can be a problem for example

kant2002 avatar Jul 31 '22 04:07 kant2002

Please, whats the problem with Pi? And witch (group of) functions are missing?


public static BigRational Pi(int digits)

c-ohle avatar Jul 31 '22 10:07 c-ohle

This interface https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPoint.cs

now derives from this one https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Numerics/IFloatingPointConstants.cs

as you will see, it has Pi property. You cannot have property Pi and method Pi() in the same class.

kant2002 avatar Jul 31 '22 10:07 kant2002

Thanks, I see, so far I don't support IFoatingPoint. It wouldn't be no problem to implement something, but does it make sense for such a number type? There is no constant for this, not even a cache (but it is planned). Within calculations, even low-level, cpu.sin, cpu.tan, when pi is requested, it is calculated in real-time in the currently desired precision.

But these are the design questions I really need help with. It would be easy and quick to change everything.

c-ohle avatar Jul 31 '22 10:07 c-ohle

You cannot not implement it, or you have to implement, but make it throw NotImplementedException, that interface is part of INumber<T> so with latest preview or nightly RC1 you will hit compilation error

kant2002 avatar Jul 31 '22 10:07 kant2002

I use this as reference: https://source.dot.net/#System.Private.CoreLib/INumber.cs,0f558758e750a740 and https://source.dot.net/#System.Private.CoreLib/IFloatingPointConstants.cs,9ff158e2a0a8fb1f

There in INumber and INumberBase IFloatingPointConstants is not included. Is there a better link for pre-versions or something?

c-ohle avatar Jul 31 '22 10:07 c-ohle

I'm not sure from which version of .NET source.dot.net gets source code, but I give you source code for latest bits from main branch. That's where dev works. And that's for sure would be either in Preview 7, or in RC1. If you install RC1 from here https://github.com/dotnet/installer you will see the issue yourself. Just be prepared before release to update things.

kant2002 avatar Jul 31 '22 10:07 kant2002

Please take a look at approximate changes which would be required https://github.com/c-ohle/RationalNumerics/pull/7

kant2002 avatar Jul 31 '22 11:07 kant2002

Many thanks for the hints - I need time to check. And sorry for the CreatePixelShader bug - but would be interesting to know what graphics hardware it is, usually there is a fallback to the reference renderer.

c-ohle avatar Jul 31 '22 11:07 c-ohle

I have it, they put IFloatingPointConstants in IRootFunctions, ITrigonometricFunctions. What nonsense. Anyway, will update that it works and check in. Will think later how to create a halfway logically interface on this - this time probably with a glass of vodka.

Thanks for hardware... Maybe the mentioned further drag-drop bugs fixed - will check and let you know.

c-ohle avatar Jul 31 '22 12:07 c-ohle

My idea was rename Pi to AproximatePi, that way methods still make sense. Just an idea

kant2002 avatar Jul 31 '22 12:07 kant2002

This works too:

static BigRational IFloatingPointConstants<BigRational>.Pi => Pi(1000) // :-)

c-ohle avatar Jul 31 '22 12:07 c-ohle

Thanks again, that was all very helpful. Latest NET7 version checked in, no more conflicts. Maybe the DX11 problem is solved too.

From this morning, have you seen the last notes? These problems are definitely still in. Probably relating to issue 6976 but must somewhere else in the source and this since longer. Before I start a new issue, it will probably go faster if you continue this.

Please not wondering if BigInteger sometimes crashes. I found some old bugs are fixed. Also BigInteger bugs I reported. But there is a new issue with BigInteger and maybe mutch deeper in the system. In the tests and benchmarks, after massive calculations BigInteger calculates wrong numbers, sometimes exceptions, but it's not determined, does not depend on the numbers. Maybe they forgot a span.Clear() but two times I got exception from ArrayPool.Shared.Rent (was in threads and difficult to debug). Did not report this before I can reproduce.

c-ohle avatar Jul 31 '22 14:07 c-ohle