Class/Object

cogx.cogmath.algebra.real

Vector

Related Docs: object Vector | package real

Permalink

class Vector extends Tensor with Serializable

A column vector.

The interface is modeled on that provided by Scalala (which in turn was modeled on Matlab), with the exception that all operations are executed immediately. This provides a more natural interface, at the cost of suboptimal performance since linear algebra libraries are not used.

In the following descriptions, "v" represents a vector, "s" a scalar, "m" a matrix, "b" a boolean, "i" and integer, "d" a double. The update operations, such as "+=", update the elements of the vector in place.

Constructors:
  new Vector(i)              (create vector of length i)
  new Vector(d*)             (create vector with elements d)
  copy           => v        (create a copy of a vector)
  length         => i        (number of elements in vector)

Vector operations:
  map(f: d => d)     => v        (map a Vector by applying f to each element)
  mapSelf(f: d => d)			    (use f to map each element in place)
  reduce((d, d)=> d) => d        (reduce a Vector to a scalar)
  randomize                      (initialize to random values in [0, 1))

Vector / Scalar operations:
  v + s   => v          (add scalar to each element to produce a new matrix)
  v += s                (add scalar to all elements of matrix in-place)
  v - s   => v
  v -= s
  v * s   => v
  v *= s
  v / s   => v
  v /= s
  -v      => v          (map each element to new matrix my multiplying by -1)
  v := s                (assign scalar to all elements of the matrix)

Vector / Vector operations:
  v + v          => v
  v += v
  v - v          => v
  v -= v
  v :* v         => v   (element-wise multiplication)
  v :*= v               (element-wise multiplication in-place)
  v :/ v         => v   (element-wise right division)
  v :/= n               (element-wise right division in-place)
  v :\ v         => v   (element-wise left division)
  v :\= v               (element-wise left division in-place)
  v1 === v2		=> b   (m1 and m2 have same shape, identical elements)
  v1 !=== v2     => b
  v1 ~== v2
  v1 !~== v2
  v1 := v2			   (assign elements of v2 to v1)


--------------------
  v1 dot v2           => d   (dot product of two vectors)
  v1 outerProduct v2  => m   (outer product of two vectors)
  v concat v2         => v   (concatentate two vectors)


 -------------------------------------------------




Matrix conversions:
  shape(i, i)           => m (create matrix)
  rectangularize        => m (create squarest matrix possible)

Miscellaneous:
  normL1     => d       (L1 norm of the vector)
  normL2     => d       (L2 norm of the vector)
  argmax     => i       (index of largest element)
  print                 (print out a vector for debugging)
Annotations
@SerialVersionUID()
Linear Supertypes
Tensor, Serializable, Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Vector
  2. Tensor
  3. Serializable
  4. Serializable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Vector(tensor: Tensor)

    Permalink

    Create a vector from a 1-dimensional tensor.

  2. new Vector(e: Float*)

    Permalink

    Create a vector from one or more Floats.

  3. new Vector(length: Int)

    Permalink

    Create a vector of size "length".

  4. new Vector(data: Array[Float])

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. def !===(v: Vector): Boolean

    Permalink
  3. def !~==(v: Vector): Boolean

    Permalink
  4. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  5. def *(that: Matrix): Matrix

    Permalink
  6. def *(s: Float): Vector

    Permalink
  7. def *=(s: Float): Unit

    Permalink
  8. def +(v: Vector): Vector

    Permalink
  9. def +(s: Float): Vector

    Permalink
  10. def +=(v: Vector): Unit

    Permalink
  11. def +=(s: Float): Unit

    Permalink
  12. def -(v: Vector): Vector

    Permalink
  13. def -(): Vector

    Permalink
  14. def -(s: Float): Vector

    Permalink
  15. def -=(v: Vector): Unit

    Permalink
  16. def -=(s: Float): Unit

    Permalink
  17. def /(s: Float): Vector

    Permalink
  18. def /=(s: Float): Unit

    Permalink
  19. def :*(v: Vector): Vector

    Permalink
  20. def :*=(v: Vector): Unit

    Permalink
  21. def :/(v: Vector): Vector

    Permalink
  22. def :/=(v: Vector): Unit

    Permalink
  23. def :=(v: Vector): Unit

    Permalink
  24. def :=(s: Float): Unit

    Permalink
  25. def :\(v: Vector): Vector

    Permalink
  26. def :\=(v: Vector): Unit

    Permalink
  27. def <(v: Float): Vector

    Permalink
  28. def <=(v: Float): Vector

    Permalink
  29. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  30. def ===(v: Vector): Boolean

    Permalink
  31. def >(v: Float): Vector

    Permalink
  32. def >=(v: Float): Vector

    Permalink
  33. def abs: Vector

    Permalink
  34. def apply(index: Int): Float

    Permalink
  35. def argmax: Int

    Permalink
  36. final def asArray: Array[Float]

    Permalink

    View this Vector as an array with full read and write access.

  37. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  38. def canEqual(other: Any): Boolean

    Permalink

    Helper for equals.

    Helper for equals.

    Definition Classes
    Tensor
  39. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. def concat(that: Vector): Vector

    Permalink
  41. def copy: Vector

    Permalink
  42. def dot(that: Vector): Float

    Permalink

    Compute the dot product of "this" and "that".

  43. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  44. def equals(other: Any): Boolean

    Permalink

    Test "this" and "other" for deep equality.

    Test "this" and "other" for deep equality. Allows "==" to work.

    Definition Classes
    Tensor → AnyRef → Any
  45. def expand(bigSize: Int, borderFill: Boolean): Vector

    Permalink

    Expand the vector, optionally extending the border into the expanded region.

    Expand the vector, optionally extending the border into the expanded region. This operation is a key part of the FFT. The new vector is of size "bigSize" element (0) of this is anchored at (0) in the larger vector. If "borderFill" is true, then the two edges of the vector are extended evenly in all directions, as though the bigger vector were actually a loop with opposite edges touching.

  46. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  47. def flip: Vector

    Permalink

    Reverses the order of the elements in this

  48. def fold(initValue: Float)(f: (Float, Float) ⇒ Float): Float

    Permalink
  49. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  50. def getData: Array[Float]

    Permalink

    Get the data in the tensor, flattened to a linear array.

    Get the data in the tensor, flattened to a linear array.

    Attributes
    protected[cogx]
  51. def hashCode(): Int

    Permalink

    Required because of overriding equals.

    Required because of overriding equals.

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

    Permalink
    Definition Classes
    Any
  53. def length: Int

    Permalink

    The number of "numbers" held in the tensor.

    The number of "numbers" held in the tensor.

    Definition Classes
    Tensor
  54. def map(f: (Float) ⇒ Float): Vector

    Permalink
  55. def mapSelf(f: (Float) ⇒ Float): Unit

    Permalink
  56. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  57. def normL1: Float

    Permalink
  58. def normL2: Float

    Permalink
  59. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  61. def outerProduct(that: Vector): Matrix

    Permalink
  62. def print: Unit

    Permalink
  63. def randomize: Vector

    Permalink
  64. def read(index: Int): Float

    Permalink

    Tensor accessor.

    Tensor accessor.

    Definition Classes
    VectorTensor
  65. def reciprocal: Vector

    Permalink
  66. def rectangularize: Matrix

    Permalink
  67. def rectify: Vector

    Permalink
  68. def reduce(f: (Float, Float) ⇒ Float): Float

    Permalink

    Reduce a Vector to a scalar using "f".

  69. def sgn: Vector

    Permalink
  70. def shape(rows: Int, columns: Int): Matrix

    Permalink
  71. def shape: geometry.Shape

    Permalink

    Shape of the vector.

    Shape of the vector.

    Definition Classes
    VectorTensor
  72. def shiftCyclic(delta: Int): Vector

    Permalink

    Rotates the elements of a vector, wrapping around the left side to the right side.

    Rotates the elements of a vector, wrapping around the left side to the right side.

    The rotation is specified by "delta"; for example, delta=2 would cause the element at location (0) to be moved to location (2). Returns the rotated vector. This was added in support of the LowPassFunction kernel, and because Matrix has a similar method. Not currently tested. -RJC XXX

  73. def size: Int

    Permalink
  74. def sort: Vector

    Permalink

    Sort vector elements in ascending order (creates new Vector, "this" unchanged).

  75. def subvector(indexRange: Range): Vector

    Permalink
  76. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  77. def toArray: Array[Float]

    Permalink

    Convert Vector to an array of doubles (copy).

  78. def toString(): String

    Permalink
    Definition Classes
    Vector → AnyRef → Any
  79. def transpose: Matrix

    Permalink
  80. def trim(smallSize: Int): Vector

    Permalink

    Trim "this" to a Vector of length smallSize.

  81. def unary_-(): Vector

    Permalink
  82. def update(index: Int, value: Float): Unit

    Permalink
  83. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  86. def ~==(v: Vector): Boolean

    Permalink

Inherited from Tensor

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped