Method: Daru::Vector#cast
- Defined in:
- lib/daru/vector.rb
#cast(opts = {}) ⇒ Object
Cast a vector to a new data type.
Options
-
:dtype- :array for Ruby Array. :nmatrix for NMatrix.
551 552 553 554 555 556 |
# File 'lib/daru/vector.rb', line 551 def cast opts={} dt = opts[:dtype] raise ArgumentError, "Unsupported dtype #{opts[:dtype]}" unless %i[array nmatrix gsl].include?(dt) @data = cast_vector_to dt unless @dtype == dt end |