Documentation ¶
Index ¶
- Variables
- func Float32Serialize(m *Float32Matrix, fn string) error
- func Float32VectorSum(data []float32) float32
- func Uint32Serialize(m *Uint32Matrix, fn string) error
- func Uint32VectorSum(data []uint32) uint32
- type DocWord
- type Float32Matrix
- type SortedMap
- func (this *SortedMap) Decr(wordId uint32, topicId uint32, count uint32)
- func (this *SortedMap) Deserialize(fn string) error
- func (this *SortedMap) Get(wordId uint32, idx int) (uint32, uint32)
- func (this *SortedMap) Incr(wordId uint32, topicId uint32, count uint32)
- func (this *SortedMap) Serialize(fn string) error
- type Uint32Matrix
- func (m *Uint32Matrix) Decr(r, c uint32, val uint32)
- func (m *Uint32Matrix) Get(r, c uint32) uint32
- func (m *Uint32Matrix) GetCol(c uint32) []uint32
- func (m *Uint32Matrix) GetRow(r uint32) []uint32
- func (m *Uint32Matrix) Incr(r, c uint32, val uint32)
- func (m *Uint32Matrix) Set(r, c uint32, val uint32)
- func (m *Uint32Matrix) Shape() (uint32, uint32)
Constants ¶
This section is empty.
Variables ¶
var ( ErrIndexOutOfRange = errors.New("matrix: index out of range") ErrBadShape = errors.New("matrix: non-positive dimension not allowed") )
Functions ¶
func Float32Serialize ¶
func Float32Serialize(m *Float32Matrix, fn string) error
serialize data to file
func Uint32Serialize ¶
func Uint32Serialize(m *Uint32Matrix, fn string) error
serialize data to file
Types ¶
type Float32Matrix ¶
type Float32Matrix struct {
// contains filtered or unexported fields
}
internal Float32 matrix representation
func Float32Deserialize ¶
func Float32Deserialize(fn string) (*Float32Matrix, error)
deserialize data from file
func NewFloat32Matrix ¶
func NewFloat32Matrix(r, c uint32) *Float32Matrix
NewFloat32Matrix creates a new Float32Matrix with r rows and c columns which is mainly used for caching temporary results
func (*Float32Matrix) Get ¶
func (m *Float32Matrix) Get(r, c uint32) float32
get the [r, c]-th element of the matrix
func (*Float32Matrix) Set ¶
func (m *Float32Matrix) Set(r, c uint32, val float32)
set val to the [r, c]-th element of the matrix
func (*Float32Matrix) Shape ¶
func (m *Float32Matrix) Shape() (uint32, uint32)
get the shape of the matrix
type SortedMap ¶
type SortedMap struct { Data map[uint32][]uint32 RotateLen uint32 TopicMask uint32 MaxWordId uint32 MaxTopicId uint32 }
var ( // Cache nonzero topic count of word and the values // are sorted by count in descending order. Each value // is represented by a uint32 number where the lower k // bits are the minimum bits needed to hold the max number // of topics and the upper 32-k bits are used to hold the // count number WordTopicMap *SortedMap )
func NewSortedMap ¶
func (*SortedMap) Deserialize ¶
deserialize data from file
type Uint32Matrix ¶
type Uint32Matrix struct {
// contains filtered or unexported fields
}
internal Uint32 matrix representation
func NewUint32Matrix ¶
func NewUint32Matrix(r, c uint32) *Uint32Matrix
NewUint32Matrix creates a new Uint32Matrix with r rows and c columns. if r*c <= 0, it will panic. A uint32 slice is used as the underlying storage and the data layout is in row major order, i.e. the (i*c + j)-th element in the data slice is the [i, j]-th element in the matrix. Vector is defined as a matrix one column, i.e. a column vector.
func Uint32Deserialize ¶
func Uint32Deserialize(fn string) (*Uint32Matrix, error)
deserialize data from file
func (*Uint32Matrix) Decr ¶
func (m *Uint32Matrix) Decr(r, c uint32, val uint32)
decrement the [r, c]-th element of the matrix by val
func (*Uint32Matrix) Get ¶
func (m *Uint32Matrix) Get(r, c uint32) uint32
get the [r, c]-th element of the matrix
func (*Uint32Matrix) GetCol ¶
func (m *Uint32Matrix) GetCol(c uint32) []uint32
get the c-th column of the matrix
func (*Uint32Matrix) GetRow ¶
func (m *Uint32Matrix) GetRow(r uint32) []uint32
get the r-th row of the matrix
func (*Uint32Matrix) Incr ¶
func (m *Uint32Matrix) Incr(r, c uint32, val uint32)
increment the [r, c]-th element of the matrix by val
func (*Uint32Matrix) Set ¶
func (m *Uint32Matrix) Set(r, c uint32, val uint32)
set val to the [r, c]-th element of the matrix
func (*Uint32Matrix) Shape ¶
func (m *Uint32Matrix) Shape() (uint32, uint32)
get the shape of the matrix