Beispiel #1
0
func NewVector(size int) *Vector {
	return &Vector{
		&DenseVec{
			common.NewCoreVec(false, size, 0, 1),
			make([]float64, size),
		},
	}
}
Beispiel #2
0
func NewSparseVector(size int) *Vector {
	return &Vector{
		&SparseVec{
			common.NewCoreVec(false, size, 0, 1),
			make(map[int]float64),
		},
	}
}
Beispiel #3
0
func (sv *SparseVec) ViewSelectionLike(offsets []int) Vec {
	return &SelectedSparseVec{
		&SparseVec{
			common.NewCoreVec(false, len(offsets), 0, 1),
			sv.elements,
		},
		offsets, 0,
	}
}
Beispiel #4
0
func (v *SelectedSparseVec) ViewVec() Vec {
	return &SelectedSparseVec{
		&SparseVec{
			common.NewCoreVec(false, v.Size(), 0, 1),
			v.elements,
		},
		v.offsets, v.offset,
	}
}
Beispiel #5
0
func (v *DenseVec) ViewSelectionLike(offsets []int) Vec {
	return &SelectedDenseVec{
		&DenseVec{
			common.NewCoreVec(false, len(offsets), 0, 1),
			v.elements,
		},
		offsets, 0,
	}
}
Beispiel #6
0
func (sv *SparseVec) ViewVec() Vec {
	return &SparseVec{
		common.NewCoreVec(sv.IsView(), sv.Size(), sv.Zero(), sv.Stride()),
		sv.elements,
	}
}
Beispiel #7
0
func (sv *SparseVec) Like(size int) Vec {
	return &SparseVec{
		common.NewCoreVec(false, size, 0, 1),
		make(map[int]float64),
	}
}
Beispiel #8
0
func (v *DenseVec) ViewVec() Vec {
	return &DenseVec{
		common.NewCoreVec(v.IsView(), v.Size(), v.Zero(), v.Stride()),
		v.elements,
	}
}
Beispiel #9
0
func (v *DenseVec) Like(size int) Vec {
	return &DenseVec{
		common.NewCoreVec(false, size, 0, 1),
		make([]float64, size),
	}
}