Giter Club home page Giter Club logo

luajit-gmp's Introduction

Features

  • Full support of 5.1.2 API (except low-level functions)

Example code

  local gmp = require 'gmp' ('libgmp-10')

  local mpz = gmp.types.z

  local a,b = mpz(), mpz()

  gmp.z_init_set_str(a, '39679054966380032223487239670184', 10)
  gmp.z_init_set_str(b, '85186439059104575627262464195387', 10)

  gmp.z_mul(a,a,b)

  gmp.printf('Result: %Zd\n', a)

  gmp.z_clears(a,b)

Differences from the C API

Binding is so close to the original API as possible, but some things still differ.

  1. Names lost 'gmp' prefix as not needed.
  2. f_get_d_2exp, f_get_str return exp as second result.
  3. Added luasprintf, for formatted output in lua string.

TODO

  • Wrap mpz_import and mpz_export functions

luajit-gmp's People

Contributors

playermet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

noa

luajit-gmp's Issues

get_str functions leak memory

Hi,

It seems that there is a memory leak in all get_str functions.

In ffi interface there is a need to have a function which will free memory like the following:

void str_free(char *);

and for example z_get_str function instead of:

function mod.z_get_str(str, base, op)
return ffi.string(bind.__gmpz_get_str(str, base, op))
end

must be changed to

function mod.z_get_str(str, base, op)
local c_str = bind.__gmpz_get_str(str, base, op)
local s = ffi.string(c_str)
bind.str_free(c_str)
return s
end

Hope this helps. Thanks!

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.