the Matrix interface should add the Copy(or CopyTo) func

28 views
Skip to first unread message

xiaok159...@gmail.com

unread,
Jun 27, 2017, 3:50:59 AM6/27/17
to gonum-dev
If I want to copy a matrix to a dense Slice,the Eigen can do :
p.copyTo(A.rowRange(3,8).colRange(0, 4))
It's Very easy to use,
But the mat package must do that things :

p := mat.NewVector(4,mesh_points[r][:]).T()
eq
:= func(i,j int ,v float64) float64 {return v}
A
.Slice(row_index,row_index+1,0,4).(*mat.Dense).Apply(eq,p
)

If matrix interface have the copy func , It will be convenient,right?

Dan Kortschak

unread,
Jun 27, 2017, 6:35:03 AM6/27/17
to xiaok159...@gmail.com, gonum-dev
https://godoc.org/gonum.org/v1/gonum/mat#Dense.Copy

p := mat.NewVector(4, m[r][:]).T()
a.Slice(i, i+1, 0, 4).(*mat.Dense).Copy(p)

On Tue, 2017-06-27 at 00:50 -0700, xiaok159...@gmail.com wrote:
> If I want to copy a matrix to a dense Slice,the *Eigen* can do :

Dan Kortschak

unread,
Jun 27, 2017, 6:39:03 AM6/27/17
to xiaok159...@gmail.com, gonum-dev
Though this is easier, and more efficient.

a.SetRow(i, m[r][:]) 

xiaok159...@gmail.com

unread,
Jun 27, 2017, 10:39:54 PM6/27/17
to gonum-dev, xiaok159...@gmail.com
Yes ,Thank you ,i founded later,and the code an be also a.Slice(i, i+1, 0, 4).(Copyier).Copy(p) to use interface!
Reply all
Reply to author
Forward
0 new messages