Class: SyMath::Definition::Lmd
- Inherits:
-
Function
- Object
- Value
- SyMath::Definition
- Operator
- Function
- SyMath::Definition::Lmd
- Defined in:
- lib/symath/definition/lmd.rb
Instance Attribute Summary
Attributes inherited from Operator
Attributes inherited from SyMath::Definition
Instance Method Summary collapse
-
#call(*args) ⇒ Object
For a lambda function, the call returns a function with a reference to our own lambda function definition.
- #compose_with_simplify(exp, vars) ⇒ Object
- #description ⇒ Object
-
#evaluate ⇒ Object
Evaluate the operator definition FIXME: Is it right to evaluate the definition exp?.
-
#initialize(exp, *vars) ⇒ Lmd
constructor
A new instance of Lmd.
- #latex_format ⇒ Object
- #reduce ⇒ Object
- #to_s(args = nil) ⇒ Object
Methods inherited from Function
#check_pi_fraction, functions, init_builtin, #is_function?, #reduce_call
Methods inherited from Operator
#<=>, #==, #arity, #dump, #evaluate_call, init_builtin, #is_operator?, operators, #replace, #to_latex, #validate_args
Methods inherited from SyMath::Definition
#<=>, #==, #arity, define, defined?, definitions, get, #hash, init_builtin, #inspect, #is_constant?, #is_function?, #is_operator?, #reduce_call, #replace, #to_latex, undefine, #variables
Methods inherited from Value
#*, #**, #+, #-, #-@, #/, #<, #<=, #<=>, #>, #>=, #^, #add, #base, compose_with_simplify, create, #deep_clone, #div, #dump, #exponent, #factors, #inspect, #inv, #is_divisor_factor?, #is_finite?, #is_nan?, #is_negative?, #is_negative_number?, #is_number?, #is_positive?, #is_prod_exp?, #is_sum_exp?, #is_unit_quaternion?, #is_zero?, #mul, #neg, #power, #reduce_modulo_sign, #sign, #sub, #terms, #to_m, #type, #wedge
Methods included from Operation::Exterior
Methods included from Operation::Integration
#anti_derivative, #get_linear_constants, initialize, #int_constant, #int_failure, #int_function, #int_inv, #int_pattern, #int_power, #int_product, #int_sum, #integral_bounds
Methods included from Operation::Differential
#_d_wedge, #d, #d_failure, #d_fraction, #d_function, #d_function_def, #d_power, #d_product, initialize
Methods included from Operation
Methods included from Operation::DistributiveLaw
#combfrac_add_term, #combfrac_sum, #combine_fractions, #expand, #expand_product, #expand_single_pass, #factorize, #factorize_integer_poly, #factorize_simple, #has_fractional_terms?
Methods included from Operation::Normalization
#combine_factors, #compare_factors_and_swap, #normalize, #normalize_matrix, #normalize_power, #normalize_product, #normalize_single_pass, #normalize_sum, #order_product, #product_on_fraction_form, #reduce_constant_factors, #replace_combined_factors, #swap_factors
Methods included from Operation::Match
#build_assoc_op, #match, #match_assoc, #match_replace
Constructor Details
#initialize(exp, *vars) ⇒ Lmd
Returns a new instance of Lmd.
6 7 8 |
# File 'lib/symath/definition/lmd.rb', line 6 def initialize(exp, *vars) super('', args: vars, exp: exp, define_symbol: false) end |
Instance Method Details
#call(*args) ⇒ Object
For a lambda function, the call returns a function with a reference to our own lambda function definition.
64 65 66 67 |
# File 'lib/symath/definition/lmd.rb', line 64 def call(*args) args = args.map { |a| a.nil? ? a : a.to_m } return SyMath::Operator.new(self, args) end |
#compose_with_simplify(exp, vars) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/symath/definition/lmd.rb', line 14 def compose_with_simplify(exp, vars) vars.each do |v| if !v.is_a?(SyMath::Definition::Variable) raise "Expected variable, got #{v.class.name}" end if v.is_d? raise "Var is not allowed to br differential, got #{v}" end end # Simplify lmd(f(*args), *args) to f(*args) if !exp.is_a?(SyMath::Operator) return end if !exp.definition.is_function? return end if exp.arity != vars.length return end exp.args.each do |a| if !a.is_a?(SyMath::Definition::Variable) return end if a.is_d? return end end return exp end |
#description ⇒ Object
10 11 12 |
# File 'lib/symath/definition/lmd.rb', line 10 def description() return "{self.to_s} - Lambda function of expression #{exp}" end |
#evaluate ⇒ Object
Evaluate the operator definition FIXME: Is it right to evaluate the definition exp?
53 54 55 56 57 58 59 60 |
# File 'lib/symath/definition/lmd.rb', line 53 def evaluate() if name == '' and !exp.nil? e = exp.evaluate return lmd(e, self.args) end return self end |
#latex_format ⇒ Object
88 89 90 |
# File 'lib/symath/definition/lmd.rb', line 88 def latex_format() return "(#{exp}).(%s)" end |
#reduce ⇒ Object
69 70 71 72 |
# File 'lib/symath/definition/lmd.rb', line 69 def reduce() # FIXME: Reduce if lmd is just a wrapper around a function. return self end |
#to_s(args = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/symath/definition/lmd.rb', line 74 def to_s(args = nil) if !args args = @args end if args.length > 0 arglist = args.map { |a| a.to_s }.join(',') else arglist = "..." end return "(#{exp}).(#{arglist})" end |