[indent=4] uses Gsl init x:double = 5.0 res : Result expected:double = -0.17759677131433830434739701 Bessel.J0_e (x, out res) print("J0(5.0) = %.18f\n+/- %.18f\n", res.val, res.err) print("exact = %.18f\n", expected)
[indent=4] uses Gsl init print("Statistics from the classroom (10 students):\n") mean,max,min:double var data = new array of double[10] data = { 17.2, 18.1, 16.5, 19.3, 12.6, 9, 14.3, 17.1, 15.6, 6.4 } mean = Stats.mean (data, 1, data.length) Stats.minmax (out min, out max, data, 1, data.length) print("Average %g", mean) print("Minimum %g", min) print("Maximum %g", max)
using Gsl; public class FitSample { struct Data { public size_t n; public double* y; public double* sigma; } static int expb_f (Vector x, void* data, Vector f) { size_t n = ((Data*)data)->n; double* y = ((Data*)data)->y; double* sigma = ((Data*)data)->sigma; double A = x.get (0); double lambda = x.get (1); double b = x.get (2); size_t i; for (i = 0; i
using Gsl; public class MultiRootSample : Object { struct RParams { public double a; public double b; } static int rosenbrock_f (Vector x, void* params, Vector f) { double a = ((RParams*)params)->a; double b = ((RParams*)params)->b; double x0 = x.get (0); double x1 = x.get (1); double y0 = a*(1-x0); double y1 = b*(x1-x0*x0); f.set (
using Gsl; public class MonteSample : Object { static double exact = 1.3932039296856768591842462603255; static double g (double* k, size_t dim, void* params) { double A = 1.0 / (Math.PI * Math.PI * Math.PI); return A / (1.0 - Math.cos(k[0]) * Math.cos(k[1]) * Math.cos(k[2])); } static void display_results (string title, double result, double error) { stdout.printf ("%s ==================\n", title); stdout.printf ("result = % .6f\n", result);
using Gsl; public class IntegrationSample : Object { public static double f (double x, double* params) { double alpha = *params; double f = Math.log (alpha*x) / Math.sqrt(x); return f; } public static void main (string[] args) { IntegrationWorkspace w = new IntegrationWorkspace (1000); double integration_result, error; double expected = -4.0; double alpha = 1.0;
using Gsl; public class RNGSample : Object { public static void main (string[] args) { RNGType* T; RNG r; int i, n=10; RNG.env_setup (); T = (RNGType*)RNGTypes.default; r = new RNG (T); for (i=0; i<n; i++) { double u = r.uniform (); stdout.printf ("%d %.5f\n", i, u); } } }
using Gsl; public class Test : Object { public static void main (string[] args) { double[] data = new double[] { 1.0 , 1/2.0, 1/3.0, 1/4.0, 1/2.0, 1/3.0, 1/4.0, 1/5.0, 1/3.0, 1/4.0, 1/5.0, 1/6.0, 1/4.0, 1/5.0, 1/6.0, 1/7.0 }; MatrixView m = MatrixView.array (data, 4, 4); Vector
using Gsl; public class Test : Object { public static void main (string[] args) { double[] a_data = new double[] { 0.18, 0.60, 0.57, 0.96, 0.41, 0.24, 0.99, 0.58, 0.14, 0.30, 0.97, 0.66, 0.51, 0.13, 0.19, 0.85 }; double[] b_data = new double[] { 1.0, 2.0, 3.0, 4.0 }; Matrix
using Gsl; public class Test : Object { public static void main (string[] args) { Combination c; size_t i; stdout.printf("All subsets of {0,1,2,3} by size:\n"); for (i=0; i<=4; i++) { c = new Combination.with_zeros (4, i); do { stdout.printf ("{"); Combination.fprintf (stdout, c, " %u"); stdout.print