polynomials 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/core_ext/math.rb CHANGED
@@ -40,7 +40,7 @@ module Math
40
40
  denom = (p/2.0)**2 - q
41
41
  return Set[] if denom < 0
42
42
  root = Math.sqrt(denom)
43
- Set.new([:+,:-].map{ |operator| (-(p/2.0)).send(operator, root)})
43
+ Set.new([:+,:-].map{ |operator| (-(p/2.0)).send(operator, root)}.map { |n| n.round(10) })
44
44
  end
45
45
 
46
46
  def self.roots_of_quartic_function(*args)
data/lib/polynomials.rb CHANGED
@@ -5,6 +5,7 @@ class Polynomial
5
5
  MinMaxMapping = { 1.0 => :max, -1.0 => :min }
6
6
  AfterExtremumsCurvatureMapping = { max: :right, min: :left }
7
7
  NegPosMinMaxExtremumMapping = {[1.0,-1.0] => :max,[-1.0,1.0] => :min}
8
+
8
9
  attr_accessor :terms
9
10
 
10
11
  def self.parse(string)
data/polynomials.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{polynomials}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Manuel Korfmann"]
data/test/math_test.rb CHANGED
@@ -16,10 +16,10 @@ class TestMath < MiniTest::Unit::TestCase
16
16
  q = -40.0/3.0
17
17
  root = Math.sqrt((p/2)**2 - q)
18
18
  fraction = -(p/2)
19
- assert_equal Set[fraction - root, fraction + root],polynomial.nulls
19
+ assert_equal Set[(fraction - root).round(10), (fraction + root).round(10)],polynomial.nulls
20
20
 
21
21
  polynomial = Polynomial.parse('3x^2 - 40')
22
- assert_equal Set[Math.sqrt(40.0/3), -Math.sqrt(40.0/3)], polynomial.nulls
22
+ assert_equal Set[Math.sqrt(40.0/3).round(10), -Math.sqrt(40.0/3).round(10)], polynomial.nulls
23
23
  end
24
24
 
25
25
  def test_nulls_for_cubic_functions
@@ -69,6 +69,6 @@ class TestPolynomial < MiniTest::Unit::TestCase
69
69
 
70
70
  def test_two_inflection_points
71
71
  polynomial = Polynomial.parse('+ 1.0 x^4 + 5.0 x^3 - 1.0 x^2 + 3.0 x + 5.0')
72
- assert_equal({left:Set[-1.0/0..-2.5649778198382918, 0.06497781983829176..1.0/0], right: Set[-2.5649778198382918..0.06497781983829176] } , polynomial.curvature_behaviour)
72
+ assert_equal({left:Set[-1.0/0..-2.5649778198, 0.0649778198..1.0/0], right: Set[-2.5649778198..0.0649778198] } , polynomial.curvature_behaviour)
73
73
  end
74
74
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'awesome_print'
2
2
  require 'minitest/autorun'
3
- require_relative '../lib/polynomial.rb'
3
+ require_relative '../lib/polynomials.rb'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Manuel Korfmann
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- hash: 1112963547142027231
133
+ hash: -894786567939167734
134
134
  segments:
135
135
  - 0
136
136
  version: "0"