[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #56609] rand(n) accepts non-integral (n)

From: Rik
Subject: [Octave-bug-tracker] [bug #56609] rand(n) accepts non-integral (n)
Date: Thu, 11 Jul 2019 11:22:42 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of bug #56609 (project octave):

                  Status:                    None => Confirmed              
                 Release:                   5.1.0 => dev                    


Follow-up Comment #1:

Matlab used to be quite loose about input validation and so Octave copied that
behavior for rand.  Also note that this looseness is only present when there
is a single dimension argument.  If more than one dimension is specified then
they must all be non-negative integers.  For example,

rand (1.5, 3)
error: rand: conversion of 1.5 to int64_t value failed

The code to change is in rand.cc at line 171.

else if (tmp.is_scalar_type ())
    double dval = tmp.double_value ();

    if (octave::math::isnan (dval))
      error ("%s: NaN is invalid matrix dimension", fcn);

    dims.resize (2);

    dims(0) = dims(1) = octave::math::nint_big (dval);

    goto gen_matrix;


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]