class Quantizer

Defined in:

quantizer.cr
quantizer/version.cr

Constant Summary

EPS = 1e-7
KSub = 1 << Quantizer::NBits
MaxPoints = MaxPointsPerCluster * KSub
MaxPointsPerCluster = 256
NBits = 8
VERSION = "0.1.0"

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(dim : Int32, dsub : Int32, centroids : Pointer(Float32) = Pointer(Float32).malloc(dim * KSub, 0_f32)) #

[View source]

Class Method Detail

def self.from_io(io : IO, format : IO::ByteFormat) #

[View source]

Instance Method Detail

def assign_centroid(x : Pointer(Float32), c0 : Pointer(Float32), code : Pointer(UInt8), d : Int32) : Float32 #

[View source]
def assign_code(x : Pointer(Float32), code : Pointer(UInt8)) #

[View source]
def assign_codes(x : Pointer(Float32), code : Pointer(UInt8), n : Int32) #

[View source]
def centroids(m : Int32, i : UInt8) : Pointer(Float32) #

[View source]
def dist_l2(x : Pointer(Float32), y : Pointer(Float32), d : Int32) #

[View source]
def e_step(x : Pointer(Float32), centroids : Pointer(Float32), codes : Pointer(UInt8), n : Int32, d : Int32) #

[View source]
def each_centroid(codes : Pointer(UInt8), &) #

[View source]
def kmeans(x : Pointer(Float32), c : Pointer(Float32), n : Int32, d : Int32, iter : Int32) #

[View source]
def m_step(x0 : Pointer(Float32), centroids : Pointer(Float32), codes : Pointer(UInt8), n : Int32, d : Int32) #

[View source]
def to_io(io : IO, format : IO::ByteFormat) #

[View source]
def train(n : Int32, x : Pointer(Float32), iter : Int32 = 25) #

[View source]