| 1 | /*************************************************************************** | 
|---|
| 2 | * blitz/randref.h      Random number generators, expression templates | 
|---|
| 3 | *                      wrapper | 
|---|
| 4 | * | 
|---|
| 5 | * $Id: randref.h,v 1.1.1.1 1999-11-26 16:37:04 ansari Exp $ | 
|---|
| 6 | * | 
|---|
| 7 | * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca> | 
|---|
| 8 | * | 
|---|
| 9 | * This program is free software; you can redistribute it and/or | 
|---|
| 10 | * modify it under the terms of the GNU General Public License | 
|---|
| 11 | * as published by the Free Software Foundation; either version 2 | 
|---|
| 12 | * of the License, or (at your option) any later version. | 
|---|
| 13 | * | 
|---|
| 14 | * This program is distributed in the hope that it will be useful, | 
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | * GNU General Public License for more details. | 
|---|
| 18 | * | 
|---|
| 19 | * Suggestions:          blitz-suggest@cybervision.com | 
|---|
| 20 | * Bugs:                 blitz-bugs@cybervision.com | 
|---|
| 21 | * | 
|---|
| 22 | * For more information, please see the Blitz++ Home Page: | 
|---|
| 23 | *    http://seurat.uwaterloo.ca/blitz/ | 
|---|
| 24 | * | 
|---|
| 25 | *************************************************************************** | 
|---|
| 26 | * $Log: not supported by cvs2svn $ | 
|---|
| 27 | * Revision 1.1.1.1  1999/04/09  17:58:59  ansari | 
|---|
| 28 | * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99 | 
|---|
| 29 | * | 
|---|
| 30 | * Revision 1.3  1998/03/14 00:04:47  tveldhui | 
|---|
| 31 | * 0.2-alpha-05 | 
|---|
| 32 | * | 
|---|
| 33 | * Revision 1.2  1997/01/24 14:42:00  tveldhui | 
|---|
| 34 | * Periodic RCS update | 
|---|
| 35 | * | 
|---|
| 36 | */ | 
|---|
| 37 |  | 
|---|
| 38 | #ifndef BZ_RANDREF_H | 
|---|
| 39 | #define BZ_RANDREF_H | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef BZ_RANDOM_H | 
|---|
| 42 | #error <blitz/randref.h> must be included via <blitz/random.h> | 
|---|
| 43 | #endif // BZ_RANDOM_H | 
|---|
| 44 |  | 
|---|
| 45 | BZ_NAMESPACE(blitz) | 
|---|
| 46 |  | 
|---|
| 47 | template<class P_distribution> | 
|---|
| 48 | class _bz_VecExprRandom { | 
|---|
| 49 |  | 
|---|
| 50 | public: | 
|---|
| 51 | typedef _bz_typename Random<P_distribution>::T_numtype T_numtype; | 
|---|
| 52 |  | 
|---|
| 53 | _bz_VecExprRandom(Random<P_distribution>& random) | 
|---|
| 54 | : random_(random) | 
|---|
| 55 | { } | 
|---|
| 56 |  | 
|---|
| 57 | #ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR | 
|---|
| 58 | _bz_VecExprRandom(_bz_VecExprRandom<P_distribution>& x) | 
|---|
| 59 | : random_(x.random_) | 
|---|
| 60 | { } | 
|---|
| 61 | #endif | 
|---|
| 62 |  | 
|---|
| 63 | T_numtype operator[](unsigned) const | 
|---|
| 64 | { return random_.random(); } | 
|---|
| 65 |  | 
|---|
| 66 | T_numtype operator()(unsigned) const | 
|---|
| 67 | { return random_.random(); } | 
|---|
| 68 |  | 
|---|
| 69 | unsigned length(unsigned recommendedLength) const | 
|---|
| 70 | { return recommendedLength; } | 
|---|
| 71 |  | 
|---|
| 72 | unsigned _bz_suggestLength() const | 
|---|
| 73 | { return 0; } | 
|---|
| 74 |  | 
|---|
| 75 | _bz_bool _bz_hasFastAccess() const | 
|---|
| 76 | { return 1; } | 
|---|
| 77 |  | 
|---|
| 78 | T_numtype _bz_fastAccess(unsigned) const | 
|---|
| 79 | { return random_.random(); } | 
|---|
| 80 |  | 
|---|
| 81 | private: | 
|---|
| 82 | _bz_VecExprRandom() { } | 
|---|
| 83 |  | 
|---|
| 84 | Random<P_distribution>& random_; | 
|---|
| 85 | }; | 
|---|
| 86 |  | 
|---|
| 87 | BZ_NAMESPACE_END | 
|---|
| 88 |  | 
|---|
| 89 | #endif // BZ_RANDREF_H | 
|---|
| 90 |  | 
|---|