Trait

basis.math

FN

Related Doc: package math

Permalink

trait FN extends VectorSpace

An abstract N-dimensional vector space over a ring. Vector addition associates and commutes, and scalar multiplication associates, commutes, 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. Every vector space is an affine space over itself. To the extent practicable, the following axioms should hold.

Axioms for vector addition:

Axioms for scalar multiplication:

Distributive laws:

Self Type
FN
Source
FN.scala
Example:
  1. // You can abstract over vector spaces by parameterizing a class or
    // function with a subtype of FN with Singleton. Type elements with
    // the #Vector and #Scalar type projections of your FN type parameter.
    def testVectorSpaceOperations[V <: FN[S] with Singleton, S <: Ring with Singleton]
        (a: V#Scalar, b: V#Scalar, u: V#Vector, v: V#Vector, w: V#Vector): Unit = {
      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 FN parameter.
    def testVectorSpaceIdentities(V: FN[_])(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
VectorSpace, AnyRef, Any
Known Subclasses
F2, F3, F4, Integer, R2, R3, R4, RI2, RI3, RIN, RN, Real, Z2, Z3, ZI2, ZI3, ZIN, ZN
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. FN
  2. VectorSpace
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. type Scalar = Element

    Permalink

    The type of scalars in this vector space.

    The type of scalars in this vector space.

    Definition Classes
    VectorSpace
  2. abstract type Vector <: VectorFN

    Permalink

    The type of vectors in this vector space.

    The type of vectors in this vector space.

    Definition Classes
    FNVectorSpace
  3. trait VectorElement extends Any

    Permalink

    A vector in this vector space.

    A vector in this vector space.

    Definition Classes
    VectorSpace
  4. trait VectorFN extends VectorElement

    Permalink

Abstract Value Members

  1. abstract val Scalar: Ring

    Permalink

    Returns the scalar set of this vector space.

    Returns the scalar set of this vector space.

    Definition Classes
    VectorSpace
  2. implicit abstract def ScalarTag: ClassTag[Scalar]

    Permalink
  3. abstract def apply(coords: Array[Scalar]): Vector

    Permalink

    Returns a new vector with the given coordinates.

  4. abstract def dim: Int

    Permalink

    Returns the dimension of this vector space.

Concrete Value Members

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

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

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

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

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

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

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

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. def zero: Vector

    Permalink

    Returns the additive identity of this vector space.

    Returns the additive identity of this vector space.

    Definition Classes
    FNVectorSpace

Inherited from VectorSpace

Inherited from AnyRef

Inherited from Any

Ungrouped