function [ r, seed ] = user ( m, n, seed ) %*****************************************************************************80 % %% USER samples points in a user-specified region with given density. % % Discussion: % % This routine can be used to % % * specify an interesting initial configuration for the data, % by specifing that USER be used for initialization (INIT = 3); % % * specify the shape of the computational region, by specifying % that sample points are to be generated by this routine, % (SAMPLE = 3) and then returning sample points uniformly at random. % % * specify the distribution or density function, by specifying % that sample points are to be generated by this routine, % (SAMPLE = 3 ) and then returning sample points according to a % given probability density function. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 23 June 2005 % % Author: % % John Burkardt % % Parameters: % % Input, integer DIM_NUM, the spatial dimension. % % Input, integer N, the number of sample points desired. % % Input, integer SEED, a seed for the random number generator. % % Output, real R(DIM_NUM,N), a set of N sample values. % % Output, integer SEED, the updated seed. % % % We sample points in the unit circle uniformly. % angle(1:n) = 2.0 * pi * rand(1,n); radius(1:n) = sqrt ( rand(1,n) ); r(1,1:n) = radius(1:n) .* cos ( angle(1:n) ); r(2,1:n) = radius(1:n) .* sin ( angle(1:n) ); return end