Exemple #1
0
// Solve Ux = y, replace b with solution
// column oriented backward substitution
func (U mesh) SolveUx(y vec.Vectorer) {
	n := U.c
	for j := n - 1; j >= 1; j-- {
		y.SetAt(j, y.GetAt(j)/U.GetAtNode(j, j))
		for k := 0; k < j; k++ {
			y.SetAt(k, y.GetAt(k)-y.GetAt(j)*U.GetAtNode(k, j))
		}
	}
	y.SetAt(0, y.GetAt(0)/U.GetAtNode(0, 0))
}
Exemple #2
0
// Solve Ly = b for y, replace b with solution
// column oriented forward substitution
func (L mesh) SolveLy(b vec.Vectorer) {
	n := L.c
	for j := 0; j < n-1; j++ {
		b.SetAt(j, b.GetAt(j)/L.GetAtNode(j, j))
		for k := j + 1; k < n; k++ {
			b.SetAt(k, b.GetAt(k)-b.GetAt(j)*L.GetAtNode(k, j))
		}
	}
	b.SetAt(n-1, b.GetAt(n-1)/L.GetAtNode(n-1, n-1))
}
Exemple #3
0
// SetDiag puts the diagonal, d into the mesh
// m must be a square matrix
func (m *mesh) SetDiag(d vec.Vectorer) {
	for e := range d.Slice() {
		m.SetAtNode(d.GetAt(e), e, e)
	}
}