| [221] | 1 | /***************************************************************************
 | 
|---|
 | 2 |  * blitz/randref.h      Random number generators, expression templates
 | 
|---|
 | 3 |  *                      wrapper
 | 
|---|
 | 4 |  *
 | 
|---|
 | 5 |  * $Id: randref.h,v 1.1.1.1 1999-04-09 17:58:59 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.3  1998/03/14 00:04:47  tveldhui
 | 
|---|
 | 28 |  * 0.2-alpha-05
 | 
|---|
 | 29 |  *
 | 
|---|
 | 30 |  * Revision 1.2  1997/01/24 14:42:00  tveldhui
 | 
|---|
 | 31 |  * Periodic RCS update
 | 
|---|
 | 32 |  *
 | 
|---|
 | 33 |  */
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | #ifndef BZ_RANDREF_H
 | 
|---|
 | 36 | #define BZ_RANDREF_H
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | #ifndef BZ_RANDOM_H
 | 
|---|
 | 39 |  #error <blitz/randref.h> must be included via <blitz/random.h>
 | 
|---|
 | 40 | #endif // BZ_RANDOM_H
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | BZ_NAMESPACE(blitz)
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | template<class P_distribution>
 | 
|---|
 | 45 | class _bz_VecExprRandom {
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | public:
 | 
|---|
 | 48 |     typedef _bz_typename Random<P_distribution>::T_numtype T_numtype;
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 |     _bz_VecExprRandom(Random<P_distribution>& random)
 | 
|---|
 | 51 |         : random_(random)
 | 
|---|
 | 52 |     { }
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 | #ifdef BZ_MANUAL_VECEXPR_COPY_CONSTRUCTOR
 | 
|---|
 | 55 |     _bz_VecExprRandom(_bz_VecExprRandom<P_distribution>& x)
 | 
|---|
 | 56 |         : random_(x.random_)
 | 
|---|
 | 57 |     { }
 | 
|---|
 | 58 | #endif
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 |     T_numtype operator[](unsigned) const
 | 
|---|
 | 61 |     { return random_.random(); }
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 |     T_numtype operator()(unsigned) const
 | 
|---|
 | 64 |     { return random_.random(); }
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 |     unsigned length(unsigned recommendedLength) const
 | 
|---|
 | 67 |     { return recommendedLength; }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 |     unsigned _bz_suggestLength() const
 | 
|---|
 | 70 |     { return 0; }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 |     _bz_bool _bz_hasFastAccess() const
 | 
|---|
 | 73 |     { return 1; }
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 |     T_numtype _bz_fastAccess(unsigned) const
 | 
|---|
 | 76 |     { return random_.random(); }
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | private:
 | 
|---|
 | 79 |     _bz_VecExprRandom() { }
 | 
|---|
 | 80 | 
 | 
|---|
 | 81 |     Random<P_distribution>& random_;
 | 
|---|
 | 82 | };
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 | BZ_NAMESPACE_END
 | 
|---|
 | 85 | 
 | 
|---|
 | 86 | #endif // BZ_RANDREF_H
 | 
|---|
 | 87 | 
 | 
|---|