Example #1
0
func (this *TPAQMixer) get() int {
	for this.idx&7 != 0 {
		this.buffer[this.ctx+this.idx] = 64
		this.idx++
	}

	// Neural Network dot product (sum weights*inputs)
	p := (this.buffer[this.ctx] * this.buffer[this.ctx+8]) +
		(this.buffer[this.ctx+1] * this.buffer[this.ctx+9]) +
		(this.buffer[this.ctx+2] * this.buffer[this.ctx+10]) +
		(this.buffer[this.ctx+3] * this.buffer[this.ctx+11]) +
		(this.buffer[this.ctx+4] * this.buffer[this.ctx+12]) +
		(this.buffer[this.ctx+5] * this.buffer[this.ctx+13]) +
		(this.buffer[this.ctx+6] * this.buffer[this.ctx+14]) +
		(this.buffer[this.ctx+7] * this.buffer[this.ctx+15])

	this.pr = kanzi.Squash(p >> 15)
	return this.pr
}
Example #2
0
func newPAQAdaptiveProbMap(n, rate uint) (*PAQAdaptiveProbMap, error) {
	this := new(PAQAdaptiveProbMap)
	this.data = make([]int, n*33)
	this.rate = rate
	k := 0

	for i := uint(0); i < n; i++ {
		for j := 0; j < 33; j++ {
			if i == 0 {
				this.data[k+j] = kanzi.Squash((j-16)<<7) << 4
			} else {
				this.data[k+j] = this.data[j]
			}
		}

		k += 33
	}

	return this, nil
}