func main() {
	showLU(mat.MakeDenseMatrixStacked([][]float64{
		{1, 3, 5},
		{2, 4, 7},
		{1, 1, 0}}))
	showLU(mat.MakeDenseMatrixStacked([][]float64{
		{11, 9, 24, 2},
		{1, 5, 2, 6},
		{3, 17, 18, 1},
		{2, 5, 7, 1}}))
}
func main() {
	m := mat.MakeDenseMatrixStacked([][]float64{
		{1, 2, 3},
		{4, 5, 6},
	})
	fmt.Println("original:")
	fmt.Println(m)
	m = m.Transpose()
	fmt.Println("transpose:")
	fmt.Println(m)
}
func main() {
	a := mat.MakeDenseMatrixStacked([][]float64{
		{1, 2, 3, 4},
		{5, 6, 7, 8},
	})
	b := mat.MakeDenseMatrixStacked([][]float64{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9},
		{10, 11, 12},
	})
	fmt.Printf("Matrix A:\n%v\n", a)
	fmt.Printf("Matrix B:\n%v\n", b)
	p, err := a.TimesDense(b)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Product of A and B:\n%v\n", p)
}
예제 #4
0
func Wishart(n int, V *m.DenseMatrix) func() *m.DenseMatrix {
	p := V.Rows()
	zeros := m.Zeros(p, 1)
	rowGen := MVNormal(zeros, V)
	return func() *m.DenseMatrix {
		x := make([][]float64, n)
		for i := 0; i < n; i++ {
			x[i] = rowGen().Array()
		}
		X := m.MakeDenseMatrixStacked(x)
		S, _ := X.Transpose().TimesDense(X)
		return S
	}
}
예제 #5
0
파일: eigen.go 프로젝트: postfix/gofaces
func (eigen *EigenFace) computeEigenFaces() {

	denseMat := gomat.MakeDenseMatrixStacked(eigen.covMatrix)
	eigenVectors, _, _ := denseMat.Eigen()

	imageCount := eigenVectors.Cols()
	rank := eigenVectors.Rows()

	for i := 0; i < rank; i++ {
		sumSquare := 0.0
		for j := 0; j < eigen.rowCount; j++ {
			for k := 0; k < imageCount; k++ {

				eigen.eigenMatrix[j][i] += eigen.diffMatrix[j][k] * eigenVectors.Get(i, k)
			}
			sumSquare += eigen.eigenMatrix[j][i] * eigen.eigenMatrix[j][i]
		}
		norm := math.Sqrt(float64(sumSquare))
		for j := 0; j < eigen.rowCount; j++ {
			eigen.eigenMatrix[j][i] /= norm
		}
	}

}