class Matrix::Scalar

:nodoc:

def *(other)

def *(other)
  case other
  when Numeric
    Scalar.new(@value * other)
  when Vector, Matrix
    other.collect{|e| @value * e}
  else
    apply_through_coercion(other, __method__)
  end
end

def **(other)

def **(other)
  case other
  when Numeric
    Scalar.new(@value ** other)
  when Vector
    Scalar.Raise ErrOperationNotDefined, "**", @value.class, other.class
  when Matrix
    #other.powered_by(self)
    Scalar.Raise ErrOperationNotImplemented, "**", @value.class, other.class
  else
    apply_through_coercion(other, __method__)
  end
end

def +(other)

ARITHMETIC
def +(other)
  case other
  when Numeric
    Scalar.new(@value + other)
  when Vector, Matrix
    Scalar.Raise ErrOperationNotDefined, "+", @value.class, other.class
  else
    apply_through_coercion(other, __method__)
  end
end

def -(other)

def -(other)
  case other
  when Numeric
    Scalar.new(@value - other)
  when Vector, Matrix
    Scalar.Raise ErrOperationNotDefined, "-", @value.class, other.class
  else
    apply_through_coercion(other, __method__)
  end
end

def /(other)

def /(other)
  case other
  when Numeric
    Scalar.new(@value / other)
  when Vector
    Scalar.Raise ErrOperationNotDefined, "/", @value.class, other.class
  when Matrix
    self * other.inverse
  else
    apply_through_coercion(other, __method__)
  end
end

def initialize(value)

def initialize(value)
  @value = value
end