maandree / libzahl Goto Github PK
View Code? Open in Web Editor NEWSuckless big integer library
Home Page: http://libs.suckless.org/libzahl
License: ISC License
Suckless big integer library
Home Page: http://libs.suckless.org/libzahl
License: ISC License
C++ doesn't support register
and restrict
.
To fix this we can use macros to only activate these keywordsin C mode and not in C++ mode.
I have a commit ready to fix this. Do you accept pull requests here on github ? Or on suckless.org ?
You may be able (probably unlikely) to sip a little more performance if you replace the logical operator in the following (from libzahl/zahl/inlines.h) with a bitwise operator. If you decide to change zzero(), there are other candidates in inlines.h worth reviewing.
ZAHL_INLINE int zzero(z_t a) { return !a->sign; }
... {return a->sign & 0;}
But, I haven't looked at the assembler code.
I wonder how fast would it be to use fractions with high(er) number of places with libzahl
as "backend" compared to using plain mpdecimal
for precise calculations.
In other words, first find out how to set precision of the fractions to match the precision of mpdecimal and then benchmark some real-world (or at least artifiicial) scenarios for speed.
What would be your guess to be faster?
Can you provide rationale on your choices of likely() and unlikely()?
void
zsub_nonnegative_assign(z_t a, z_t b)
{
if (unlikely(zzero(b)))
zabs(a, a);
else if (unlikely(!zcmpmag(a, b)))
SET_SIGNUM(a, 0);
else
zsub_impl(a, b, b->used);
}
What if I issue zsub_nonnegative_assign(x, "0") in an iterative process? In this example, the unlikely is very, very, very unlikely (zzero(0) is not just likely, but totally likely). (I see that zsub_nonnegative_assign() may be removed.) How do these branch predictions behave if they are more likely to be incorrect than correct for certain use cases? Perhaps you could allow the user of the library a choice on the use of likely()/unlikely().
Please initialize i.
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.