InnerProductSpace working example #1308
-
We plan to use this wonderful library in one of our service, yet I couldn't find any proper tutorial on how to run a simple example. our use case is as follows:
If you provide me with some sample code, it would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Are you familiar with implicits/givens/typeclasses? Are you using Scala 2 or Scala 3? You want to define an instance of Here's an example for Scala 3. object Person {
given InnerProductSpace[Person, Int] with {
def dot(x: Person, y: Person): Int = ...
}
} Then to get the dot syntax you would do something like |
Beta Was this translation helpful? Give feedback.
Are you familiar with implicits/givens/typeclasses? Are you using Scala 2 or Scala 3? You want to define an instance of
InnerProductSpace
and place inside the companionobject Person
.Here's an example for Scala 3.
Then to get the dot syntax you would do something like
import spire.syntax.all._