Beispiel #1
0
// SymRankOne performs a symetric rank-one update to the matrix a and stores
// the result in the receiver
//  s = a + alpha * x * x'
func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x []float64) {
	n := s.mat.N
	var w SymDense
	if s == a {
		w = *s
	}
	if w.isZero() {
		w.mat = blas64.Symmetric{
			N:      n,
			Stride: n,
			Uplo:   blas.Upper,
			Data:   use(w.mat.Data, n*n),
		}
	} else if n != w.mat.N {
		panic(ErrShape)
	}
	if s != a {
		w.CopySym(a)
	}
	if len(x) != n {
		panic(ErrShape)
	}
	blas64.Syr(alpha, blas64.Vector{Inc: 1, Data: x}, w.mat)
	*s = w
	return
}
Beispiel #2
0
// SymRankOne performs a symetric rank-one update to the matrix a and stores
// the result in the receiver
//  s = a + alpha * x * x'
func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x *Vector) {
	n := x.Len()
	if a.Symmetric() != n {
		panic(matrix.ErrShape)
	}
	s.reuseAs(n)
	if s != a {
		s.CopySym(a)
	}
	blas64.Syr(alpha, x.mat, s.mat)
}
Beispiel #3
0
// SymRankOne performs a symetric rank-one update to the matrix a and stores
// the result in the receiver
//  s = a + alpha * x * x'
func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x *Vector) {
	n := x.Len()
	if a.Symmetric() != n {
		panic(matrix.ErrShape)
	}
	s.reuseAs(n)
	if s != a {
		if rs, ok := a.(RawSymmetricer); ok {
			s.checkOverlap(rs.RawSymmetric())
		}
		s.CopySym(a)
	}
	blas64.Syr(alpha, x.mat, s.mat)
}
Beispiel #4
0
// SymRankOne performs a symetric rank-one update to the matrix a and stores
// the result in the receiver
//  s = a + alpha * x * x'
func (s *SymDense) SymRankOne(a Symmetric, alpha float64, x *Vector) {
	n := x.Len()
	if a.Symmetric() != n {
		panic(matrix.ErrShape)
	}
	if s.isZero() {
		s.mat = blas64.Symmetric{
			N:      n,
			Stride: n,
			Uplo:   blas.Upper,
			Data:   use(s.mat.Data, n*n),
		}
	} else if n != s.mat.N {
		panic(matrix.ErrShape)
	}
	if s != a {
		s.CopySym(a)
	}
	blas64.Syr(alpha, x.mat, s.mat)
}