Path: utzoo!attcan!uunet!timbuk!sumac02!tbb From: tbb@sumac02.cray.com (Todd Blachowiak) Newsgroups: comp.lang.fortran Subject: Re: Random Number Functions--Generate versus Input Message-ID: <140719.13816@timbuk.cray.com> Date: 12 Nov 90 20:51:50 GMT References: <1990Nov8.170334.24579@athena.mit.edu> <1990Nov8.215752.7075@athena.mit.edu> Reply-To: tbb@sumac02.cray.com (Todd Blachowiak) Organization: Cray Research, Inc. Lines: 35 In article <1990Nov8.215752.7075@athena.mit.edu>, oliver@athena.mit.edu (James D. Oliver III) writes: |> I guess I need to make this clear: the random number genertor itself is |> vectorizable, however, the values of interest to me are *functions* of |> these randome variables. To be more specific, I'm generating a series of |> randomly oriented 3-D unit vectors. The fastest way to do this is to |> generate two random numbers for x and y and calculate z as long as x**2 + |> y**2 <= 1. This process, however, involves a conditional loop back to the |> ranf() function and thus is not vectorizable. However, the fact that this |> method is not vectorizable is just of incidental interest, since it remains |> the fastest way of doing it. would something like this work for you. x(i) = ranf() y(i) = (1-x(i)*x(i))*ranf() z(i) = 1-x(i)*x(i)-y(i)*y(i) I believe this would vectorize for you and it gets rid of your conditional. Also, you do not have to make any wasted calls to the random number generator. |> |> What I'd like to know is, *given* this way of generating my values, should |> I expect it to be faster than reading the values from a file? Like I said, |> for this particular case I can run a benchmark, but I was wondering if |> there was a general rule of thumb for the speed of I/O operations. |> |> |> -- |> ____________________________ |> Jim Oliver |> oliver@athena.mit.edu / joliver@hstbme.mit.edu |> oliver%mitwccf.BITNET@MITVMA.MIT.EDU -- Todd Blachowiak tbb@cray.com