diff libinterp/corefcn/rand.cc @ 29961:7d6709900da7

eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more Files affected: __betainc__.cc, __contourc__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, balance.cc, besselj.cc, bsxfun.cc, call-stack.cc, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, defaults.cc, dirfns.cc, display.cc, dlmread.cc, dmperm.cc, dot.cc, eig.cc, ellipj.cc, environment.cc, error.cc, event-manager.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, find.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, gsvd.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jsondecode.cc, jsonencode.cc, load-path.cc, load-save.cc, lookup.cc, lsode.cc, lu.cc, max.cc, mgorth.cc, oct-hist.cc, ordqz.cc, ordschur.cc, pager.cc, pr-output.cc, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, regexp.cc, schur.cc, settings.cc, sighandlers.cc, sparse.cc, spparms.cc, sqrtm.cc, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, symbfact.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-struct.cc, ov-typeinfo.cc, ov-usr-fcn.cc, octave.cc, lex.ll, oct-parse.yy, profiler.cc, andpt-eval.cc.
author John W. Eaton <jwe@octave.org>
date Sat, 14 Aug 2021 22:48:52 -0400
parents 32c3a5805893
children 91c6288781ba 796f54d4ddbf
line wrap: on
line diff
--- a/libinterp/corefcn/rand.cc	Sat Aug 14 21:50:26 2021 -0400
+++ b/libinterp/corefcn/rand.cc	Sat Aug 14 22:48:52 2021 -0400
@@ -120,13 +120,13 @@
   dim_vector dims;
 
   // Restore current distribution on any exit.
-  octave::unwind_action restore_distribution
+  unwind_action restore_distribution
     ([] (const std::string& old_distribution)
      {
-       octave::rand::distribution (old_distribution);
-     }, octave::rand::distribution ());
+       rand::distribution (old_distribution);
+     }, rand::distribution ());
 
-  octave::rand::distribution (distribution);
+  rand::distribution (distribution);
 
   switch (nargin)
     {
@@ -155,21 +155,21 @@
             std::string s_arg = tmp.string_value ();
 
             if (s_arg == "dist")
-              retval = octave::rand::distribution ();
+              retval = rand::distribution ();
             else if (s_arg == "seed")
-              retval = octave::rand::seed ();
+              retval = rand::seed ();
             else if (s_arg == "state" || s_arg == "twister")
-              retval = octave::rand::state (fcn);
+              retval = rand::state (fcn);
             else if (s_arg == "uniform")
-              octave::rand::uniform_distribution ();
+              rand::uniform_distribution ();
             else if (s_arg == "normal")
-              octave::rand::normal_distribution ();
+              rand::normal_distribution ();
             else if (s_arg == "exponential")
-              octave::rand::exponential_distribution ();
+              rand::exponential_distribution ();
             else if (s_arg == "poisson")
-              octave::rand::poisson_distribution ();
+              rand::poisson_distribution ();
             else if (s_arg == "gamma")
-              octave::rand::gamma_distribution ();
+              rand::gamma_distribution ();
             else
               error ("%s: unrecognized string argument", fcn);
           }
@@ -185,7 +185,7 @@
           }
         else if (tmp.is_range ())
           {
-            octave::range<double> r = tmp.range_value ();
+            range<double> r = tmp.range_value ();
 
             if (! r.all_elements_are_ints ())
               error ("%s: all elements of range must be integers", fcn);
@@ -194,8 +194,8 @@
 
             dims.resize (n);
 
-            octave_idx_type base = octave::math::nint_big (r.base ());
-            octave_idx_type incr = octave::math::nint_big (r.increment ());
+            octave_idx_type base = math::nint_big (r.base ());
+            octave_idx_type incr = math::nint_big (r.increment ());
 
             for (octave_idx_type i = 0; i < n; i++)
               {
@@ -214,7 +214,7 @@
               {
                 iv = tmp.octave_idx_type_vector_value (true);
               }
-            catch (octave::execution_exception& ee)
+            catch (execution_exception& ee)
               {
                 error (ee, "%s: dimensions must be a scalar or array of integers", fcn);
               }
@@ -251,11 +251,11 @@
                   {
                     double d = args(idx+1).double_value ();
 
-                    octave::rand::seed (d);
+                    rand::seed (d);
                   }
                 else if (args(idx+1).is_string ()
                          && args(idx+1).string_value () == "reset")
-                  octave::rand::reset ();
+                  rand::reset ();
                 else
                   error ("%s: seed must be a real scalar", fcn);
               }
@@ -263,7 +263,7 @@
               {
                 if (args(idx+1).is_string ()
                     && args(idx+1).string_value () == "reset")
-                  octave::rand::reset (fcn);
+                  rand::reset (fcn);
                 else
                   {
                     ColumnVector s
@@ -272,10 +272,10 @@
                     // Backwards compatibility with previous versions of
                     // Octave which mapped Inf to 0.
                     for (octave_idx_type i = 0; i < s.numel (); i++)
-                      if (octave::math::isinf (s.xelem (i)))
+                      if (math::isinf (s.xelem (i)))
                         s.xelem (i) = 0.0;
 
-                    octave::rand::state (s, fcn);
+                    rand::state (s, fcn);
                   }
               }
             else
@@ -311,7 +311,7 @@
       if (additional_arg)
         {
           if (a.numel () == 1)
-            return octave::rand::float_nd_array (dims, a(0));
+            return rand::float_nd_array (dims, a(0));
           else
             {
               if (a.dims () != dims)
@@ -322,20 +322,20 @@
               float *v = m.fortran_vec ();
 
               for (octave_idx_type i = 0; i < len; i++)
-                v[i] = octave::rand::float_scalar (a(i));
+                v[i] = rand::float_scalar (a(i));
 
               return m;
             }
         }
       else
-        return octave::rand::float_nd_array (dims);
+        return rand::float_nd_array (dims);
     }
   else
     {
       if (additional_arg)
         {
           if (a.numel () == 1)
-            return octave::rand::nd_array (dims, a(0));
+            return rand::nd_array (dims, a(0));
           else
             {
               if (a.dims () != dims)
@@ -346,13 +346,13 @@
               double *v = m.fortran_vec ();
 
               for (octave_idx_type i = 0; i < len; i++)
-                v[i] = octave::rand::scalar (a(i));
+                v[i] = rand::scalar (a(i));
 
               return m;
             }
         }
       else
-        return octave::rand::nd_array (dims);
+        return rand::nd_array (dims);
     }
 }
 
@@ -547,7 +547,7 @@
 %!error <dimensions must be .* array of integers> rand ([1, 1.1])
 */
 
-static std::string current_distribution = octave::rand::distribution ();
+static std::string current_distribution = rand::distribution ();
 
 DEFUN (randn, args, ,
        doc: /* -*- texinfo -*-
@@ -1140,7 +1140,7 @@
   bool short_shuffle = m < n/5;
 
   // Generate random numbers.
-  NDArray r = octave::rand::nd_array (dim_vector (1, m));
+  NDArray r = rand::nd_array (dim_vector (1, m));
   double *rvec = r.fortran_vec ();
 
   octave_idx_type idx_len = (short_shuffle ? m : n);
@@ -1204,8 +1204,8 @@
   if (m < n)
     idx.resize (dim_vector (1, m));
 
-  // Now create an array object with a cached octave::idx_vector.
-  return ovl (new octave_matrix (r, octave::idx_vector (idx)));
+  // Now create an array object with a cached idx_vector.
+  return ovl (new octave_matrix (r, idx_vector (idx)));
 }
 
 /*