Groups
Groups
Sign in
Groups
Groups
scalanlp-discuss
Conversations
About
Send feedback
Help
DenseMatrix array masking
14 views
Skip to first unread message
Rahul Palamuttam
unread,
Jul 21, 2015, 2:18:29 PM
7/21/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scalanlp...@googlegroups.com
Hi I wanted to create masked arrays and wanted to know how to do this using the DenseMatrix syntax.
I was looking for something like DenseMatrix <= num. Which will give me another dense matrix of elements less than num, or 0 otherwise.
David Hall
unread,
Jul 21, 2015, 3:46:22 PM
7/21/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scalanlp...@googlegroups.com
it is not fast, but:
where(dm :<= num, dm, DenseMatrix.zeros[Double](dm.rows, dm.cols))
or
dm.map { v => if (v <= num) v else 0.0 }
or
dm :* I(dm :<= 5)
Reply all
Reply to author
Forward
0 new messages