Implement GetSubMatrix functionality into biogo.matrix package

26 views
Skip to first unread message

Chatrapathi Kun

unread,
Dec 4, 2014, 8:06:36 AM12/4/14
to biog...@googlegroups.com
biogo.matrix package doesn't have a GetSubMatrix convenience function. I'd like to add it.

Here it is.....

// Get submatrix from A of nr,nc dimensions starting at wr,wc
func
SubMatrixFrom(wr, wc, nr, nc int, A *bio.Dense) (B *bio.Dense) {
        bv
:= make([][]float64, nr)
       
for i := 0; i < nr; i++ {
                bv
[i] = A.Row(i + wr)[wc:wc+nc]
       
}
        B
,_ = bio.NewDense(bv)
       
return
}


Dan Kortschak

unread,
Dec 4, 2014, 5:10:14 PM12/4/14
to Chatrapathi Kun, biog...@googlegroups.com
biogo.matrix is deprecated and we are not accepting any changes - it
will go away at some stage.

However, github.com/gonum/matrix/mat64 is under active development (same
developers and more). You will find the dense matrix type in that
package does have a method equivalence to this by taking a view on a
matrix and then cloning the view. Using your names:

b := &mat64.Dense{}
b.View(a, wr, wc, nr, nc)
b.Clone(b)

Dan Kortschak

unread,
Dec 4, 2014, 5:57:28 PM12/4/14
to Chatrapathi Kun, biog...@googlegroups.com
We have just revised this interface and now the equivalent idiom is

b := &mat64.Dense{}
b.Clone(a.View(wr, wc, nr, nc))
Reply all
Reply to author
Forward
0 new messages