slice of vector immutable/mutable?

47 views
Skip to first unread message

Daniel Korzekwa

unread,
Aug 7, 2015, 11:13:31 AM8/7/15
to Scala Breeze
I just found a bug in my code, which was due to assuming that slice of vector in breeze is immutable (copy), but I just realized it's a view (read/write through).

- What is the reason behind this? Wouldn't it be better to create immutable slice by default? 

- In breeze doc (https://github.com/scalanlp/breeze/wiki/Linear-Algebra-Cheat-Sheet#indexing-and-slicing) it is stated that the corresponding matlab operation is a(2:5), lets point it out that in breeze it's just a view and not a copy. Oh, just found on the Quickstart breeze page this
'....The slice operator constructs a read-through and write-through view...'

David Hall

unread,
Aug 7, 2015, 11:40:17 AM8/7/15
to scala-...@googlegroups.com
The reason is the usual: performance. It being immutable doesn't really solve the general problem, only being a copy does. But I'm not willing to sacrifice that performance.

I guess evidently it should be better documented.

--
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/130bbec6-b88f-4fc1-81d5-ce80dae06254%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Korzekwa

unread,
Aug 7, 2015, 12:18:20 PM8/7/15
to Scala Breeze
yeah, I really meant a copy.

I actually like the performance wise approach, but still I would not be surprised others do similar mistake that me. I think that a good book on breeze would help. I made this mistake simply because of not understanding well how breeze works and how is it different from other linear algebra libraries. Any plans to write one?

David Hall

unread,
Aug 7, 2015, 2:26:52 PM8/7/15
to scala-...@googlegroups.com
"Plans" is too strong a term. Aspirations is perhaps better. Maybe even "intentions." :-)

Reply all
Reply to author
Forward
0 new messages