basis.math

VectorSpace

trait VectorSpace extends AnyRef

An abstract vector space over a ring. Vector addition associates and commutes, and scalar multiplication associates and distributes over vector addition and scalar addition. Vector addition and scalar multiplication both have an identity element, and every vector has an additive inverse. To the extent practicable, the following axioms should hold.

Axioms for vector addition:

Axioms for scalar multiplication:

Distributive laws:

Source
VectorSpace.scala
Example:
  1. // You can abstract over vector spaces by parameterizing a class or
    // function with a subtype of VectorSpace with Singleton. Type elements
    // with the #Vector and #Scalar type projections of your VectorSpace
    // type parameter.
    def testVectorSpaceOperations[V <: VectorSpace with Singleton]
        (a: V#Scalar, b: V#Scalar, u: V#Vector, v: V#Vector, w: V#Vector) {
      assert(u + v == v + u, "commutativity of vector addition")
      assert((u + v) + w == u + (v + w), "associativity of vector addition")
      assert((a * b) *: v == a *: (b *: v), "associativity of scalar multiplication with ring multiplication")
      assert(a *: (u + v) == (a *: u) + (a *: v), "distributivity of scalar multiplication over vector addition")
      assert((a + b) *: v == (a *: v) + (b *: v), "distributivity of scalar multiplication over ring addition")
    }
    
    // Alternatively, functions can use path-dependent types of a VectorSpace parameter.
    def testVectorSpaceIdentities(V: VectorSpace)(a: V.Scalar, v: V.Vector): Unit = {
      import V._
      assert(zero + v == v, "existence of additive identity vector")
      assert(v + (-v) == zero, "existence of additive inverse vector")
      assert(Scalar.unit *: v == v, "existence of multiplicative identity scalar")
    }
Version

0.1

Since

0.0

Linear Supertypes
AnyRef, Any
Known Subclasses
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. VectorSpace
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type Scalar = Element

    The type of scalars in this vector space.

  2. abstract type Vector <: VectorElement

    The type of vectors in this vector space.

  3. trait VectorElement extends Any

    A vector in this vector space.

Abstract Value Members

  1. abstract val Scalar: Ring

    Returns the scalar set of this vector space.

  2. abstract def zero: Vector

    Returns the additive identity of this vector space.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  16. def toString(): String

    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped