ragni-cas 0.1.9 → 0.2.0
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 +50 -0
- data/lib/fnc-branch.rb +24 -0
- data/lib/fnc-trig.rb +30 -0
- data/lib/fnc-trsc.rb +10 -0
- data/lib/numbers.rb +22 -0
- data/lib/op.rb +14 -0
- data/lib/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: 5050928caea86f26844bb7d526712ebbac3955bd
|
4
|
+
data.tar.gz: d65f4cc064b36c402cea4dc49a7ad983130af256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad30cd4099786ab30fcfb02d2df868fdd2addf7ae69611c881f5cffaa2f46ba414bd66b4cb84c868582c92b1fce4c2b9a163379b194c2f717d83c5de3bb2a237
|
7
|
+
data.tar.gz: d5edfc457d09f2758d18108af41e96c4107634e7dcd9aaee0ce03b0eeb85b33ccab641890e9b8e0585268bbbee5242cba8f49cc505a37cc6c9c7c8f76ad62681
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/fnc-base.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/vin/env ruby
|
2
2
|
|
3
3
|
module CAS
|
4
|
+
# ```
|
4
5
|
# ___
|
5
6
|
# / __|_ _ _ __
|
6
7
|
# \__ \ || | ' \
|
7
8
|
# |___/\_,_|_|_|_|
|
9
|
+
# ```
|
8
10
|
class Sum < CAS::BinaryOp
|
9
11
|
# Performs the sum between two `CAS::Op`
|
10
12
|
#
|
@@ -68,12 +70,19 @@ module CAS
|
|
68
70
|
def to_code
|
69
71
|
"(#{@x.to_code} + #{@y.to_code})"
|
70
72
|
end
|
73
|
+
|
74
|
+
# Returns a latex represenntation of the current Op
|
75
|
+
def to_latex
|
76
|
+
"\\left(#{@x.to_latex} + #{@y.to_latex}\\right)"
|
77
|
+
end
|
71
78
|
end # Sum
|
72
79
|
|
80
|
+
# ```
|
73
81
|
# ___ _ __ __
|
74
82
|
# | \(_)/ _|/ _|
|
75
83
|
# | |) | | _| _/
|
76
84
|
# |___/|_|_| |_|
|
85
|
+
# ```
|
77
86
|
class Diff < CAS::BinaryOp
|
78
87
|
# Performs the difference between two `CAS::Op`s
|
79
88
|
#
|
@@ -135,12 +144,19 @@ module CAS
|
|
135
144
|
def to_code
|
136
145
|
"(#{@x.to_code} - #{@y.to_code})"
|
137
146
|
end
|
147
|
+
|
148
|
+
# Returns a latex representation of the current Op
|
149
|
+
def to_latex
|
150
|
+
"\\left(#{@x.to_latex} - #{@y.to_latex}\\right)"
|
151
|
+
end
|
138
152
|
end # Difference
|
139
153
|
|
154
|
+
# ```
|
140
155
|
# ___ _
|
141
156
|
# | _ \_ _ ___ __| |
|
142
157
|
# | _/ '_/ _ \/ _` |
|
143
158
|
# |_| |_| \___/\__,_|
|
159
|
+
# ```
|
144
160
|
class Prod < CAS::BinaryOp
|
145
161
|
# Performs the product between two `CAS::Op`
|
146
162
|
#
|
@@ -200,12 +216,19 @@ module CAS
|
|
200
216
|
def to_code
|
201
217
|
"(#{@x.to_code} * #{@y.to_code})"
|
202
218
|
end
|
219
|
+
|
220
|
+
# Returns a latex represstation of the Op
|
221
|
+
def to_latex
|
222
|
+
"#{@x.to_latex}\\,#{@y.to_latex}"
|
223
|
+
end
|
203
224
|
end # Prod
|
204
225
|
|
226
|
+
# ```
|
205
227
|
# ___
|
206
228
|
# | _ \_____ __ __
|
207
229
|
# | _/ _ \ V V /
|
208
230
|
# |_| \___/\_/\_/
|
231
|
+
# ```
|
209
232
|
class Pow < CAS::BinaryOp
|
210
233
|
# Performs the power between two `CAS::Op`
|
211
234
|
#
|
@@ -270,16 +293,23 @@ module CAS
|
|
270
293
|
def to_code
|
271
294
|
"(#{@x.to_code} ** #{@y.to_code})"
|
272
295
|
end
|
296
|
+
|
297
|
+
# Returns the latex representation of the op
|
298
|
+
def to_latex
|
299
|
+
"{#{@x.to_latex}}^{#{@y.to_latex}}"
|
300
|
+
end
|
273
301
|
end
|
274
302
|
|
275
303
|
def self.pow(x, y)
|
276
304
|
CAS::Pow.new x, y
|
277
305
|
end
|
278
306
|
|
307
|
+
# ```
|
279
308
|
# ___ _
|
280
309
|
# | \(_)_ __
|
281
310
|
# | |) | \ V /
|
282
311
|
# |___/|_|\_/
|
312
|
+
# ```
|
283
313
|
class Div < CAS::BinaryOp
|
284
314
|
# Performs the division between two `CAS::Op`
|
285
315
|
#
|
@@ -336,6 +366,11 @@ module CAS
|
|
336
366
|
def to_code
|
337
367
|
"(#{@x.to_code} / #{@y.to_code})"
|
338
368
|
end
|
369
|
+
|
370
|
+
# Returns the latex reppresentation of the current Op
|
371
|
+
def to_latex
|
372
|
+
"\\dfrac{#{@x.to_latex}}{#{@y.to_latex}}"
|
373
|
+
end
|
339
374
|
end # Div
|
340
375
|
|
341
376
|
# ___ _
|
@@ -393,6 +428,11 @@ module CAS
|
|
393
428
|
def to_code
|
394
429
|
"Math::sqrt(#{@x.to_code})"
|
395
430
|
end
|
431
|
+
|
432
|
+
# Returns the latex representation of the current Op
|
433
|
+
def to_latex
|
434
|
+
"\\sqrt{#{@x.to_latex}}"
|
435
|
+
end
|
396
436
|
end # Sqrt
|
397
437
|
|
398
438
|
def self.sqrt(x)
|
@@ -447,6 +487,11 @@ module CAS
|
|
447
487
|
def to_code
|
448
488
|
"(-#{@x.to_code})"
|
449
489
|
end
|
490
|
+
|
491
|
+
# Returns the latex representation of the current op
|
492
|
+
def to_latex
|
493
|
+
"-{#{@x.to_latex}}"
|
494
|
+
end
|
450
495
|
end
|
451
496
|
|
452
497
|
def self.invert(x)
|
@@ -502,6 +547,11 @@ module CAS
|
|
502
547
|
def to_code
|
503
548
|
"(#{@x.to_code}).abs"
|
504
549
|
end
|
550
|
+
|
551
|
+
# Returns the latex representation of the current Op
|
552
|
+
def to_latex
|
553
|
+
"\\left|#{@x.to_latex}\\right|"
|
554
|
+
end
|
505
555
|
end
|
506
556
|
|
507
557
|
def self.abs(x)
|
data/lib/fnc-branch.rb
CHANGED
@@ -45,6 +45,10 @@ module CAS
|
|
45
45
|
cls = "#{self.class.to_s.gsub("CAS::", "")}_#{self.object_id}"
|
46
46
|
"#{cls} -> #{@x.dot_graph node}\n #{cls} -> #{@y.dot_graph node}\n #{cls} -> #{@condition.dot_graph node}"
|
47
47
|
end
|
48
|
+
|
49
|
+
def to_latex
|
50
|
+
"\\left\\{ \\begin{array}{lr} #{@x.to_latex} & #{@condition.to_latex} \\\\ #{@y.to_latex} \\end{array} \\right."
|
51
|
+
end
|
48
52
|
end
|
49
53
|
|
50
54
|
|
@@ -156,30 +160,50 @@ module CAS
|
|
156
160
|
def initialize(x, y)
|
157
161
|
super(:eq, x, y)
|
158
162
|
end
|
163
|
+
|
164
|
+
def to_latex
|
165
|
+
"#{@x.to_latex} = #{@y.to_latex}"
|
166
|
+
end
|
159
167
|
end
|
160
168
|
|
161
169
|
class Greater < CAS::Condition
|
162
170
|
def initialize(x, y)
|
163
171
|
super(:gt, x, y)
|
164
172
|
end
|
173
|
+
|
174
|
+
def to_latex
|
175
|
+
"#{@x.to_latex} > #{@y.to_latex}"
|
176
|
+
end
|
165
177
|
end
|
166
178
|
|
167
179
|
class GreaterEqual < CAS::Condition
|
168
180
|
def initialize(x, y)
|
169
181
|
super(:geq, x, y)
|
170
182
|
end
|
183
|
+
|
184
|
+
def to_latex
|
185
|
+
"#{@x.to_latex} \\geq #{@y.to_latex}"
|
186
|
+
end
|
171
187
|
end
|
172
188
|
|
173
189
|
class Smaller < CAS::Condition
|
174
190
|
def initialize(x, y)
|
175
191
|
super(:lt, x, y)
|
176
192
|
end
|
193
|
+
|
194
|
+
def to_latex
|
195
|
+
"#{@x.to_latex} < #{@y.to_latex}"
|
196
|
+
end
|
177
197
|
end
|
178
198
|
|
179
199
|
class SmallerEqual < CAS::Condition
|
180
200
|
def initialize(x, y)
|
181
201
|
super(:leq, x, y)
|
182
202
|
end
|
203
|
+
|
204
|
+
def to_latex
|
205
|
+
"#{@x.to_latex} \\leq #{@y.to_latex}"
|
206
|
+
end
|
183
207
|
end
|
184
208
|
|
185
209
|
def self.equal(x, y); CAS::Equal.new(x, y); end
|
data/lib/fnc-trig.rb
CHANGED
@@ -45,6 +45,11 @@ module CAS
|
|
45
45
|
def to_code
|
46
46
|
"Math::sin(#{@x.to_code})"
|
47
47
|
end
|
48
|
+
|
49
|
+
# Return latex representation of current Op
|
50
|
+
def to_latex
|
51
|
+
"\\mathrm{sin}\\left( #{@x.to_latex} \\right))"
|
52
|
+
end
|
48
53
|
end # Sin
|
49
54
|
|
50
55
|
def self.sin(x)
|
@@ -95,6 +100,11 @@ module CAS
|
|
95
100
|
def to_code
|
96
101
|
"Math::asin(#{@x.to_code})"
|
97
102
|
end
|
103
|
+
|
104
|
+
# Return latex representation of current Op
|
105
|
+
def to_latex
|
106
|
+
"\\mathrm{arcsin}\\left( #{@x.to_latex} \\right))"
|
107
|
+
end
|
98
108
|
end
|
99
109
|
|
100
110
|
def self.asin(x)
|
@@ -145,6 +155,11 @@ module CAS
|
|
145
155
|
def to_code
|
146
156
|
"Math::cos(#{@x.to_code})"
|
147
157
|
end
|
158
|
+
|
159
|
+
# Return latex representation of current Op
|
160
|
+
def to_latex
|
161
|
+
"\\mathrm{cos}\\left( #{@x.to_latex} \\right))"
|
162
|
+
end
|
148
163
|
end
|
149
164
|
|
150
165
|
def self.cos(x)
|
@@ -195,6 +210,11 @@ module CAS
|
|
195
210
|
def to_code
|
196
211
|
"Math::acos(#{@x.to_code})"
|
197
212
|
end
|
213
|
+
|
214
|
+
# Return latex representation of current Op
|
215
|
+
def to_latex
|
216
|
+
"\\mathrm{arccos}\\left( #{@x.to_latex} \\right))"
|
217
|
+
end
|
198
218
|
end
|
199
219
|
|
200
220
|
def self.acos(x)
|
@@ -245,6 +265,11 @@ module CAS
|
|
245
265
|
def to_code
|
246
266
|
"Math::tan(#{@x.to_code})"
|
247
267
|
end
|
268
|
+
|
269
|
+
# Return latex representation of current Op
|
270
|
+
def to_latex
|
271
|
+
"\\mathrm{tan}\\left( #{@x.to_latex} \\right))"
|
272
|
+
end
|
248
273
|
end
|
249
274
|
|
250
275
|
def self.tan(x)
|
@@ -298,6 +323,11 @@ module CAS
|
|
298
323
|
def to_code
|
299
324
|
"Math::atan(#{@x.to_code})"
|
300
325
|
end
|
326
|
+
|
327
|
+
# Return latex representation of current Op
|
328
|
+
def to_latex
|
329
|
+
"\\mathrm{arctan}\\left( #{@x.to_latex} \\right))"
|
330
|
+
end
|
301
331
|
end
|
302
332
|
|
303
333
|
def self.atan(x)
|
data/lib/fnc-trsc.rb
CHANGED
@@ -49,6 +49,11 @@ module CAS
|
|
49
49
|
def to_code
|
50
50
|
"Math::exp(#{@x.to_code})"
|
51
51
|
end
|
52
|
+
|
53
|
+
# Return latex representation of current Op
|
54
|
+
def to_latex
|
55
|
+
"e^{#{@x.to_latex}}"
|
56
|
+
end
|
52
57
|
end # Exp
|
53
58
|
|
54
59
|
def self.exp(x)
|
@@ -105,6 +110,11 @@ module CAS
|
|
105
110
|
def to_code
|
106
111
|
"Math::log(#{@x.to_code})"
|
107
112
|
end
|
113
|
+
|
114
|
+
# Return latex representation of current Op
|
115
|
+
def to_latex
|
116
|
+
"\\mathrm{ln}\\left( #{@x.to_latex} \\right))"
|
117
|
+
end
|
108
118
|
end # Ln
|
109
119
|
|
110
120
|
def self.ln(x)
|
data/lib/numbers.rb
CHANGED
@@ -87,6 +87,11 @@ module CAS
|
|
87
87
|
def dot_graph(node)
|
88
88
|
"#{self.class.to_s.gsub("CAS::", "")}_#{self.object_id};"
|
89
89
|
end
|
90
|
+
|
91
|
+
# Return latex representation of current Op
|
92
|
+
def to_latex
|
93
|
+
self.to_s
|
94
|
+
end
|
90
95
|
end
|
91
96
|
|
92
97
|
# Allows to define a series of new constants.
|
@@ -229,6 +234,11 @@ module CAS
|
|
229
234
|
def dot_graph(node)
|
230
235
|
"#{@name};"
|
231
236
|
end
|
237
|
+
|
238
|
+
# Return latex representation of current Op
|
239
|
+
def to_latex
|
240
|
+
self.to_s
|
241
|
+
end
|
232
242
|
end # Number
|
233
243
|
|
234
244
|
def self.vars(*name)
|
@@ -297,6 +307,10 @@ module CAS
|
|
297
307
|
def to_s
|
298
308
|
"π"
|
299
309
|
end
|
310
|
+
|
311
|
+
def to_latex
|
312
|
+
"\\pi"
|
313
|
+
end
|
300
314
|
end
|
301
315
|
Pi = CAS::PI_CONSTANT.new
|
302
316
|
|
@@ -312,6 +326,10 @@ module CAS
|
|
312
326
|
def to_s
|
313
327
|
"e"
|
314
328
|
end
|
329
|
+
|
330
|
+
def to_latex
|
331
|
+
"e"
|
332
|
+
end
|
315
333
|
end
|
316
334
|
E = CAS::E_CONSTANT.new
|
317
335
|
|
@@ -328,6 +346,10 @@ module CAS
|
|
328
346
|
def to_s
|
329
347
|
"∞"
|
330
348
|
end
|
349
|
+
|
350
|
+
def to_latex
|
351
|
+
"\\infty"
|
352
|
+
end
|
331
353
|
end
|
332
354
|
Infinity = CAS::INFINITY_CONSTANT.new
|
333
355
|
|
data/lib/op.rb
CHANGED
@@ -260,6 +260,13 @@ module CAS
|
|
260
260
|
cls = "#{self.class.to_s.gsub("CAS::", "")}_#{self.object_id}"
|
261
261
|
"#{cls} -> #{@x.dot_graph node}\n"
|
262
262
|
end
|
263
|
+
|
264
|
+
# Returns the latex representation of the current Op.
|
265
|
+
#
|
266
|
+
# -> `String`
|
267
|
+
def to_latex
|
268
|
+
"#{self.class.gsub("CAS::", "")}\\left(#{@x.to_latex}\\right)"
|
269
|
+
end
|
263
270
|
end # Op
|
264
271
|
|
265
272
|
# ___ _ ___
|
@@ -436,5 +443,12 @@ module CAS
|
|
436
443
|
cls = "#{self.class.to_s.gsub("CAS::", "")}_#{self.object_id}"
|
437
444
|
"#{cls} -> #{@x.dot_graph node}\n #{cls} -> #{@y.dot_graph node}"
|
438
445
|
end
|
446
|
+
|
447
|
+
# Returns the latex representation of the current Op.
|
448
|
+
#
|
449
|
+
# -> `String`
|
450
|
+
def to_latex
|
451
|
+
"#{self.class.gsub("CAS::", "")}\\left(#{@x.to_latex},\\,#{@y.to_latex}\\right)"
|
452
|
+
end
|
439
453
|
end # BinaryOp
|
440
454
|
end
|
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.
|
4
|
+
version: 0.2.0
|
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-27 00:00:00.000000000 Z
|
33
33
|
dependencies: []
|
34
34
|
description:
|
35
35
|
email: info@ragni.me
|
@@ -57,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
60
|
+
version: '2.0'
|
61
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
63
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|