Probando Unas Funciones Externas Del API De GMP

Probando Unas Funciones Externas Del API De GMP
Article
Quote    Download Post  
Post Probando Unas Funciones Externas Del API De GMP 
 
Estaba probando un simple código gambas con unas funciones externas de la libreria GMP.

Library "libgmp:10.1.3"

Public Struct __mpz_struct
  _mp_alloc As Integer
  _mp_size As Integer
  _mp_d As Pointer
End Struct

' int __gmpz_init_set_str (mpz_t rop, const char *str, int base)
' Initialize rop.
Private Extern __gmpz_init_set_str(rop As __mpz_struct, st As String, base As Integer) As Integer

' void __gmpz_init (mpz_ptr x)
' Initialize x, and set its value to 0
Private Extern __gmpz_init(x As __mpz_struct)

' void __gmpz_mul (mpz_t rop, const mpz_t op1, const mpz_t op2)
' Set rop to op1 times op2.
Private Extern __gmpz_mul(rop As __mpz_struct, op1 As __mpz_struct, op2 As __mpz_struct)

' int __gmp_printf (const char *, ...)
' Accept format strings similar to the standard C printf
Private Extern __gmp_printf(ris As String, mpz_ptr As __mpz_struct, mpz_ptr As __mpz_struct, mpz_ptr As __mpz_struct) As Integer

' void __gmpz_clear (mpz_t x)
' Free the space occupied by x.
Private Extern __gmpz_clear(x As __mpz_struct)


Public Sub Main()

  Dim x, y, res As New __mpz_struct

    __gmpz_init_set_str(x, "8723169365849056", 10)
    __gmpz_init_set_str(y, "7374602239540192", 10)
    __gmpz_init(res)
    
    __gmpz_mul(res, x, y)
    
    __gmp_printf("                %Zd *\n" &
            "                %Zd\n" &
            "--------------------------------\n" &
            "%Zd\n", x, y, res)
    
' Memoriam terminando vacuam facit:
    __gmpz_clear(x)
    __gmpz_clear(y)
    __gmpz_clear(res)

End

Referencias:
https://gmplib.org/manual/


Existe tambien el Componente gb.gmp creado de los recursos de esta libreria, pero prefiero el código extremo.    
bunge-20jumping-2002



 
Last edited by vuott on Saturday, 02 April 2016, 16:31; edited 4 times in total 
vuott - Profile PM  
vuott [ Saturday, 02 April 2016, 01:38 ]


Probando Unas Funciones Externas Del API De GMP
Comments
Quote    Download Post  
Post Re: Probando Unas Funciones Externas Del API De GMP 
 
Vuott:


Uffff..... por alguna razón crei leer GIMP


No sabia que era GMP,... lo acabo de leer en https://en.wikipedia.org/wiki/GNU_M...thmetic_Library



 
jsbsan - Profile PM  
jsbsan [ Saturday, 02 April 2016, 11:36 ]
Quote    Download Post  
Post Re: Probando Unas Funciones Externas Del API De GMP 
 
juer.... tengo lectura para dias...



 
arubioc - Profile PM  
arubioc [ Saturday, 02 April 2016, 15:40 ]
Display posts from previous:    
Post new topic  Reply to topic  Page 1 of 1
 
 

Users browsing this topic: 0 Registered, 0 Hidden and 1 Guest
Registered Users: None


 


   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Design by DiDiDaDo

Generation Time: 0.1172s (PHP: -18% SQL: 118%)
SQL queries: 24 - Debug Off - GZIP Enabled