iterate through densematrix with index

597 views
Skip to first unread message

Tamas Jambor

unread,
Mar 1, 2016, 1:57:08 PM3/1/16
to Scala Breeze
Hi all,

I would like to run some operation on a DenseMatrix row-wise, I understand that I can use the syntax w[*, ::].map{l => l} where I have access to row vectors in the map. 

Just wondering if it is possible to get the index of the row accessible in the map somehow.

Thanks,

David Hall

unread,
Mar 1, 2016, 1:59:13 PM3/1/16
to scala-...@googlegroups.com
that's not really available right now, sorry :(

--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/07e13e12-7d97-4eb3-8580-01bc4cdf7676%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tamas Jambor

unread,
Mar 1, 2016, 2:03:41 PM3/1/16
to Scala Breeze
thanks for the reply. 

can I maybe wrap the broadcaster to an iterator to use with zipwithindex?

David Hall

unread,
Mar 1, 2016, 2:06:01 PM3/1/16
to scala-...@googlegroups.com
oh sure, if you just want to iterate (and not preserve the matrix structure), then i think there's iterator

Tamas Jambor

unread,
Mar 1, 2016, 2:11:40 PM3/1/16
to Scala Breeze
I would like to iterate through the rows, but couldn't find the way to wrap that with a zipWithIndex. it doesn't look like that BroadcastedRows provides an iterator. 

Daniel Korzekwa

unread,
Mar 3, 2016, 10:43:21 AM3/3/16
to Scala Breeze
Yeah, I need the same quite a lot. Currently I use something like this

(0 until m.rows).foreach/map{rowIndex =>
val row = m(rowIndex,::)

...
}

similarly things like filter rows, sort matrix by would help.
Reply all
Reply to author
Forward
0 new messages