congruence_solver 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/csolve_spec.rb CHANGED
@@ -1,89 +1,89 @@
1
1
  require "polynomial_interpreter"
2
2
 
3
3
  RSpec.describe PolynomialInterpreter do
4
- describe "::read_congruence" do
5
- context "when input contains no '\='" do
6
- it "raises an ArgumentError" do
7
- not_congruence = "x^2 (mod 5)"
8
- expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
9
- end
10
- end
4
+ describe "::read_congruence" do
5
+ context "when input contains no '\='" do
6
+ it "raises an ArgumentError" do
7
+ not_congruence = "x^2 (mod 5)"
8
+ expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
9
+ end
10
+ end
11
11
 
12
- context "when input contains no mod" do
13
- it "raises an ArgumentError" do
14
- not_congruence = "x^2 = 3"
15
- expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
16
- end
17
- end
12
+ context "when input contains no mod" do
13
+ it "raises an ArgumentError" do
14
+ not_congruence = "x^2 = 3"
15
+ expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
16
+ end
17
+ end
18
18
 
19
- context "when input contains an invalid mod" do
20
- it "raises an ArgumentError" do
21
- not_congruence = "x = 5 (mod)"
22
- expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
23
- end
24
- end
19
+ context "when input contains an invalid mod" do
20
+ it "raises an ArgumentError" do
21
+ not_congruence = "x = 5 (mod)"
22
+ expect {PolynomialInterpreter.read_congruence not_congruence}.to raise_error ArgumentError, "congruence invalid"
23
+ end
24
+ end
25
25
 
26
- context "when lhs is empty" do
27
- it "raises an ArgumentError" do
28
- congruence = "= 3 (mod 4)"
29
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
30
- end
31
- end
26
+ context "when lhs is empty" do
27
+ it "raises an ArgumentError" do
28
+ congruence = "= 3 (mod 4)"
29
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
30
+ end
31
+ end
32
32
 
33
- context "when lhs contains invalid characters" do
34
- it "raises an ArgumentError" do
35
- congruence = "x! = 3 (mod 5)"
36
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
37
- end
38
- end
33
+ context "when lhs contains invalid characters" do
34
+ it "raises an ArgumentError" do
35
+ congruence = "x! = 3 (mod 5)"
36
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
37
+ end
38
+ end
39
39
 
40
- context "when lhs contains more than one distinct variables" do
41
- it "raises an ArgumentError" do
42
- congruence = "x^2 + y = 0 (mod 6)"
43
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
44
- end
45
- end
40
+ context "when lhs contains more than one distinct variables" do
41
+ it "raises an ArgumentError" do
42
+ congruence = "x^2 + y = 0 (mod 6)"
43
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
44
+ end
45
+ end
46
46
 
47
- context "when lhs contains negative power" do
48
- it "raises an ArgumentError" do
49
- congruence = "x^-1 = 2 (mod 35)"
50
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
51
- end
52
- end
47
+ context "when lhs contains negative power" do
48
+ it "raises an ArgumentError" do
49
+ congruence = "x^-1 = 2 (mod 35)"
50
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "lhs polynomial invalid"
51
+ end
52
+ end
53
53
 
54
- context "when rhs is empty" do
55
- it "raises an ArgumentError" do
56
- congruence = "x^3 = (mod 4)"
57
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
58
- end
59
- end
54
+ context "when rhs is empty" do
55
+ it "raises an ArgumentError" do
56
+ congruence = "x^3 = (mod 4)"
57
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
58
+ end
59
+ end
60
60
 
61
- context "when rhs contains invalid characters" do
62
- it "raises an ArgumentError" do
63
- congruence = "3 = x! (mod 5)"
64
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
65
- end
66
- end
61
+ context "when rhs contains invalid characters" do
62
+ it "raises an ArgumentError" do
63
+ congruence = "3 = x! (mod 5)"
64
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
65
+ end
66
+ end
67
67
 
68
- context "when rhs contains more than one distinct variables" do
69
- it "raises an ArgumentError" do
70
- congruence = "0 = x^2 + y (mod 6)"
71
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
72
- end
73
- end
68
+ context "when rhs contains more than one distinct variables" do
69
+ it "raises an ArgumentError" do
70
+ congruence = "0 = x^2 + y (mod 6)"
71
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
72
+ end
73
+ end
74
74
 
75
- context "when rhs contains negative power" do
76
- it "raises an ArgumentError" do
77
- congruence = "2 = x^-1 (mod 35)"
78
- expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
79
- end
80
- end
75
+ context "when rhs contains negative power" do
76
+ it "raises an ArgumentError" do
77
+ congruence = "2 = x^-1 (mod 35)"
78
+ expect {PolynomialInterpreter.read_congruence congruence}.to raise_error ArgumentError, "rhs polynomial invalid"
79
+ end
80
+ end
81
81
 
82
- context "when input is a valid polynomial congruence" do
83
- it "formats congruence as a single polynomial congruent to 0" do
84
- congruence = "45x^5 + 5 + 3x ^6 + 5x^2 + x + 3x^5=x^9 + 9 x (mod 16)"
85
- expect( PolynomialInterpreter.read_congruence(congruence)).to eq [[-1, 0, 0, 3, 48, 0, 0, 5, -8, 5].reverse, 16]
86
- end
87
- end
88
- end
82
+ context "when input is a valid polynomial congruence" do
83
+ it "formats congruence as a single polynomial congruent to 0" do
84
+ congruence = "45x^5 + 5 + 3x ^6 + 5x^2 + x + 3x^5=x^9 + 9 x (mod 16)"
85
+ expect( PolynomialInterpreter.read_congruence(congruence)).to eq [[-1, 0, 0, 3, 48, 0, 0, 5, -8, 5].reverse, 16]
86
+ end
87
+ end
88
+ end
89
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: congruence_solver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: os
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
69
83
  description: "Provides a class (CongruenceSolver) for finding the modular zeros of
70
84
  a \n polynomial (given the coefficients and modulus) and
71
85
  a binary (csolve) to \n to solve your congruences at the
@@ -83,6 +97,7 @@ files:
83
97
  - ".gitmodules"
84
98
  - ".rspec"
85
99
  - ".travis.yml"
100
+ - Gemfile
86
101
  - README.md
87
102
  - Rakefile
88
103
  - bench/bench_tools.rb
@@ -131,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
146
  version: '0'
132
147
  requirements: []
133
148
  rubyforge_project:
134
- rubygems_version: 2.4.5
149
+ rubygems_version: 2.6.7
135
150
  signing_key:
136
151
  specification_version: 4
137
152
  summary: A gem for solving polynomial congruences.