Skip to content

InnerProductSpace working example #1308

Discussion options

You must be logged in to vote

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 companion object Person.

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 import spire.syntax.all._

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MohammadForouhesh
Comment options

Answer selected by MohammadForouhesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1307 on December 16, 2023 18:33.