- Main Page
- Modules
- Data Structures
- Files

# misc.h

    00001 /*************************************************************************
    00002  *                                                                       *
    00003  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.       *
    00004  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
    00005  *                                                                       *
    00006  * This library is free software; you can redistribute it and/or         *
    00007  * modify it under the terms of EITHER:                                  *
    00008  *   (1) The GNU Lesser General Public License as published by the Free  *
    00009  *       Software Foundation; either version 2.1 of the License, or (at  *
    00010  *       your option) any later version. The text of the GNU Lesser      *
    00011  *       General Public License is included with this library in the     *
    00012  *       file LICENSE.TXT.                                               *
    00013  *   (2) The BSD-style license that is included with this library in     *
    00014  *       the file LICENSE-BSD.TXT.                                       *
    00015  *                                                                       *
    00016  * This library is distributed in the hope that it will be useful,       *
    00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
    00019  * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
    00020  *                                                                       *
    00021  *************************************************************************/
    00022
    00023 /* miscellaneous math functions. these are mostly useful for testing */
    00024
    00025 #ifndef _ODE_MISC_H_
    00026 #define _ODE_MISC_H_
    00027
    00028 #include <ode/common.h>
    00029
    00030
    00031 #ifdef __cplusplus
    00032 extern "C" {
    00033 #endif
    00034
    00035
    00036 /* return 1 if the random number generator is working. */
    00037 ODE_API int dTestRand(void);
    00038
    00039 /* return next 32 bit random number. this uses a not-very-random linear
    00040  * congruential method.
    00041  */
    00042 ODE_API unsigned long dRand(void);
    00043
    00044 /* get and set the current random number seed. */
    00045 ODE_API unsigned long  dRandGetSeed(void);
    00046 ODE_API void dRandSetSeed (unsigned long s);
    00047
    00048 /* return a random integer between 0..n-1. the distribution will get worse
    00049  * as n approaches 2^32.
    00050  */
    00051 ODE_API int dRandInt (int n);
    00052
    00053 /* return a random real number between 0..1 */
    00054 ODE_API dReal dRandReal(void);
    00055
    00056 /* print out a matrix */
    00057 #ifdef __cplusplus
    00058 ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt = "%10.4f ",
    00059          FILE *f=stdout);
    00060 #else
    00061 ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt, FILE *f);
    00062 #endif
    00063
    00064 /* make a random vector with entries between +/- range. A has n elements. */
    00065 ODE_API void dMakeRandomVector (dReal *A, int n, dReal range);
    00066
    00067 /* make a random matrix with entries between +/- range. A has size n*m. */
    00068 ODE_API void dMakeRandomMatrix (dReal *A, int n, int m, dReal range);
    00069
    00070 /* clear the upper triangle of a square matrix */
    00071 ODE_API void dClearUpperTriangle (dReal *A, int n);
    00072
    00073 /* return the maximum element difference between the two n*m matrices */
    00074 ODE_API dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m);
    00075
    00076 /* return the maximum element difference between the lower triangle of two
    00077  * n*n matrices */
    00078 ODE_API dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n);
    00079
    00080
    00081 #ifdef __cplusplus
    00082 }
    00083 #endif
    00084
    00085 #endif