LU decomposition: Difference between revisions
→Flat representation: simplify
m (correction: there stood "columns" where rows was meant) |
(→Flat representation: simplify) |
||
Line 1,098:
type matrix struct {
stride int▼
ele []float64
▲ stride int
}
Line 1,127 ⟶ 1,116:
return nil, false
}
m3 = &matrix{m2.stride, make([]float64, (len(m1.ele)/m1.stride)*m2.stride)
for m1c0, m3x := 0, 0; m1c0 < len(m1.ele); m1c0 += m1.stride {
for m2r0 := 0; m2r0 < m2.stride; m2r0++ {
Line 1,141 ⟶ 1,130:
func zero(rows, cols int) *matrix {
return &matrix{cols, make([]float64, rows*cols)
}
Line 1,202 ⟶ 1,191:
}
l.ele[ixc0+j] = (a.ele[ixc0+j] - sum) / u.ele[jxc0+j]
}
jxc0 += a.stride
}
return
}
func main() {
showLU(
showLU(
}
func showLU(a *matrix) {
a.print("\na")
l, u, p := a.lu()
l.print("l")
u.print("u")
|