class Algebra::Scalar
Public Class Methods
new(x)
click to toggle source
# File lib/algebra/matrix-algebra.rb, line 856 def initialize(x) @value = x end
Public Instance Methods
*(other)
click to toggle source
# File lib/algebra/matrix-algebra.rb, line 878 def *(other) case other when Algebra::MatrixAlgebra other.matrix{|i, j| @value * other[i, j]} else raise "Fail: Scalar(#{@value}) * #{other}" end end
+(other)
click to toggle source
# File lib/algebra/matrix-algebra.rb, line 860 def +(other) case other when Algebra::SquareMatrix other.const(@value) + other else raise "Fail: Scalar(#{@value}) + #{other}" end end
-(other)
click to toggle source
# File lib/algebra/matrix-algebra.rb, line 869 def -(other) case other when Algebra::SquareMatrix other.const(@value) - other else raise "Fail: Scalar(#{@value}) - #{other}" end end