class GSL::Vector

Defined in:

gsl/base/iterator.cr
gsl/base/vector.cr
gsl/maths/basic/vector.cr
gsl/maths/statistics/vector.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(size : Int32) #

[View source]
def self.new(a : Array(Float64)) #

[View source]

Instance Method Detail

def *(n : Int32 | Float64) #

[View source]
def *(n : GSL::Vector) #

[View source]
def +(n : Int32 | Float64) #

[View source]
def +(n : GSL::Vector) #

[View source]
def -(n : Int32 | Float64) #

[View source]
def -(n : GSL::Vector) #

[View source]
def /(n : GSL::Vector) #

[View source]
def /(n : Int32 | Float64) #

[View source]
def <<(n : Float64 | Int32) : Vector #

[View source]
def ==(n : GSL::Vector) : Bool #

[View source]
def [](i) : Float64 #

[View source]
def []=(i, x) : Float64 #

[View source]
def concat(n : GSL::Vector) : Vector #

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]

[View source]
def copy #

[View source]
def dot(n : GSL::Vector) #

[View source]
def each(&block : Float64 -> _) #

[View source]
def empty? : Bool #

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

[View source]
def first : Float64 #

[View source]
def freqs #

alias for frequencies


[View source]
def frequencies #

[View source]
def getPointer #

[View source]
def has_neg? : Bool #

[View source]
def head : Vector #

[View source]
def includes?(n : Float64 | Int32) : Bool #

[View source]
def inner_product(n : GSL::Vector) #

same as dot function


[View source]
def inspect #
Description copied from class Object

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.


[View source]
def last : Float64 #

[View source]
def map(&block : Float64 -> _) #

[View source]
def max : Float64 #

[View source]
def 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.

a = [1,2,3].to_vector
a.max_index => 2

[View source]
def mean : Float64 #

calculate the mean of the vector's elements

a = [0.0, -5.0, 7.3].to_vector.mean
a => 0.76666666666666661

[View source]
def min : Float64 #

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

[View source]
def min_index : UInt64 #

[View source]
def minmax : Array(Float64) #

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

[View source]
def minmax_index : Array(UInt64) #

[View source]
def mode #

[View source]
def neg? : Bool #

[View source]
def pointer : Pointer(LibGSL::Gsl_vector) #

[View source]
def pos? : Bool #

[View source]
def proportion(n : Float64 | Int32) #

[View source]
def push(n : Float64 | Int32) : Vector #

[View source]
def ranked #

[View source]
def replace(n : GSL::Vector) : Vector #

[View source]
def reverse #

[View source]
def reverse! : Vector #

[View source]
def set_all(n : Int32 | Float64) : Vector #

[View source]
def set_all!(n : Int32 | Float64) : Vector #

[View source]
def set_basis(n : Int32) : Vector #

[View source]
def set_basis!(n : Int32) : Vector #

[View source]
def set_zero : Vector #

[View source]
def set_zero! : Vector #

[View source]
def size : Int32 #

[View source]
def sort : Vector #

[View source]
def sort! : Vector #

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]

[View source]
def sum #

[View source]
def tail : Vector #

[View source]
def to_a : Array(Float64) #

alias to to_array


[View source]
def to_array : Array(Float64) #

[View source]
def to_s : String #
Description copied from class Object

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.


[View source]