1 /************************************************************************* 2 * D bindings for ODE * 3 * * 4 * C header port by Daniel "q66" Kolesa <quaker66@gmail.com> * 5 * * 6 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * 7 * All rights reserved. Email: russ@q12.org Web: www.q12.org * 8 * * 9 * This library is free software; you can redistribute it and/or * 10 * modify it under the terms of EITHER: * 11 * (1) The GNU Lesser General Public License as published by the Free * 12 * Software Foundation; either version 2.1 of the License, or (at * 13 * your option) any later version. The text of the GNU Lesser * 14 * General Public License is included with this library in the * 15 * file LICENSE.TXT. * 16 * (2) The BSD-style license that is included with this library in * 17 * the file LICENSE-BSD.TXT. * 18 * * 19 * This library is distributed in the hope that it will be useful, * 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * 22 * LICENSE.TXT and LICENSE-BSD.TXT for more details. * 23 * * 24 *************************************************************************/ 25 26 /* miscellaneous math functions. these are mostly useful for testing */ 27 28 module deimos.ode.misc; 29 30 private import deimos.ode.common; 31 private import core.stdc.config; 32 private import core.stdc.stdio: FILE; 33 34 extern (C): 35 nothrow: 36 37 /* return 1 if the random number generator is working. */ 38 int dTestRand(); 39 40 /* return next 32 bit random number. this uses a not-very-random linear 41 * congruential method. 42 */ 43 c_ulong dRand(); 44 45 /* get and set the current random number seed. */ 46 c_ulong dRandGetSeed(); 47 void dRandSetSeed(c_ulong s); 48 49 /* return a random integer between 0..n-1. the distribution will get worse 50 * as n approaches 2^32. 51 */ 52 int dRandInt(int n); 53 54 /* return a random real number between 0..1 */ 55 dReal dRandReal(); 56 57 /* print out a matrix */ 58 void dPrintMatrix(in dReal* A, int n, int m, char* fmt, FILE* f); 59 60 /* make a random vector with entries between +/- range. A has n elements. */ 61 void dMakeRandomVector(dReal* A, int n, dReal range); 62 63 /* make a random matrix with entries between +/- range. A has size n*m. */ 64 void dMakeRandomMatrix(dReal* A, int n, int m, dReal range); 65 66 /* clear the upper triangle of a square matrix */ 67 void dClearUpperTriangle(dReal* A, int n); 68 69 /* return the maximum element difference between the two n*m matrices */ 70 dReal dMaxDifference(in dReal* A, in dReal* B, int n, int m); 71 72 /* return the maximum element difference between the lower triangle of two 73 * n*n matrices */ 74 dReal dMaxDifferenceLowerTriangle(in dReal* A, in dReal* B, int n);