Class: Daru::Accessors::GSLWrapper
- Inherits:
-
Object
- Object
- Daru::Accessors::GSLWrapper
show all
- Extended by:
- Forwardable
- Includes:
- GSLStatistics, Enumerable
- Defined in:
- lib/daru/accessors/gsl_wrapper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#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.
85
86
87
88
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 85
def initialize data, context
@data = ::GSL::Vector.alloc(data)
@context = context
end
|
Instance Attribute Details
Returns the value of attribute data.
61
62
63
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 61
def data
@data
end
|
Instance Method Details
#==(other) ⇒ Object
117
118
119
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 117
def == other
@data == other.data
end
|
#[]=(index, element) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 90
def []= index, element
if index == size
push element
else
@data[index] = element
end
end
|
63
64
65
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 63
def compact
::GSL::Vector.alloc(@data.to_a - [Float::NAN])
end
|
#delete_at(index) ⇒ Object
98
99
100
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 98
def delete_at index
@data.delete_at index
end
|
113
114
115
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 113
def dup
GSLWrapper.new(@data.to_a, @context)
end
|
#each(&block) ⇒ Object
75
76
77
78
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 75
def each(&block)
@data.each(&block)
self
end
|
#index(key) ⇒ Object
102
103
104
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 102
def index key
@data.to_a.index key
end
|
#map!(&block) ⇒ Object
80
81
82
83
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 80
def map!(&block)
@data.map!(&block)
self
end
|
#push(value) ⇒ Object
Also known as:
<<, concat
106
107
108
109
|
# File 'lib/daru/accessors/gsl_wrapper.rb', line 106
def push value
@data = @data.concat value
self
end
|