Class: Relax4::IntegerArray
- Inherits:
-
Object
- Object
- Relax4::IntegerArray
- Defined in:
- lib/relax4.rb
Overview
Provided by SWIG for exchanging data with the solver. Intended for internal use; see relax4_init in relax4.h, above. You do not have to use this if you call solve.
Class Method Summary collapse
-
.from_array(a) ⇒ IntegerArray
Create from Ruby Array of Integers; creates C array of appropriate length and copies the Ruby values in.
Instance Method Summary collapse
-
#assign!(a) ⇒ IntegerArray
Set elements from Ruby Array; array length is not checked.
-
#to_a!(size) ⇒ Array<Integer>
Convert to Ruby Array of given size; array length is not checked.
Class Method Details
.from_array(a) ⇒ IntegerArray
Create from Ruby Array of Integers; creates C array of appropriate length and copies the Ruby values in.
299 300 301 302 |
# File 'lib/relax4.rb', line 299 def self.from_array a ia = self.new(a.size) or raise 'failed to create IntegerArray' ia.assign! a end |
Instance Method Details
#assign!(a) ⇒ IntegerArray
Set elements from Ruby Array; array length is not checked.
because array bounds are not checked.
312 313 314 315 316 317 |
# File 'lib/relax4.rb', line 312 def assign! a for i in 0...a.size self[i] = a[i] end self end |
#to_a!(size) ⇒ Array<Integer>
Convert to Ruby Array of given size; array length is not checked.
324 325 326 327 328 329 330 |
# File 'lib/relax4.rb', line 324 def to_a! size a = Array.new(size) for i in 0...a.size a[i] = self[i] end a end |