time | Calls | line |
---|
| | 850 | function stream = localGetSetGlobalStream(stream)
|
< 0.001 | 2 | 851 | persistent globe;
|
< 0.001 | 2 | 852 | persistent legacy;
|
< 0.001 | 2 | 853 | mlock
|
| | 854 |
|
| | 855 | % If the local handle to the global/legacy stream is empty, this is
|
| | 856 | % the first time through, so we need to create the stream. If the
|
| | 857 | % local handle is invalid, the stream must have been deleted at some
|
| | 858 | % point, so we need to get hold of the new stream that was created
|
| | 859 | % automatically underneath.
|
0.003 | 2 | 860 | if builtin('_RandStream_inLegacyMode')
|
| | 861 | if isempty(legacy) || ~isvalid(legacy)
|
| | 862 | legacy = RandStream.createLegacyStream();
|
| | 863 | end
|
| | 864 | globe = legacy;
|
< 0.001 | 2 | 865 | elseif isempty(globe) || ~isvalid(globe)
|
0.003 | 1 | 866 | globe = RandStream.createGlobalStream();
|
< 0.001 | 2 | 867 | end
|
| | 868 |
|
< 0.001 | 2 | 869 | if nargin == 0
|
< 0.001 | 1 | 870 | stream = globe;
|
< 0.001 | 1 | 871 | elseif isa(stream,'RandStream') && isvalid(stream)
|
< 0.001 | 1 | 872 | builtin('_RandStream_getset_mex','defaultstream', stream.StreamID);
|
< 0.001 | 1 | 873 | globe = stream;
|
| | 874 | else
|
| | 875 | error(message('MATLAB:RandStream:setglobalstream:InvalidInput'));
|
< 0.001 | 2 | 876 | end
|
< 0.001 | 2 | 877 | end
|
Other subfunctions in this file are not included in this listing.