Class: Daru::Accessors::GSLWrapper

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
GSLStatistics, Enumerable
Defined in:
lib/daru/accessors/gsl_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GSLStatistics

#kurtosis, #median, #sample_with_replacement, #sample_without_replacement, #skew, #standard_deviation_population, #standard_deviation_sample, #variance_population, #variance_sample, #vector_centered_compute, #vector_standardized_compute

Constructor Details

#initialize(data, context) ⇒ GSLWrapper

Returns a new instance of GSLWrapper.



86
87
88
89
# File 'lib/daru/accessors/gsl_wrapper.rb', line 86

def initialize data, context
  @data = ::GSL::Vector.alloc(data)
  @context = context
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



62
63
64
# File 'lib/daru/accessors/gsl_wrapper.rb', line 62

def data
  @data
end

Instance Method Details

#==(other) ⇒ Object



118
119
120
# File 'lib/daru/accessors/gsl_wrapper.rb', line 118

def == other
  @data == other.data
end

#[]=(index, element) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/daru/accessors/gsl_wrapper.rb', line 91

def []= index, element
  if index == size
    push element
  else
    @data[index] = element
  end
end

#compactObject



64
65
66
# File 'lib/daru/accessors/gsl_wrapper.rb', line 64

def compact
  ::GSL::Vector.alloc(@data.to_a - [Float::NAN])
end

#delete_at(index) ⇒ Object



99
100
101
# File 'lib/daru/accessors/gsl_wrapper.rb', line 99

def delete_at index
  @data.delete_at index
end

#dupObject



114
115
116
# File 'lib/daru/accessors/gsl_wrapper.rb', line 114

def dup
  GSLWrapper.new(@data.to_a, @context)
end

#each(&block) ⇒ Object



76
77
78
79
# File 'lib/daru/accessors/gsl_wrapper.rb', line 76

def each(&block)
  @data.each(&block)
  self
end

#index(key) ⇒ Object



103
104
105
# File 'lib/daru/accessors/gsl_wrapper.rb', line 103

def index key
  @data.to_a.index key
end

#map!(&block) ⇒ Object



81
82
83
84
# File 'lib/daru/accessors/gsl_wrapper.rb', line 81

def map!(&block)
  @data.map!(&block)
  self
end

#push(value) ⇒ Object Also known as: <<, concat



107
108
109
110
# File 'lib/daru/accessors/gsl_wrapper.rb', line 107

def push value
  @data = @data.concat value
  self
end