Git Product home page Git Product logo

postgres-cmath's Introduction

cmath

cmath is a collection of math functions defined in the ISO C programming language. All functions in <math.h>, except for long double versions (sinl(x), expl(x), etc.), are included with the prefix c_. For example, log10(x) can be called by:

SELECT c_log10(100);

c_log10(x), unlike the PostgreSQL native function log(x), does not raise error when x < 0. Instead, c_log10(x) returns NaN or -Infinity in such cases.

Another example:

SELECT c_exp(1e100);

c_exp(x), unlike the PostgreSQL native function exp(x), does not raise error when the return value is overflowing. Instead, c_exp(x) returns +Infinity in such cases.

Single precision versions of functions are also available:

SELECT c_sinf(0.1), c_cosf(0.1);

Rather newly specified functions are available:

SELECT c_erf(1), c_tgamma(5), c_nextafter(0, 'infinity');

If a function has output parameters, a tuple is returned:

SELECT * FROM c_remquo(13, 5);
/* ret_value | quo
  -----------+-----
          -2 |   3
*/

Install

PostgreSQL must be installed first.

Then

$ make && make install

will install libraries into postgres's library directory. To use it, you have to tell the postgres server to load it:

$ psql -U {super user}
sql> CREATE EXTENSION cmath;
sql> \q

Source code maintenance

The source files are generated automatically by generate_pg_cmath.py. Do not modify src/pg_cmath.c and sql/cmath.sql.in directly.

postgres-cmath's People

Contributors

joannebogart avatar

Stargazers

Jonathan Fischoff avatar Daniel Durante avatar Georgy Shelkovy avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

rekgrpth durango

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.