Last active
March 11, 2018 09:16
-
-
Save hvesalai/650a0f1668db955df8fcb0567fa81c4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait VectorSpace[A] { } // isomorphisms | |
trait Iso[A, B] { | |
def to(a: A): B | |
def from(b: B): A | |
} | |
trait TensorAlgebra { | |
type * [V] | |
type ⨂ [V, W] | |
type ⨁ [V, W] | |
type Z | |
type I | |
implicit def dual[V](implicit V: VectorSpace[V]): VectorSpace[*[V]] | |
implicit def sum[V, W](implicit V: VectorSpace[V], W: VectorSpace[W]): VectorSpace[V ⨁ W] | |
implicit def product[V, W](implicit V: VectorSpace[V], W: VectorSpace[W]): VectorSpace[V ⨂ W] | |
// add implicit VectorSpace's everywhere | |
def zero[V]: Iso[V, V ⨁ Z] | |
def unit[V]: Iso[V, V ⨂ I] | |
def commuteSum[V, W]: Iso[V ⨁ W, W ⨁ V] | |
def commuteProd[V, W]: Iso[V ⨂ W, W ⨂ V] | |
def directSum[V, W](v: V, w: W): V ⨁ W | |
def inner[V, U, W](v: V ⨂ *[U], w: U ⨂ W): V ⨂ W | |
def outerProduct[V, W](v: V, w: W): V ⨂ W | |
def differentiate[V, W](f: V => W): W ⨂ *[V] | |
} | |
trait Module { | |
val T: TensorAlgebra | |
import T._ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment