ragni-cas 0.1.8 → 0.1.9
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/fnc-base.rb +9 -0
- data/lib/numbers.rb +30 -2
- data/lib/op.rb +39 -8
- data/lib/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c547aa2096182c55e8674b72843393f874aa2bd7
|
4
|
+
data.tar.gz: 61985208f2af48b036567375eef62357e814d052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fd2a091cc81766464510764b0d3bc9b61d2c9fa8d4664cb4234865e8a93aa209ce82bae39e73025579b596dda950889e49d866e88c8c7488b86d9bf2dd6ba65
|
7
|
+
data.tar.gz: 118fb72362a2c40eb1330a8f8dbe24f85d90d2915e9ebff0700becb0f521fd3b7479d54e7eaf1efc4c9882c71be7e12917075e7066ff61e6bdbaebdb19e3bbc8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/fnc-base.rb
CHANGED
@@ -48,6 +48,9 @@ module CAS
|
|
48
48
|
if @x == -@y or -@x == @y
|
49
49
|
return CAS::Zero
|
50
50
|
end
|
51
|
+
if @y.is_a? CAS::Invert
|
52
|
+
return (@x - @y.x)
|
53
|
+
end
|
51
54
|
if @x.is_a? CAS::Constant and @y.is_a? CAS::Constant
|
52
55
|
return CAS.const(self.call({}))
|
53
56
|
end
|
@@ -113,6 +116,12 @@ module CAS
|
|
113
116
|
if @x.is_a? CAS::Constant and @y.is_a? CAS::Constant
|
114
117
|
return CAS.const(self.call({}))
|
115
118
|
end
|
119
|
+
if @y.is_a? CAS::Invert
|
120
|
+
return @x + @y.x
|
121
|
+
end
|
122
|
+
if @x.is_a? CAS::Invert
|
123
|
+
return -(@x.x + @y)
|
124
|
+
end
|
116
125
|
return self
|
117
126
|
end
|
118
127
|
|
data/lib/numbers.rb
CHANGED
@@ -30,6 +30,20 @@ module CAS
|
|
30
30
|
"#{@x}"
|
31
31
|
end
|
32
32
|
|
33
|
+
# Subs for a constant is a dummy method
|
34
|
+
def subs(dt)
|
35
|
+
# CAS::Help.assert(dt, Hash)
|
36
|
+
# if dt.keys.include? self
|
37
|
+
# if dt[self].is_a? CAS::Op
|
38
|
+
# return dt[self]
|
39
|
+
# elsif dt[self].is_a? Numeric
|
40
|
+
# return CAS::const(dt[self])
|
41
|
+
# else
|
42
|
+
# raise CASError, "Impossible subs. Received a #{dt[self].class} = #{dt[self]}"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
end
|
46
|
+
|
33
47
|
# Same as `CAS::Op`
|
34
48
|
def simplify
|
35
49
|
case @x
|
@@ -55,7 +69,7 @@ module CAS
|
|
55
69
|
|
56
70
|
# Same as `CAS::Op`
|
57
71
|
def ==(op)
|
58
|
-
CAS::Help.assert(op, CAS::Op)
|
72
|
+
# CAS::Help.assert(op, CAS::Op)
|
59
73
|
|
60
74
|
if op.is_a? CAS::Constant
|
61
75
|
return @x == op.x
|
@@ -156,7 +170,7 @@ module CAS
|
|
156
170
|
|
157
171
|
# Same as `CAS::Op`
|
158
172
|
def ==(op)
|
159
|
-
CAS::Help.assert(op, CAS::Op)
|
173
|
+
# CAS::Help.assert(op, CAS::Op)
|
160
174
|
if op.is_a? CAS::Variable
|
161
175
|
return self.inspect == op.inspect
|
162
176
|
else
|
@@ -187,6 +201,20 @@ module CAS
|
|
187
201
|
[self]
|
188
202
|
end
|
189
203
|
|
204
|
+
# Terminal substitutions for variables
|
205
|
+
def subs(dt)
|
206
|
+
CAS::Help.assert(dt, Hash)
|
207
|
+
if dt.keys.include? self
|
208
|
+
if dt[self].is_a? CAS::Op
|
209
|
+
return dt[self]
|
210
|
+
elsif dt[self].is_a? Numeric
|
211
|
+
return CAS::const(dt[self])
|
212
|
+
else
|
213
|
+
raise CASError, "Impossible subs. Received a #{dt[self].class} = #{dt[self]}"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
190
218
|
# Same as `CAS::Op`
|
191
219
|
def inspect
|
192
220
|
"Var(#{@name})"
|
data/lib/op.rb
CHANGED
@@ -104,8 +104,17 @@ module CAS
|
|
104
104
|
# -> `CAS::Op` (`self`) with substitution performed
|
105
105
|
def subs(dt)
|
106
106
|
CAS::Help.assert(dt, Hash)
|
107
|
-
|
108
|
-
|
107
|
+
if dt.keys.include? @x
|
108
|
+
if dt[@x].is_a? CAS::Op
|
109
|
+
@x = dt[@x]
|
110
|
+
elsif dt[@x].is_a? Numeric
|
111
|
+
@x = CAS::const dt[@x]
|
112
|
+
else
|
113
|
+
raise CASError, "Impossible subs. Received a #{dt[@x].class} = #{dt[@x]}"
|
114
|
+
end
|
115
|
+
else
|
116
|
+
@x.subs(dt)
|
117
|
+
end
|
109
118
|
return self
|
110
119
|
end
|
111
120
|
|
@@ -196,9 +205,12 @@ module CAS
|
|
196
205
|
# <- `CAS::Op` to be tested against
|
197
206
|
# -> `TrueClass` if equal, `FalseClass` if differs
|
198
207
|
def ==(op)
|
199
|
-
CAS::Help.assert(op, CAS::Op)
|
200
|
-
|
201
|
-
|
208
|
+
# CAS::Help.assert(op, CAS::Op)
|
209
|
+
if op.is_a? CAS::Op
|
210
|
+
return false if op.is_a? CAS::BinaryOp
|
211
|
+
return (self.class == op.class and @x == op.x)
|
212
|
+
end
|
213
|
+
false
|
202
214
|
end
|
203
215
|
|
204
216
|
# Disequality operator, the standard operator is overloaded
|
@@ -324,9 +336,28 @@ module CAS
|
|
324
336
|
# -> `CAS::BinaryOp`, in practice `self`
|
325
337
|
def subs(dt)
|
326
338
|
CAS::Help.assert(dt, Hash)
|
327
|
-
|
328
|
-
|
329
|
-
|
339
|
+
if dt.keys.include? @x
|
340
|
+
if dt[@x].is_a? CAS::Op
|
341
|
+
@x = dt[@x]
|
342
|
+
elsif dt[@x].is_a? Numeric
|
343
|
+
@x = CAS::const dt[@x]
|
344
|
+
else
|
345
|
+
raise CASError, "Impossible subs. Received a #{dt[@x].class} = #{dt[@x]}"
|
346
|
+
end
|
347
|
+
else
|
348
|
+
@x.subs(dt)
|
349
|
+
end
|
350
|
+
if dt.keys.include? @y
|
351
|
+
if dt[@y].is_a? CAS::Op
|
352
|
+
@y = dt[@y]
|
353
|
+
elsif dt[@y].is_a? Numeric
|
354
|
+
@y = CAS::const dt[@y]
|
355
|
+
else
|
356
|
+
raise CASError, "Impossible subs. Received a #{dt[@y].class} = #{dt[@y]}"
|
357
|
+
end
|
358
|
+
else
|
359
|
+
@y.subs(dt)
|
360
|
+
end
|
330
361
|
return self
|
331
362
|
end
|
332
363
|
|
data/lib/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ragni-cas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Ragni
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
XorZtzkkLImvKFj35xKLFfVkv0Vd8tGQoiL8vdmQNJjAjtE+C+Y7OI4dpiZPKO4G
|
30
30
|
R/8JOvUuk9jPbyLxjQH/sFaFqqYGX2xo1zk2CRy/A0WhJrSaXVw1r5lEi7b0W5gg
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2016-07-
|
32
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
33
33
|
dependencies: []
|
34
34
|
description:
|
35
35
|
email: info@ragni.me
|
metadata.gz.sig
CHANGED
Binary file
|