briangladman / mpir Goto Github PK
View Code? Open in Web Editor NEWThis project forked from wbhart/mpir
Multiple Precision Integers and Rationals
License: GNU General Public License v3.0
This project forked from wbhart/mpir
Multiple Precision Integers and Rationals
License: GNU General Public License v3.0
It is unclear if this is a known MPIR problem on Win64. It seems as if the 3rd function argument in an unsigned long rather than an mpir_ui. Hence it doesn't work as advertised on Win64.
Example code:
'
#include "stdafx.h"
#include < stdio.h >
#include "D:\MPIR\mpir.h"
typedef unsigned long long i64;
void main(){
mpz_t fermatNumber1;
mpz_init(fermatNumber1);
mpz_t fermatNumber2;
mpz_init(fermatNumber2);
mpf_t tmp;
mpf_init2(tmp, 128);
for( int F = 30; F < 34; F++ ){
i64 n = ( 0x01LL << F ); // long long int constant keeps the compiler quiet.
mpz_ui_pow_ui(fermatNumber1, 2, n);
mpz_add_ui(fermatNumber1, fermatNumber1, 1); // only now is this the Fermat Number
mpf_set_d(tmp, 2.0);
mpf_pow_ui(tmp, tmp, n);
mpz_set_f(fermatNumber2, tmp);
mpz_add_ui(fermatNumber2, fermatNumber2, 1); // only now is this the Fermat Number
printf("\n\nFERMAT NUMBER #%d has ", F);
i64 digits = mpz_sizeinbase(fermatNumber1, 2);
printf("\n\t\t(1) digits = %I64d", digits);
digits = mpz_sizeinbase(fermatNumber2, 2);
printf("\n\t\t(2) digits = %I64d", digits);
}
printf("\n\n=================== DONE =====================");
mpz_clear(fermatNumber1); mpz_clear(fermatNumber2); mpf_clear(tmp);
getchar();
}
`
( Why the GitHub "code" tags are not working correctly on all the code is another mystery!)
Example output:
FERMAT NUMBER 30 has
(1) digits = 1073741825
(2) digits = 1073741825
FERMAT NUMBER 31 has
(1) digits = 2147483649
(2) digits = 2147483649
FERMAT NUMBER 32 has
(1) digits = 2
(2) digits = 4294967297
FERMAT NUMBER 33 has
(1) digits = 2
(2) digits = 8589934593
=================== DONE =====================
( I deleted the hash symbols in front of the Fermat Number indexes because they got converted to links )
I don't imagine that it is relevant, but MPIR was compiled as a K8/K10/K102 x64 release DLL for Windows 10, running on an AMD A10-7800 Radeon R7. All the MPIR tests ran correctly. The same DLL/test code also gives the same result on a Xeon E5-1650 v4 processor.
Hello, thank you for your impressive work. I had no issues building the Visual Studio x64 Release DLL. (dll_mpir_gc)
While not entirely unfamiliar with c/c++ concepts, I am not particularly fluent in using them. Therein lies the problem.
I'm trying to wrap a few functions for use in AHK and I have to admit I'm a little mystified by the custom typedef declarations, such as mpf_t. I've been banging my head for several hours. (It looks like they might just be byte arrays? I have some experience making structs and would be willing to craft whatever's required on AHK's side if you could point me at the right place in the code.)
Anyways, I respectfully request some example C++ code utilizing the DLL version. I guess I need mpf_init_set, mpf_add, & mpf_div specifically.
I... think... I can figure the rest out from there.
Thanks in advance. I know it's a lot to randomly ask.
Hello,
I tried to compile the mpir library for haswell_avx (for Windows & VS2019) and I got 2 errors with the following file:
mpn/x86_64w/haswell/avx/and_n.asm
SizeB and CountB are undefined.
When comparing with the other architecture in:
mpn/x86_64w/broadwell/avx/and_n.asm
the following values are defined:
%define SizeB R9B
%define CountB AL
Hope this helps,
Daniel
Is there any optimized assembly for Core i9 and Xeon W CPU?
I am getting this error when I try to build it.
zero_p.c
1>Generating Code...
1>addmul_2.obj : error LNK2005: __gmpn_addmul_2 already defined in redc_2.obj
1> Creating library x64\Release\mpir.lib and object x64\Release\mpir.exp
1>x64\Release\mpir.dll : fatal error LNK1169: one or more multiply defined symbols found
1>Done building project "dll_mpir_skylake_avx.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild started at 8:30 PM and took 43.966 seconds ==========
How to compile with static CRT?
Cloned MPIR to a fresh directory.
mpir_config.py shows a syntax error when mpir_config.sln opened in VS2015 under Win10.
write_f(join(build_root_dir, f'version_info{vs_version}.py'), join(solution_dir, 'version_info.py'))
It is unclear where the extra "f" in front of the version_info came from.
Deleting the excess f and changing the hard_coded vs_version from 22 to 15 allows the config to run as expected. The tests then run and pass for a Release x64 DLL build.
I have tried to open the sln files for vs17 and vs19 but I have several issues.
Config.h and gmp-mparam.h cannot be found. I found a .bet file I think to genergate config.h but the config.h generated seems all wrong. I get errors such as:
'HAVE_NATIVE_' macro redefinition
Seems like all the macros are kinda sorta commented out?
#define HAVE_NATIVE_/* 1
#define HAVE_NATIVE_Copyright 1
Like so.
When I try to use the Command Tools prompt, I get the following error:
'\msbuild.exe' is not recognized as an internal or external command, operable program, or batch file.
'-latest' is also not recognized.
The ChangeLog file is effectively not there since the fork of GMP occured. The NEWS file has a nice user-viewable change-list - up to 3.0.0.
Is there a documentation about the user-visible changes since 3.0.0 and/or even a "real" ChangeLog (the commit history is not really useful)?
Additional:
Hi, this may be a newbie question, but how does one build with --enable-gmpcompat
option when using Visual Studio?
There's also a question on SO on this topic: https://stackoverflow.com/questions/38279880/mpir-windows-build-with-enable-gmpcompat
MPIR handles invalid operations by raising a SIGFPE
signal. On windows, this cause the program to exit silently. Visual studio will not break on such signal, even if everything in the exception settings are checked. However it will break when abort()
is called, which appears right after raise (SIGFPE)
. Since the signal already terminates the program, the abort has no chance execute, so there will be no sign of what happened.
A possible solution/workaround is to add a __debugbreak()
(int 3
instruction) before raise
when it's available.
When generating the solution and project filed under VS19 for skylake_avx a project file is generated that is not readable by VS 2019.
There are many entries of the type
and similar, which are rejected by VS having bad syntax.
The lib_mpir_cxx
project can generate only static library of GMPXX. How to generate DLL of GMPXX?
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.