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.


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

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data


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

def data
  @data
end

Instance Method Details

#==(other) ⇒ Object


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

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

#[]=(index, element) ⇒ Object


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

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

#delete_at(index) ⇒ Object


89
90
91
# File 'lib/daru/accessors/gsl_wrapper.rb', line 89

def delete_at index
  @data.delete_at index
end

#dupObject


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

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

#each(&block) ⇒ Object


66
67
68
69
# File 'lib/daru/accessors/gsl_wrapper.rb', line 66

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

#index(key) ⇒ Object


93
94
95
# File 'lib/daru/accessors/gsl_wrapper.rb', line 93

def index key
  @data.to_a.index key
end

#map!(&block) ⇒ Object


71
72
73
74
# File 'lib/daru/accessors/gsl_wrapper.rb', line 71

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

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


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

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