Module: DaruLite::Maths::Arithmetic::Vector
- Included in:
- Vector
- Defined in:
- lib/daru_lite/maths/arithmetic/vector.rb
Instance Method Summary collapse
- #%(other) ⇒ Object
- #*(other) ⇒ Object
- #**(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #/(other) ⇒ Object
- #abs ⇒ Object
-
#add(other, opts = {}) ⇒ Object
Add specified vector.
- #exp ⇒ Object
- #round(precision = 0) ⇒ Object
- #sqrt ⇒ Object
Instance Method Details
#%(other) ⇒ Object
21 22 23 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 21 def %(other) binary_op :%, other end |
#*(other) ⇒ Object
13 14 15 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 13 def *(other) binary_op :*, other end |
#**(other) ⇒ Object
25 26 27 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 25 def **(other) binary_op :**, other end |
#+(other) ⇒ Object
5 6 7 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 5 def +(other) binary_op :+, other end |
#-(other) ⇒ Object
9 10 11 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 9 def -(other) binary_op :-, other end |
#/(other) ⇒ Object
17 18 19 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 17 def /(other) binary_op :/, other end |
#abs ⇒ Object
37 38 39 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 37 def abs recode { |e| e&.abs } end |
#add(other, opts = {}) ⇒ Object
Add specified vector.
69 70 71 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 69 def add(other, opts = {}) v2v_binary :+, other, skipnil: opts.fetch(:skipnil, false) end |
#exp ⇒ Object
29 30 31 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 29 def exp math_unary_op :exp end |
#round(precision = 0) ⇒ Object
41 42 43 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 41 def round(precision = 0) recode { |e| e&.round(precision) } end |
#sqrt ⇒ Object
33 34 35 |
# File 'lib/daru_lite/maths/arithmetic/vector.rb', line 33 def sqrt math_unary_op :sqrt end |