Sha256: 3c66ffb7b20bcadf33f70ecba6c21de6d70fe1c3bbf152ec5e485c3bb3cc68e2

Contents?: true

Size: 666 Bytes

Versions: 8

Compression:

Stored size: 666 Bytes

Contents

module GenerateComplex

  def self.float_arguments(number, max = 100)
    ret = Array.new(number){ |j| Array.new(2){ |i| rand(max) - rand } }
    for i in 0...(ret.size)
      case i % 4
      when 1
        ret[i].map!{ |a| -a }
      when 2, 3
        ret[i].map!{ |a| (rand > 0.5 ? -a : a) }
      end
    end
    ret
  end

  MAX_NUMBER = 1000
  
  def self.string_arguments(number)
    prec = MPFR.get_default_prec
    max = 2 ** prec
    Array.new(number) do |i|
      sign1 = ((rand > 0.5 ? '-' : ''))
      sign2 = ((rand > 0.5 ? '-' : ''))
      ["#{sign1}#{rand(MAX_NUMBER)}.#{rand(max)}", "#{sign2}#{rand(MAX_NUMBER)}.#{rand(max)}"]
    end
  end
  

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-mpc-0.0.9 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.8 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.7 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.6 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.5 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.4 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.3 spec/mpc/generate_complex_number.rb
ruby-mpc-0.0.2 spec/mpc/generate_complex_number.rb