Giter Site home page Giter Site logo

briangladman / mpir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wbhart/mpir

74.0 15.0 36.0 20.52 MB

Multiple Precision Integers and Rationals

License: GNU General Public License v3.0

C 35.68% Shell 0.93% C++ 7.93% Assembly 40.29% Perl 0.48% Batchfile 0.28% Makefile 0.49% M4 3.15% GDB 0.01% AngelScript 6.03% Python 1.25% C# 3.27% ActionScript 0.21%

mpir's People

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

Watchers

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

mpir's Issues

mpz_ui_pow_ui overflow

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.

Porting to AHK - Please provide example DLL usage.

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.

Errors in x86_64w/haswell/avx/and_n.asm

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

Build dll_mpir_skylake_avx in VS2022

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 ==========

mpir_config.py syntax error

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.

How do I compile with VS?

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:

unexpected in macro definition

'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.

Is there a ChangeLog?

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:

  • Are there changes not related to VC build/test files that are missing in the upstream repository?
  • Should the next version be 3.1.0 or "newer"?

Fail silently on Windows after invalid operations

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.

Invalid dll_mpir_skylake_avx.vcxproj file generated

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.

How to build DLL GMPXX?

The lib_mpir_cxx project can generate only static library of GMPXX. How to generate DLL of GMPXX?

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.