class Maxima::Unit
Attributes
maxima_output[RW]
plot_title[RW]
Public Class Methods
new(inline_maxima_output = nil, plot_title: nil, maxima_output: nil)
click to toggle source
# File lib/maxima/unit.rb, line 5 def initialize(inline_maxima_output = nil, plot_title: nil, maxima_output: nil) @maxima_output = inline_maxima_output || maxima_output @plot_title = plot_title end
parse(m)
click to toggle source
# File lib/maxima/unit.rb, line 18 def self.parse(m) Function.parse(m) end
parse_float(m)
click to toggle source
# File lib/maxima/unit.rb, line 22 def self.parse_float(m) Rational.parse(m) || Complex.parse(m) end
Public Instance Methods
==(other)
click to toggle source
Basic string identity
# File lib/maxima/unit.rb, line 107 def ==(other) (self <=> other) == 0 end
===(other)
click to toggle source
True mathematical equivalence
# File lib/maxima/unit.rb, line 112 def ===(other) (self == other) || Maxima.equivalence(self, other)[:is_equal] end
at(_)
click to toggle source
# File lib/maxima/unit.rb, line 59 def at(_) self end
gnu_plot_options()
click to toggle source
# File lib/maxima/unit.rb, line 72 def gnu_plot_options { w: gnu_plot_w }.tap do |options| options[:plot_title] = @plot_title if @plot_title end end
gnu_plot_text()
click to toggle source
private
# File lib/maxima/unit.rb, line 68 def gnu_plot_text to_s end
gnu_plot_w()
click to toggle source
# File lib/maxima/unit.rb, line 78 def gnu_plot_w "points" end
imaginary?()
click to toggle source
# File lib/maxima/unit.rb, line 90 def imaginary? throw "imaginary_is_undecidable_for_#{self.class}" end
inspect()
click to toggle source
# File lib/maxima/unit.rb, line 10 def inspect if plot_title.nil? || plot_title == "" "#{self.class}(#{self})" else "#{self.class}[#{plot_title}](#{self})" end end
negative?()
click to toggle source
# File lib/maxima/unit.rb, line 102 def negative? to_f < 0 end
positive?()
click to toggle source
# File lib/maxima/unit.rb, line 94 def positive? to_f > 0 end
real?()
click to toggle source
# File lib/maxima/unit.rb, line 86 def real? throw "real_is_undecidable_for_#{self.class}" end
simplified()
click to toggle source
# File lib/maxima/unit.rb, line 40 def simplified @simplified ||= through_maxima(:expand) end
through_maxima(*array_options, **options)
click to toggle source
~~ *unary_operations, **unary_operations_options
# File lib/maxima/unit.rb, line 45 def through_maxima(*array_options, **options) @after_maxima ||= Command.output(itself: Unit) do |c| c.let :itself, self.to_s, *array_options, **options end[:itself] end
to_f()
click to toggle source
# File lib/maxima/unit.rb, line 82 def to_f throw "cannot_cast_#{self.class}_to_float" end
to_gnu_plot()
click to toggle source
# File lib/maxima/unit.rb, line 55 def to_gnu_plot [gnu_plot_text, gnu_plot_options] end
to_maxima_input()
click to toggle source
# File lib/maxima/unit.rb, line 51 def to_maxima_input to_s end
to_pdf(t0, t1, v: "x")
click to toggle source
# File lib/maxima/unit.rb, line 63 def to_pdf(t0, t1, v: "x") (self / integral(t0, t1)).definite_integral(t0, v) end
to_s()
click to toggle source
# File lib/maxima/unit.rb, line 26 def to_s @maxima_output end
with_plot_title(plot_title)
click to toggle source
# File lib/maxima/unit.rb, line 30 def with_plot_title(plot_title) self.class.new(@maxima_output, plot_title) end
zero?()
click to toggle source
# File lib/maxima/unit.rb, line 98 def zero? to_f == 0 end