c-ohle / rationalnumerics Goto Github PK
View Code? Open in Web Editor NEW.NET library for rational arithmetic based on a stack machine.
License: MIT License
.NET library for rational arithmetic based on a stack machine.
License: MIT License
I noticed some values returned by arc trigonometry functions are not correct:
Asin(1) return 0 instead of 1.570796 rad (90°)
Acos(0) return 0 instead of 1.570796 rad (90°)
After upgrading to version 1.0.0.7 in the published Blazor WASM application I get this error, while in the development environment it works correctly. If I downgrade to version 1.0.0.6 it works fine.
I can't figure out why since it works in the development environment.
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Arg_TargetInvocationException
System.Reflection.TargetInvocationException: Arg_TargetInvocationException
---> System.TypeLoadException: Could not load list of method overrides due to Method not found: int System.Numerics.INumberBase1.get_Radix() at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object , Span
1 , BindingFlags )
Exception_EndOfInnerExceptionStack
at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
at System.Activator.CreateInstance(Type , Boolean , Boolean )
at System.Activator.CreateInstance(Type , Boolean )
at System.Activator.CreateInstance(Type )
at Microsoft.AspNetCore.Components.DefaultComponentActivator.CreateInstance(Type )
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider , Type )
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent(Type )
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame& , Int32 )
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& , Int32 )
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& , Int32 )
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& , Int32 )
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& , Int32 , Int32 , Int32 , Int32 )
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer , RenderBatchBuilder , Int32 , ArrayRange1 , ArrayRange
1 )
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry )
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
Hi, first of all this project is awesome!
I've been test-driving the code in F# with .NET 7.0 preview using the BigRational
NuGet package. However, it appears that explicit casting to BigInt
wasn't added to the project codebase until more recently, so I haven't been able to try out the newer changes. When is the next package expected to be released?
Alternatively, do you happen to know of a way to reference this GitHub repo using Paket? I've tried something like adding the paket add c-ole/RationalNumerics
but that didn't seem to work.
Thanks in advance for your help!
Hi, very impressive project. I was wondering if there is an implementation of the samples (fractal, tesselator, csg etc.) available that uses the new BigRat class? The code using the stack architecture full of push and pop is quite hard to read and understand.
When opening Polyhedron tab on my PC. On other laptop tab was opening fine.
System.ArgumentException: Value does not fall within the expected range.
at Test.DX11Ctrl.IDevice.CreatePixelShader(Byte* ShaderBytecode, IntPtr BytecodeLength, Void* ClassLinkage)
at Test.DX11Ctrl.apply() in c:\RationalNumerics\Test\mini3d\DX11Ctrl.cs:line 388
at Test.DX11Ctrl.DC.DrawMesh(VertexBuffer vb, IndexBuffer ib, Int32 i, Int32 n) in c:\RationalNumerics\Test\mini3d\DX11Ctrl.cs:line 1223
at Test.DX11ModelCtrl.render(DC dc, Int32 was, Group[] nodes) in c:\RationalNumerics\Test\mini3d\DX11ModelCtrl.cs:line 86
at Test.DX11ModelCtrl.OnRender(DC dc) in c:\RationalNumerics\Test\mini3d\DX11ModelCtrl.cs:line 107
at Test.DX11Ctrl.Refresh() in c:\RationalNumerics\Test\mini3d\DX11Ctrl.cs:line 147
at Test.DX11Ctrl.WndProc(Message& m) in c:\RationalNumerics\Test\mini3d\DX11Ctrl.cs:line 621
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
Not sure if you accept suggestions, but found a possible problem when reading the documentation of how works this code.
The exposed property static CPU task_cpu
would not work property on asynchronous code.
Imagine the following:
// Thread "1".
BigRational.task_cpu.push(value1);
await SomeOperation();
// Resume on thread "2".
BigRational.task_cpu.push(value2); // Pushing on a different cpu.
The problem also persists when caching the access:
// Thread "1".
CPU cpu= BigRational.task_cpu;
cpu.task_cpu.push(value1);
await SomeOperation();
// Resume on thread "2".
cpu.task_cpu.push(value2); // Pushing on cpu of thread "1" from thread "2", which is not thread safe.
Instead, the [ThreadStatic] static CPU? cpu;
field should be static AsyncLocal<CPU?> cpu = new();
. This wrapper handles all issues that may raise when suspending or resuming asynchronous code.
However, this would also slow down implemented operators in BigRational
, so I would suggest having two properties:
// Only used inside the library for the operators.
private static CPU thread_cpu_ => thread_cpu??= new();
[ThreadStatic]
private static CPU? thread_cpu_;
public static CPU task_cpu => cpu.Value ??= new();
private static AsyncLocal<CPU?> cpu;
BTW, amazing job.
How are things going on your end? Love the trajectory of this package and I hope it gets into .NET in the future!
Console.WriteLine(BigRational.Pow(BigRational.Parse("2"), BigRational.Parse("1024")).ToString("F5000").Trim('0').Trim('.').Trim(','));
output:
179769313486231590772930519088622001011118896214832765155304275349863344832230481635579222589753905511470408352693059293915016093195361235646204211316618291270358047266252361344772967473693272614986720710237742201778406260548280080727716004012369601250654400739018446628865972481023592362912353548367809468670,72419534065285259505027929807
This answer is incorrect. Right:
179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.