Class: Rust::MathArray
- Inherits:
-
Array
show all
- Defined in:
- lib/rust/core/types/utils.rb
Instance Method Summary
collapse
Methods inherited from Array
#_rust_prob_distance, #distribution, #to_R
Instance Method Details
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/rust/core/types/utils.rb', line 72
def *(other)
raise ArgumentError, "Expected array or numeric" if !other.is_a?(::Array) && !other.is_a?(Numeric)
raise ArgumentError, "The two arrays must have the same size" if other.is_a?(::Array) && self.size != other.size
result = self.clone
other = [other] * self.size if other.is_a?(Numeric)
for i in 0...self.size
result[i] *= other[i]
end
return result
end
|
#**(other) ⇒ Object
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/rust/core/types/utils.rb', line 111
def **(other)
raise ArgumentError, "Expected numeric" if !other.is_a?(Numeric)
result = self.clone
for i in 0...self.size
result[i] = result[i] ** other
end
return result
end
|
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/rust/core/types/utils.rb', line 85
def +(other)
raise ArgumentError, "Expected array or numeric" if !other.is_a?(::Array) && !other.is_a?(Numeric)
raise ArgumentError, "The two arrays must have the same size" if other.is_a?(::Array) && self.size != other.size
result = self.clone
other = [other] * self.size if other.is_a?(Numeric)
for i in 0...self.size
result[i] += other[i]
end
return result
end
|
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rust/core/types/utils.rb', line 59
def -(other)
raise ArgumentError, "Expected array or numeric" if !other.is_a?(::Array) && !other.is_a?(Numeric)
raise ArgumentError, "The two arrays must have the same size" if other.is_a?(::Array) && self.size != other.size
result = self.clone
other = [other] * self.size if other.is_a?(Numeric)
for i in 0...self.size
result[i] -= other[i]
end
return result
end
|
/# <- this comment is just to recover the syntax highlighting bug in Kate
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/rust/core/types/utils.rb', line 98
def /(other) raise ArgumentError, "Expected array or numeric" if !other.is_a?(::Array) && !other.is_a?(Numeric)
raise ArgumentError, "The two arrays must have the same size" if other.is_a?(::Array) && self.size != other.size
result = self.clone
other = [other] * self.size if other.is_a?(Numeric)
for i in 0...self.size
result[i] /= other[i]
end
return result
end
|