Class: Steffi::Vector
- Inherits:
-
Object
- Object
- Steffi::Vector
- Includes:
- Enumerable
- Defined in:
- lib/steffi/vector.rb
Defined Under Namespace
Classes: Struct
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(obj) ⇒ Object
- #[](i) ⇒ Object
- #[]=(i, obj) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Vector
constructor
A new instance of Vector.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
permalink #ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
26 27 28 |
# File 'lib/steffi/vector.rb', line 26 def ptr @ptr end |
Class Method Details
permalink .from_a(ary) ⇒ Object
[View source]
57 58 59 60 61 |
# File 'lib/steffi/vector.rb', line 57 def self.from_a ary v = new ary.each { |i| v << i } v end |
Instance Method Details
permalink #<<(obj) ⇒ Object
[View source]
33 34 35 |
# File 'lib/steffi/vector.rb', line 33 def << obj Igraph.vector_push_back ptr, obj.to_f end |
permalink #[](i) ⇒ Object
[View source]
37 38 39 |
# File 'lib/steffi/vector.rb', line 37 def [] i Igraph.vector_e ptr, i end |
permalink #[]=(i, obj) ⇒ Object
[View source]
41 42 43 |
# File 'lib/steffi/vector.rb', line 41 def []= i, obj Igraph.vector_set ptr, i, obj.to_f end |
permalink #each ⇒ Object
[View source]
49 50 51 |
# File 'lib/steffi/vector.rb', line 49 def each 0.upto(size-1) { |i| yield self[i] } end |
permalink #size ⇒ Object
[View source]
45 46 47 |
# File 'lib/steffi/vector.rb', line 45 def size Igraph.vector_size ptr end |
permalink #to_s ⇒ Object
[View source]
53 54 55 |
# File 'lib/steffi/vector.rb', line 53 def to_s to_a.to_s end |