func (m *RandomWalkMiner) PrMatrices(sg *goiso.SubGraph) (vp int, Q, R, u Sparse, err error) { defer func() { if e := recover(); e != nil { stack := string(debug.Stack()) err = fmt.Errorf("%v\n%v", e, stack) } }() lattice := sg.Lattice() log.Printf("lattice size %d %v", len(lattice.V), sg.Label()) p := m.probabilities(lattice) log.Println("got transistion probabilities", p) vp = m.startingPoints.Size() Q = Sparse{ Rows: len(lattice.V) - 1, Cols: len(lattice.V) - 1, Entries: make([]*SparseEntry, 0, len(lattice.V)-1), } R = Sparse{ Rows: len(lattice.V) - 1, Cols: 1, Entries: make([]*SparseEntry, 0, len(lattice.V)-1), } u = Sparse{ Rows: 1, Cols: len(lattice.V) - 1, Entries: make([]*SparseEntry, 0, len(lattice.V)-1), } for i, x := range lattice.V { if len(x.V) == 1 && len(x.E) == 0 && i < len(lattice.V)-1 { u.Entries = append(u.Entries, &SparseEntry{0, i, 1.0 / float64(vp), vp}) } } for _, e := range lattice.E { if e.Targ >= len(lattice.V)-1 { R.Entries = append(R.Entries, &SparseEntry{e.Src, 0, 1.0 / float64(p[e.Src]), p[e.Src]}) } else { Q.Entries = append(Q.Entries, &SparseEntry{e.Src, e.Targ, 1.0 / float64(p[e.Src]), p[e.Src]}) } } return vp, Q, R, u, nil }