4

I am doing some Machine Learning code in Scala. I want to vectorize the operations like vector dot product, vector - scalar multiplication, vector vector addition. For example,

val x = u . v
val x = 2 * v

Basically I have experince in Matlab and would love to have similar operators on vectors. Which is the way to proceed? Thanks

Ria
  • 10,237
  • 3
  • 33
  • 60
Arun
  • 645
  • 7
  • 16
  • 2
    Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. –  Oct 27 '13 at 07:59
  • 3
    @MikeW I think we need to be a bit more careful with the trigger finger on Stackoverflow. This is a valid question from a newbie, and besides it's not like there are two dozen vector libraries for Scala, so the danger of primarily opinion based answer is not given IMO. – 0__ Oct 27 '13 at 09:53
  • See also [this question](http://stackoverflow.com/questions/12545313/linear-algebra-library-for-scala) – 0__ Oct 27 '13 at 09:55
  • @0__ Were this a request related to a more mainstream product it would have been mercilessly savaged as off-topic. Looking at the balance of upvotes to close votes I'd say the balance is about even. Perhaps we should agree to differ? –  Oct 27 '13 at 13:43

1 Answers1

4

You may want to have a look at the VectorSpace trait, provided by Spire.

Since it supports generic numeric programming, you can easily switch between different vector types. See this example of a k-means clustering algorithm.

Roland Ewald
  • 4,630
  • 3
  • 35
  • 49