class GSL::Vector
- GSL::Vector
- Reference
- Object
Defined in:
gsl/base/iterator.crgsl/base/vector.cr
gsl/maths/basic/vector.cr
gsl/maths/statistics/vector.cr
Constructors
Instance Method Summary
- #*(n : Int32 | Float64)
- #*(n : GSL::Vector)
- #+(n : Int32 | Float64)
- #+(n : GSL::Vector)
- #-(n : Int32 | Float64)
- #-(n : GSL::Vector)
- #/(n : GSL::Vector)
- #/(n : Int32 | Float64)
- #<<(n : Float64 | Int32) : Vector
- #==(n : GSL::Vector) : Bool
- #[](i) : Float64
- #[]=(i, x) : Float64
-
#concat(n : GSL::Vector) : Vector
concatinate two different vector and return a new vector
- #copy
- #dot(n : GSL::Vector)
- #each(&block : Float64 -> _)
-
#empty? : Bool
return true if current vector's elements are all 0
- #first : Float64
-
#freqs
alias for frequencies
- #frequencies
- #getPointer
- #has_neg? : Bool
- #head : Vector
- #includes?(n : Float64 | Int32) : Bool
-
#inner_product(n : GSL::Vector)
same as dot function
-
#inspect
Returns a
String
representation of this object suitable to be embedded inside other expressions, sometimes providing more information about this object. - #last : Float64
- #map(&block : Float64 -> _)
- #max : Float64
-
#max_index : UInt64
return the index of maximum value of current vector note: if there are multiple same maximum value then only return the first one.
-
#mean : Float64
calculate the mean of the vector's elements
-
#min : Float64
return the minimum value of current vector note: if there are multiple same minimum value then only return once
- #min_index : UInt64
-
#minmax : Array(Float64)
return the minimum and maximun values of current vector
- #minmax_index : Array(UInt64)
- #mode
- #neg? : Bool
- #pointer : Pointer(LibGSL::Gsl_vector)
- #pos? : Bool
- #proportion(n : Float64 | Int32)
- #push(n : Float64 | Int32) : Vector
- #ranked
- #replace(n : GSL::Vector) : Vector
- #reverse
- #reverse! : Vector
- #set_all(n : Int32 | Float64) : Vector
- #set_all!(n : Int32 | Float64) : Vector
- #set_basis(n : Int32) : Vector
- #set_basis!(n : Int32) : Vector
- #set_zero : Vector
- #set_zero! : Vector
- #size : Int32
- #sort : Vector
-
#sort! : Vector
change current vector in ascending order
- #sum
- #tail : Vector
-
#to_a : Array(Float64)
alias to to_array
- #to_array : Array(Float64)
-
#to_s : String
Returns a string representation of this object.
Constructor Detail
Instance Method Detail
concatinate two different vector and return a new vector
a = [1,2,3].to_vector
b = [2,3,4].to_vector
a.concat b => GSL::Vector: [1.0,2.0,3.0,2.0,3.0,4.0]
return true if current vector's elements are all 0
a = [0,0,0].to_vector
b = [1,0,0].to_vector
a.empty? => true
b.empty? => false
Returns a String
representation of this object suitable
to be embedded inside other expressions, sometimes providing
more information about this object.
#inspect
(and #inspect(io)
) are the methods used when
you invoke #to_s
or #inspect
on an object that holds
other objects and wants to show them. For example when you
invoke Array#to_s
, #inspect
will be invoked on each element:
ary = ["one", "two", "three, etc."]
ary.inspect # => ["one", "two", "three, etc."]
Note that if Array invoked #to_s
on each of the elements
above, the output would have been this:
ary = ["one", "two", "three, etc."]
# If inspect invoked to_s on each element...
ary.inspect # => [one, two, three, etc.]
Note that it's not clear how many elements the array has,
or which are they, because #to_s
doesn't guarantee that
the string representation is clearly delimited (in the case
of String
the quotes are not shown).
Also note that sometimes the output of #inspect
will look
like a Crystal expression that will compile, but this isn't
always the case, nor is it necessary. Notably, Reference#inspect
and Struct#inspect
return values that don't compile.
Classes must usually not override this method. Instead,
they must override inspect(io)
, which must append to the
given IO
object.
return the index of maximum value of current vector note: if there are multiple same maximum value then only return the first one.
a = [1,2,3].to_vector
a.max_index => 2
calculate the mean of the vector's elements
a = [0.0, -5.0, 7.3].to_vector.mean
a => 0.76666666666666661
return the minimum value of current vector note: if there are multiple same minimum value then only return once
a = [1,2,3].to_vector
a.min => 1.0
return the minimum and maximun values of current vector
a = [1,2,3].to_vector
min, max = a.minmax
min => 1.0
max => 3.0
change current vector in ascending order
a = [2,5,3,7,1].to_vector
a.sort! => GSL::Vector: [1.0,2.0,3.0,5.0,7.0]
a => GSL::Vector: [1.0,2.0,3.0,5.0,7.0]
Returns a string representation of this object.
Descendants must usually not override this method. Instead,
they must override to_s(io)
, which must append to the given
IO object.