1 /***************************************************************************** 2 * * 3 * UNURAN -- Universal Non-Uniform Random number generator * 4 * * 5 ***************************************************************************** 6 * * 7 * FILE: unur_methods_source.h * 8 * * 9 * PURPOSE: * 10 * defines bitmasks to identify used method in generator objects * 11 * * 12 ***************************************************************************** 13 * * 14 * Copyright (c) 2000-2006 Wolfgang Hoermann and Josef Leydold * 15 * Department of Statistics and Mathematics, WU Wien, Austria * 16 * * 17 * This program is free software; you can redistribute it and/or modify * 18 * it under the terms of the GNU General Public License as published by * 19 * the Free Software Foundation; either version 2 of the License, or * 20 * (at your option) any later version. * 21 * * 22 * This program is distributed in the hope that it will be useful, * 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 25 * GNU General Public License for more details. * 26 * * 27 * You should have received a copy of the GNU General Public License * 28 * along with this program; if not, write to the * 29 * Free Software Foundation, Inc., * 30 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * 31 * * 32 *****************************************************************************/ 33 34 /*---------------------------------------------------------------------------*/ 35 #ifndef UNUR_METHODS_SOURCE_H_SEEN 36 #define UNUR_METHODS_SOURCE_H_SEEN 37 /*---------------------------------------------------------------------------*/ 38 39 /*****************************************************************************/ 40 /** Bitmask to indicate methods **/ 41 /*****************************************************************************/ 42 43 /*---------------------------------------------------------------------------*/ 44 /* bitmasks */ 45 46 #define UNUR_MASK_TYPE 0xff000000u /* indicate type of method */ 47 48 /* discrete distributions */ 49 #define UNUR_METH_DISCR 0x01000000u 50 51 #define UNUR_METH_DARI 0x01000001u 52 #define UNUR_METH_DAU 0x01000002u 53 #define UNUR_METH_DGT 0x01000003u 54 #define UNUR_METH_DSROU 0x01000004u 55 #define UNUR_METH_DSS 0x01000005u 56 57 /* continuous distributions */ 58 #define UNUR_METH_CONT 0x02000000u 59 60 #define UNUR_METH_AROU 0x02000100u 61 #define UNUR_METH_ARS 0x02000d00u 62 #define UNUR_METH_HINV 0x02000200u 63 #define UNUR_METH_HRB 0x02000300u 64 #define UNUR_METH_HRD 0x02000400u 65 #define UNUR_METH_HRI 0x02000500u 66 #define UNUR_METH_ITDR 0x02000800u 67 #define UNUR_METH_NINV 0x02000600u 68 #define UNUR_METH_NROU 0x02000700u 69 #define UNUR_METH_PINV 0x02001000u 70 #define UNUR_METH_SROU 0x02000900u 71 #define UNUR_METH_SSR 0x02000a00u 72 #define UNUR_METH_TABL 0x02000b00u 73 #define UNUR_METH_TDR 0x02000c00u 74 #define UNUR_METH_UNIF 0x02000e00u 75 #define UNUR_METH_UTDR 0x02000f00u 76 77 /* univariate continuous empirical distributions */ 78 #define UNUR_METH_CEMP 0x04000000u 79 80 #define UNUR_METH_EMPK 0x04001100u 81 #define UNUR_METH_EMPL 0x04001200u 82 #define UNUR_METH_HIST 0x04001300u 83 84 /* multivariate continuous distributions */ 85 #define UNUR_METH_VEC 0x08000000u 86 87 #define UNUR_METH_MVTDR 0x08010000u 88 #define UNUR_METH_VMT 0x08020000u 89 #define UNUR_METH_VNROU 0x08030000u 90 #define UNUR_METH_VAROU 0x08040000u 91 #define UNUR_METH_NORTA 0x08050000u 92 93 #define UNUR_METH_GIBBS 0x08060000u 94 #define UNUR_METH_HITRO 0x08070000u 95 #define UNUR_METH_BALL 0x08080000u 96 #define UNUR_METH_WALK 0x08090000u 97 98 /* multivariate continuous empirical distributions */ 99 #define UNUR_METH_CVEMP 0x10000000u 100 101 #define UNUR_METH_VEMPK 0x10010000u 102 103 /* random matrices */ 104 #define UNUR_METH_MAT 0x20000000u 105 106 #define UNUR_METH_MCORR 0x20010000u 107 108 /* generators for standard distributions */ 109 #define UNUR_METH_CSTD 0x0200f100u /* is of type UNUR_METH_CONT !! */ 110 #define UNUR_METH_DSTD 0x0100f200u /* is of type UNUR_METH_DISCR !! */ 111 #define UNUR_METH_MVSTD 0x0800f300u /* is of type UNUR_METH_CVEC !! */ 112 113 /* meta distributions */ 114 #define UNUR_METH_MIXT 0x0200e100u /* univariate continuous */ 115 116 /* wrapper for external generators */ 117 #define UNUR_METH_CEXT 0x0200f400u /* is of type UNUR_METH_CONT !! */ 118 #define UNUR_METH_DEXT 0x0100f500u /* is of type UNUR_METH_DISCR !! */ 119 120 /* automatically selected generator */ 121 #define UNUR_METH_AUTO 0x00a00000u /* can be any type of distribution */ 122 123 /* to indicate unknown type */ 124 #define UNUR_METH_UNKNOWN 0xff000000u 125 126 /*****************************************************************************/ 127 /** Macros **/ 128 /*****************************************************************************/ 129 130 /*---------------------------------------------------------------------------*/ 131 /* check if parameter object is of correct type, return 0 otherwise */ 132 133 #define _unur_check_par_object( par,type ) \ 134 if ( (par)->method != UNUR_METH_##type ) { \ 135 _unur_error(#type,UNUR_ERR_PAR_INVALID,""); \ 136 return (UNUR_ERR_PAR_INVALID); } \ 137 COOKIE_CHECK((par),CK_##type##_PAR,UNUR_ERR_COOKIE) 138 139 /*---------------------------------------------------------------------------*/ 140 /* check if generator object is of correct type, return 0 otherwise */ 141 142 #define _unur_check_gen_object( gen,type,rval ) \ 143 if ( (gen)->method != UNUR_METH_##type ) { \ 144 _unur_error((gen)->genid,UNUR_ERR_GEN_INVALID,""); \ 145 return rval; } \ 146 COOKIE_CHECK((gen),CK_##type##_GEN,UNUR_ERR_COOKIE) 147 148 /*---------------------------------------------------------------------------*/ 149 #endif /* UNUR_METHODS_SOURCE_H_SEEN */ 150 /*---------------------------------------------------------------------------*/ 151