ragni-cas 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/fnc-base.rb +9 -9
- data/lib/fnc-branch.rb +13 -0
- data/lib/fnc-trig.rb +12 -12
- data/lib/fnc-trsc.rb +3 -3
- data/lib/numbers.rb +26 -6
- data/lib/op.rb +5 -5
- data/lib/version.rb +1 -1
- 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: b056fe6568af3a1aaeb4ae3442554aac4a971c33
|
4
|
+
data.tar.gz: fa872c9f903c62a8627d49990c536df10b811af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64343ce07b37fd80d0415293c72137d837792f10a1afb41669c0a7987a28fa9c73e834c0aaf9319f27627a871f23166afd30d32787b77a62a93728f3c7a71594
|
7
|
+
data.tar.gz: 189a27a57b2d6bd6808b8cec54ed5b1d06644f3a24a0b2070366163ab5d8718fb32036ddaa0067492b852d58dcea3ef96106ef4c963e82c99f6320a17e724267
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/fnc-base.rb
CHANGED
@@ -70,7 +70,7 @@ module CAS
|
|
70
70
|
def to_code
|
71
71
|
"(#{@x.to_code} + #{@y.to_code})"
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
# Returns a latex represenntation of the current Op
|
75
75
|
def to_latex
|
76
76
|
"\\left(#{@x.to_latex} + #{@y.to_latex}\\right)"
|
@@ -144,7 +144,7 @@ module CAS
|
|
144
144
|
def to_code
|
145
145
|
"(#{@x.to_code} - #{@y.to_code})"
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
# Returns a latex representation of the current Op
|
149
149
|
def to_latex
|
150
150
|
"\\left(#{@x.to_latex} - #{@y.to_latex}\\right)"
|
@@ -216,7 +216,7 @@ module CAS
|
|
216
216
|
def to_code
|
217
217
|
"(#{@x.to_code} * #{@y.to_code})"
|
218
218
|
end
|
219
|
-
|
219
|
+
|
220
220
|
# Returns a latex represstation of the Op
|
221
221
|
def to_latex
|
222
222
|
"#{@x.to_latex}\\,#{@y.to_latex}"
|
@@ -293,7 +293,7 @@ module CAS
|
|
293
293
|
def to_code
|
294
294
|
"(#{@x.to_code} ** #{@y.to_code})"
|
295
295
|
end
|
296
|
-
|
296
|
+
|
297
297
|
# Returns the latex representation of the op
|
298
298
|
def to_latex
|
299
299
|
"{#{@x.to_latex}}^{#{@y.to_latex}}"
|
@@ -366,7 +366,7 @@ module CAS
|
|
366
366
|
def to_code
|
367
367
|
"(#{@x.to_code} / #{@y.to_code})"
|
368
368
|
end
|
369
|
-
|
369
|
+
|
370
370
|
# Returns the latex reppresentation of the current Op
|
371
371
|
def to_latex
|
372
372
|
"\\dfrac{#{@x.to_latex}}{#{@y.to_latex}}"
|
@@ -428,7 +428,7 @@ module CAS
|
|
428
428
|
def to_code
|
429
429
|
"Math::sqrt(#{@x.to_code})"
|
430
430
|
end
|
431
|
-
|
431
|
+
|
432
432
|
# Returns the latex representation of the current Op
|
433
433
|
def to_latex
|
434
434
|
"\\sqrt{#{@x.to_latex}}"
|
@@ -487,7 +487,7 @@ module CAS
|
|
487
487
|
def to_code
|
488
488
|
"(-#{@x.to_code})"
|
489
489
|
end
|
490
|
-
|
490
|
+
|
491
491
|
# Returns the latex representation of the current op
|
492
492
|
def to_latex
|
493
493
|
"-{#{@x.to_latex}}"
|
@@ -512,7 +512,7 @@ module CAS
|
|
512
512
|
# ```
|
513
513
|
def diff(v)
|
514
514
|
if @x.depend? v
|
515
|
-
return @x.diff * (@x/CAS.abs(@x))
|
515
|
+
return @x.diff(x) * (@x/CAS.abs(@x))
|
516
516
|
else
|
517
517
|
return CAS::Zero
|
518
518
|
end
|
@@ -547,7 +547,7 @@ module CAS
|
|
547
547
|
def to_code
|
548
548
|
"(#{@x.to_code}).abs"
|
549
549
|
end
|
550
|
-
|
550
|
+
|
551
551
|
# Returns the latex representation of the current Op
|
552
552
|
def to_latex
|
553
553
|
"\\left|#{@x.to_latex}\\right|"
|
data/lib/fnc-branch.rb
CHANGED
@@ -218,6 +218,7 @@ module CAS
|
|
218
218
|
end
|
219
219
|
CAS::Help.assert(lower, CAS::Constant)
|
220
220
|
CAS::Help.assert(upper, CAS::Constant)
|
221
|
+
|
221
222
|
CAS::Help.assert(x, CAS::Op)
|
222
223
|
CAS::Help.assert(type, Symbol)
|
223
224
|
|
@@ -241,6 +242,9 @@ module CAS
|
|
241
242
|
self.define_singleton_method :to_code do
|
242
243
|
"(#{@lower.to_code} < #{@x.to_code} and #{@x.to_code} < #{@upper.to_code}"
|
243
244
|
end
|
245
|
+
self.define_singleton_method :to_latex do
|
246
|
+
"#{@lower.to_latex} < #{@x.to_latex} < #{@upper.to_latex}"
|
247
|
+
end
|
244
248
|
when :closed
|
245
249
|
self.define_singleton_method :call do |fd|
|
246
250
|
(@lower.call(fd) <= @x.call(fd)) and (@x.call(fd) <= @upper.call(fd))
|
@@ -254,6 +258,9 @@ module CAS
|
|
254
258
|
self.define_singleton_method :to_code do
|
255
259
|
"(#{@lower.to_code} <= #{@x.to_code} and #{@x.to_code} <= #{@upper.to_code}"
|
256
260
|
end
|
261
|
+
self.define_singleton_method :to_latex do
|
262
|
+
"#{@lower.to_latex} \\leq #{@x.to_latex} \\leq #{@upper.to_latex}"
|
263
|
+
end
|
257
264
|
when :upper_closed
|
258
265
|
self.define_singleton_method :call do |fd|
|
259
266
|
(@lower.call(fd) < @x.call(fd)) and (@x.call(fd) <= @upper.call(fd))
|
@@ -267,6 +274,9 @@ module CAS
|
|
267
274
|
self.define_singleton_method :to_code do
|
268
275
|
"(#{@lower.to_code} < #{@x.to_code} and #{@x.to_code} <= #{@upper.to_code}"
|
269
276
|
end
|
277
|
+
self.define_singleton_method :to_latex do
|
278
|
+
"#{@lower.to_latex} < #{@x.to_latex} \\leq #{@upper.to_latex}"
|
279
|
+
end
|
270
280
|
when :lower_closed
|
271
281
|
self.define_singleton_method :call do |fd|
|
272
282
|
(@lower.call(fd) <= @x.call(fd)) and (@x.call(fd) < @upper.call(fd))
|
@@ -280,6 +290,9 @@ module CAS
|
|
280
290
|
self.define_singleton_method :to_code do
|
281
291
|
"(#{@lower.to_code} <= #{@x.to_code} and #{@x.to_code} < #{@upper.to_code}"
|
282
292
|
end
|
293
|
+
self.define_singleton_method :to_latex do
|
294
|
+
"#{@lower.to_latex} \\leq #{@x.to_latex} < #{@upper.to_latex}"
|
295
|
+
end
|
283
296
|
else
|
284
297
|
raise ArgumentError, "Unknown type of box condition"
|
285
298
|
end
|
data/lib/fnc-trig.rb
CHANGED
@@ -45,10 +45,10 @@ module CAS
|
|
45
45
|
def to_code
|
46
46
|
"Math::sin(#{@x.to_code})"
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
# Return latex representation of current Op
|
50
50
|
def to_latex
|
51
|
-
"\\
|
51
|
+
"\\sin\\left( #{@x.to_latex} \\right)"
|
52
52
|
end
|
53
53
|
end # Sin
|
54
54
|
|
@@ -100,10 +100,10 @@ module CAS
|
|
100
100
|
def to_code
|
101
101
|
"Math::asin(#{@x.to_code})"
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
# Return latex representation of current Op
|
105
105
|
def to_latex
|
106
|
-
"\\
|
106
|
+
"\\arcsin\\left( #{@x.to_latex} \\right)"
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -155,10 +155,10 @@ module CAS
|
|
155
155
|
def to_code
|
156
156
|
"Math::cos(#{@x.to_code})"
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
# Return latex representation of current Op
|
160
160
|
def to_latex
|
161
|
-
"\\
|
161
|
+
"\\cos\\left( #{@x.to_latex} \\right)"
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -210,10 +210,10 @@ module CAS
|
|
210
210
|
def to_code
|
211
211
|
"Math::acos(#{@x.to_code})"
|
212
212
|
end
|
213
|
-
|
213
|
+
|
214
214
|
# Return latex representation of current Op
|
215
215
|
def to_latex
|
216
|
-
"\\
|
216
|
+
"\\arccos\\left( #{@x.to_latex} \\right)"
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
@@ -265,10 +265,10 @@ module CAS
|
|
265
265
|
def to_code
|
266
266
|
"Math::tan(#{@x.to_code})"
|
267
267
|
end
|
268
|
-
|
268
|
+
|
269
269
|
# Return latex representation of current Op
|
270
270
|
def to_latex
|
271
|
-
"\\
|
271
|
+
"\\tan\\left( #{@x.to_latex} \\right)"
|
272
272
|
end
|
273
273
|
end
|
274
274
|
|
@@ -323,10 +323,10 @@ module CAS
|
|
323
323
|
def to_code
|
324
324
|
"Math::atan(#{@x.to_code})"
|
325
325
|
end
|
326
|
-
|
326
|
+
|
327
327
|
# Return latex representation of current Op
|
328
328
|
def to_latex
|
329
|
-
"\\
|
329
|
+
"\\arctan\\left( #{@x.to_latex} \\right)"
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
data/lib/fnc-trsc.rb
CHANGED
@@ -49,7 +49,7 @@ module CAS
|
|
49
49
|
def to_code
|
50
50
|
"Math::exp(#{@x.to_code})"
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
# Return latex representation of current Op
|
54
54
|
def to_latex
|
55
55
|
"e^{#{@x.to_latex}}"
|
@@ -110,10 +110,10 @@ module CAS
|
|
110
110
|
def to_code
|
111
111
|
"Math::log(#{@x.to_code})"
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
# Return latex representation of current Op
|
115
115
|
def to_latex
|
116
|
-
"\\
|
116
|
+
"\\log\\left( #{@x.to_latex} \\right)"
|
117
117
|
end
|
118
118
|
end # Ln
|
119
119
|
|
data/lib/numbers.rb
CHANGED
@@ -87,7 +87,7 @@ module CAS
|
|
87
87
|
def dot_graph(node)
|
88
88
|
"#{self.class.to_s.gsub("CAS::", "")}_#{self.object_id};"
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
# Return latex representation of current Op
|
92
92
|
def to_latex
|
93
93
|
self.to_s
|
@@ -165,7 +165,7 @@ module CAS
|
|
165
165
|
# <- `CAS::Op` for the derivative denominator
|
166
166
|
# -> `CAS::Constant`, 0 if not depended, 1 if dependent
|
167
167
|
def diff(v)
|
168
|
-
CAS::One
|
168
|
+
(self == v ? CAS::One : CAS::Zero)
|
169
169
|
end
|
170
170
|
|
171
171
|
# Same as `CAS::Op`
|
@@ -234,7 +234,7 @@ module CAS
|
|
234
234
|
def dot_graph(node)
|
235
235
|
"#{@name};"
|
236
236
|
end
|
237
|
-
|
237
|
+
|
238
238
|
# Return latex representation of current Op
|
239
239
|
def to_latex
|
240
240
|
self.to_s
|
@@ -307,7 +307,7 @@ module CAS
|
|
307
307
|
def to_s
|
308
308
|
"π"
|
309
309
|
end
|
310
|
-
|
310
|
+
|
311
311
|
def to_latex
|
312
312
|
"\\pi"
|
313
313
|
end
|
@@ -326,7 +326,7 @@ module CAS
|
|
326
326
|
def to_s
|
327
327
|
"e"
|
328
328
|
end
|
329
|
-
|
329
|
+
|
330
330
|
def to_latex
|
331
331
|
"e"
|
332
332
|
end
|
@@ -346,13 +346,33 @@ module CAS
|
|
346
346
|
def to_s
|
347
347
|
"∞"
|
348
348
|
end
|
349
|
-
|
349
|
+
|
350
350
|
def to_latex
|
351
351
|
"\\infty"
|
352
352
|
end
|
353
353
|
end
|
354
354
|
Infinity = CAS::INFINITY_CONSTANT.new
|
355
355
|
|
356
|
+
# _ _ ___ __ _ _ _
|
357
|
+
# | \| |___ __ _|_ _|_ _ / _(_)_ _ (_) |_ _ _
|
358
|
+
# | .` / -_) _` || || ' \| _| | ' \| | _| || |
|
359
|
+
# |_|\_\___\__, |___|_||_|_| |_|_||_|_|\__|\_, |
|
360
|
+
# |___/ |__/
|
361
|
+
class NEG_INFINITY_CONSTANT < CAS::Constant
|
362
|
+
def initialize
|
363
|
+
@x = -(1.0/0.0)
|
364
|
+
end
|
365
|
+
|
366
|
+
def to_s
|
367
|
+
"-∞"
|
368
|
+
end
|
369
|
+
|
370
|
+
def to_latex
|
371
|
+
"-\\infty"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
NegInfinity = CAS::NEG_INFINITY_CONSTANT.new
|
375
|
+
|
356
376
|
# _
|
357
377
|
# ___/ |
|
358
378
|
# |___| |
|
data/lib/op.rb
CHANGED
@@ -21,10 +21,10 @@ module CAS
|
|
21
21
|
# -> `CAS::Op` instance
|
22
22
|
def initialize(x)
|
23
23
|
if x.is_a? Numeric
|
24
|
-
case x
|
25
|
-
when 0
|
24
|
+
case x.to_f
|
25
|
+
when 0.0
|
26
26
|
x = CAS::Zero
|
27
|
-
when 1
|
27
|
+
when 1.0
|
28
28
|
x = CAS::One
|
29
29
|
else
|
30
30
|
x = CAS.const x
|
@@ -41,7 +41,7 @@ module CAS
|
|
41
41
|
# <- `CAS::Variable` instance
|
42
42
|
# -> `TrueClass` if depends, `FalseClass` if not
|
43
43
|
def depend?(v)
|
44
|
-
CAS::Help.assert(v, CAS::
|
44
|
+
CAS::Help.assert(v, CAS::Op)
|
45
45
|
|
46
46
|
@x.depend? v
|
47
47
|
end
|
@@ -110,7 +110,7 @@ module CAS
|
|
110
110
|
elsif dt[@x].is_a? Numeric
|
111
111
|
@x = CAS::const dt[@x]
|
112
112
|
else
|
113
|
-
raise CASError, "Impossible subs. Received a #{dt[@x].class} = #{dt[@x]}"
|
113
|
+
raise CAS::CASError, "Impossible subs. Received a #{dt[@x].class} = #{dt[@x]}"
|
114
114
|
end
|
115
115
|
else
|
116
116
|
@x.subs(dt)
|
data/lib/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.2
|
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-
|
32
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
33
33
|
dependencies: []
|
34
34
|
description:
|
35
35
|
email: info@ragni.me
|
metadata.gz.sig
CHANGED
Binary file
|