[フレーム]

Class: Matrix::Scalar

Inherits:
Numeric show all
Includes:
ExceptionForMatrix , CoercionHelper
Defined in:
opal/stdlib/matrix.rb

Overview

Private CLASS

Constant Summary

Constants included from Exception2MessageMapper

Exception2MessageMapper::E2MM

Instance Method Summary collapse

Methods included from CoercionHelper

coerce_to , coerce_to_int , coerce_to_matrix

Methods included from Exception2MessageMapper

#Fail , Raise , #Raise , #bind , def_e2message , #def_e2message , #def_exception , def_exception , e2mm_message , extend_object , #fail

Methods inherited from Numeric

#to_json , #to_n

Constructor Details

#initialize(value) ⇒ Scalar

Returns a new instance of Scalar.

1579
1580
1581
# File 'opal/stdlib/matrix.rb', line 1579
def initialize(value)
 @value = value
end

Instance Method Details

#*(other) ⇒ Object

1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
# File 'opal/stdlib/matrix.rb', line 1606
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

#**(other) ⇒ Object

1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
# File 'opal/stdlib/matrix.rb', line 1630
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

#+(other) ⇒ Object

ARITHMETIC

1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
# File 'opal/stdlib/matrix.rb', line 1584
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

#-(other) ⇒ Object

1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
# File 'opal/stdlib/matrix.rb', line 1595
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

#/(other) ⇒ Object

1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
# File 'opal/stdlib/matrix.rb', line 1617
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

AltStyle によって変換されたページ (->オリジナル) /