Giter Site home page Giter Site logo

gsl's Introduction

D bindings for GSL (GNU Scientific Library)

This library was configured to run with GSL 2.1. See the website. At the moment all the items from the C GSL library are ported, but no specific D framework has been implemented and so the library is very much "as is" from the C library.

Basic examples

#!/usr/bin/env dub
/+ dub.json:
{
    "name": "testgsl",
    "dependencies": {"gsl": "~>0.1.8"}
}
+/

/*
*  Compile example:
*  dub run --single testgsl.d
*/

import std.range : iota, array;
import std.stdio : writeln;
import gsl.randist : gsl_ran_gaussian_pdf;
import gsl.cdf : gsl_cdf_gaussian_P;
import gsl.statistics : gsl_stats_mean, gsl_stats_variance, gsl_stats_sd, gsl_stats_absdev;

void main(){
	double[] x;
	writeln("PDF, x = 0: ", gsl_ran_gaussian_pdf(0, 1));
	writeln("CDF, x = 0: ", gsl_cdf_gaussian_P (0, 1));

	writeln("CDF, x = -1.96: ", gsl_cdf_gaussian_P (-1.96, 1));
	writeln("CDF, x = 1.96: ", gsl_cdf_gaussian_P (1.96, 1));

	double[10] some_numbers = iota(1., 11., 1.).array();
	writeln("\n", gsl_stats_mean(some_numbers.ptr, 1, some_numbers.length));
	writeln(gsl_stats_sd(some_numbers.ptr, 1, some_numbers.length));
	writeln(gsl_stats_variance(some_numbers.ptr, 1, some_numbers.length));
	writeln(gsl_stats_absdev(some_numbers.ptr, 1, some_numbers.length));
}

The library was transformed using the dstep tool.

gsl's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gsl's Issues

Wrong source path in dub package

I was unable to import modules.

In .dub/packages/gsl-0.1.7/dub.json I found that the import path is wrong as

"importPaths": [
		"source/"
	]

I corrected this by modifying the importPaths to

"importPaths": [
		"source/headers/"
	]

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.