Class: SyMath::Minus
Instance Attribute Summary
Attributes inherited from Operator
#args, #definition
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Operator
#<=>, #==, #args_assoc, #arity, #dump, #hash, #is_associative?, #is_commutative?, #is_constant?, #name, #reduce, #replace, #variables
Methods inherited from Value
#*, #**, #+, #-, #-@, #/, #<, #<=, #<=>, #>, #>=, #^, #add, #base, create, #deep_clone, #div, #dump, #exponent, #inspect, #inv, #is_divisor_factor?, #is_nan?, #is_negative?, #is_number?, #is_unit_quaternion?, #mul, #neg, #power, #reduce, #sub, #to_m, #wedge
#flat, #hodge, #sharp
#anti_derivative, #get_linear_constants, initialize, #int_constant, #int_failure, #int_function, #int_inv, #int_pattern, #int_power, #int_product, #int_sum, #integral_bounds
#_d_wedge, #d, #d_failure, #d_fraction, #d_function, #d_function_def, #d_power, #d_product, initialize
Methods included from Operation
#iterate, #recurse
#combfrac_add_term, #combfrac_sum, #combine_fractions, #expand, #expand_product, #expand_single_pass, #factorize, #factorize_integer_poly, #factorize_simple, #has_fractional_terms?
#combine_factors, #compare_factors_and_swap, #normalize, #normalize_matrix, #normalize_power, #normalize_product, #normalize_single_pass, #normalize_sum, #order_product, #product_on_fraction_form, #replace_combined_factors, #swap_factors
#build_assoc_op, #match, #match_assoc, #match_replace
Constructor Details
#initialize(arg) ⇒ Minus
Returns a new instance of Minus.
20
21
22
|
# File 'lib/symath/minus.rb', line 20
def initialize(arg)
super('-', [arg])
end
|
Class Method Details
.compose_with_simplify(a) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/symath/minus.rb', line 5
def self.compose_with_simplify(a)
a = a.to_m
if a == 0
return a
end
if a.is_a?(SyMath::Minus)
return a.argument
else
return self.new(a)
end
end
|
Instance Method Details
#argument ⇒ Object
24
25
26
|
# File 'lib/symath/minus.rb', line 24
def argument()
return @args[0]
end
|
#evaluate ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/symath/minus.rb', line 93
def evaluate
if argument.is_a?(SyMath::Matrix)
return argument.matrix_neg
end
return super
end
|
#factors ⇒ Object
65
66
67
68
69
70
|
# File 'lib/symath/minus.rb', line 65
def factors()
return Enumerator.new do |f|
f << -1.to_m
argument.factors.each { |f1| f << f1 }
end
end
|
#is_finite? ⇒ Boolean
53
54
55
|
# File 'lib/symath/minus.rb', line 53
def is_finite?()
return argument.is_finite?
end
|
#is_negative_number? ⇒ Boolean
45
46
47
|
# File 'lib/symath/minus.rb', line 45
def is_negative_number?()
return argument.is_number?
end
|
#is_positive? ⇒ Boolean
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/symath/minus.rb', line 28
def is_positive?()
if argument.is_nan?
return false
end
if SyMath.setting(:complex_arithmetic) and (argument.is_finite? == false)
return true
end
if argument.is_positive?.nil?
return
end
return (!argument.is_positive? and !argument.is_zero?)
end
|
#is_prod_exp? ⇒ Boolean
61
62
63
|
# File 'lib/symath/minus.rb', line 61
def is_prod_exp?()
return true
end
|
#is_sum_exp? ⇒ Boolean
57
58
59
|
# File 'lib/symath/minus.rb', line 57
def is_sum_exp?()
return true
end
|
#is_zero? ⇒ Boolean
49
50
51
|
# File 'lib/symath/minus.rb', line 49
def is_zero?()
return argument.is_zero?
end
|
#reduce_constant_factors ⇒ Object
82
83
84
|
# File 'lib/symath/minus.rb', line 82
def reduce_constant_factors()
return -argument.reduce_constant_factors
end
|
#reduce_modulo_sign ⇒ Object
Simple reduction rules, allows sign to change. Returns (reduced exp, sign, changed).
88
89
90
91
|
# File 'lib/symath/minus.rb', line 88
def reduce_modulo_sign
red, sign, changed = argument.reduce_modulo_sign
return red, -sign, true
end
|
#sign ⇒ Object
72
73
74
|
# File 'lib/symath/minus.rb', line 72
def sign()
return -argument.sign
end
|
#terms ⇒ Object
76
77
78
79
80
|
# File 'lib/symath/minus.rb', line 76
def terms()
return Enumerator.new do |s|
argument.terms.each { |s1| s << s1.neg }
end
end
|
#to_latex ⇒ Object
121
122
123
|
# File 'lib/symath/minus.rb', line 121
def to_latex()
return '- '.to_s + argument.to_latex
end
|
#to_s ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/symath/minus.rb', line 109
def to_s()
if SyMath.setting(:expl_parentheses)
return '(- '.to_s + argument.to_s + ')'.to_s
else
if argument.is_a?(SyMath::Sum)
return '- ('.to_s + argument.to_s + ')'.to_s
else
return '- '.to_s + argument.to_s
end
end
end
|
#type ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/symath/minus.rb', line 101
def type()
if argument.type.is_subtype?('integer')
return 'integer'.to_t
else
return argument.type
end
end
|