Package

cogx.cogmath.algebra

real

Permalink

package real

Visibility
  1. Public
  2. All

Type Members

  1. trait ArrayMath extends AnyRef

    Permalink

    Functions for combining two arrays of Floats.

    Functions for combining two arrays of Floats.

    In all of these functions, one of the two arguments may be null, in which case the function returns the non-null argument. If both arguments are null, the function returns null. If both arguments are non-null, both arguments must be of the same length.

    User: Greg Snider Date: Nov 12, 2010 Time: 8:03:11 AM

  2. class Dyad2D extends Vector with Tensor

    Permalink

    A two-dimensional dyad.

    A two-dimensional dyad.

    The terminology of "stickness" and "ballness" is described in "An efficient method for tensor voting using steerable filters," Franken et al.

    Since dyads in Cog are symmetric matrices, we implement them as vectors for efficiency. The matrix representation:

    xx   xy
    yx   yy

    is therefore represented internally as a vector like this:

    xx   xy   yy
  3. trait Logarithm extends AnyRef

    Permalink

    Base 2 logarithms.

  4. class Matrix extends Tensor with Serializable

    Permalink

    A matrix.

    A matrix.

    In the following descriptions, "v" represents a vector, "s" a scalar, "m" a matrix, "b" a boolean, "i" and integer, "d" a double, "r" a range of integers (e.g. "1 to 5" or "3 until 9").

    The update operations, such as "+=", update the elements of the matrix in place.

    Constructors:
      Matrix(i, i)
      Matrix(i, i, Array[d])
      copy
    
    Dimensions:
      rows               => i        (number of rows in matrix)
      columns            => i        (number of columns in matrix)
      size               => i        (total # elements in matrix)
    
    Linear element access:
      apply(i)           => s        (access element linearly)
      update(i, s)                   (write element i with value s)
    
    2D element access:
      apply(i, i)        => s        (access element by 2D coordinates)
      update(i, i, s)                (write element (i, i) with value s)
    
    Submatrix multi-element reads:
      row(i)             => m        (extract a copy of a row)
      column(i)          => m        (extract a copy of a column)
      submatrix(r, r)    => m        (extract a subregion of a matrix)
      reshape(i, i)      => m        (reshape the matrix)
    
    Matrix operations:
      map(f: d => d)     => m        (map a Matrix 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 Matrix to a scalar)
      randomize                      (initialize to random values in [0, 1))
    
    Matrix / Scalar operations:
      m + s   => m          (add scalar to each element to produce a new matrix)
      m += s                (add scalar to all elements of matrix in-place)
      m - s   => m
      m -= s
      m * s   => m
      m *= s
      m / s   => m
      m /= s
      -m      => m          (map each element to new matrix my multiplying by -1)
      m := s                (assign scalar to all elements of the matrix)
    
    Matrix / Matrix operations:
      m + m          => m
      m += m
      m - m          => m
      m -= m
      m :* m         => m   (element-wise multiplication)
      m :*= m               (element-wise multiplication in-place)
      m :/ m         => m   (element-wise right division)
      m :/= n               (element-wise right division in-place)
      m :\ m         => m   (element-wise left division)
      m :\= m               (element-wise left division in-place)
      m1 === m2		=> b   (m1 and m2 have same shape, identical elements)
      m1 !=== m2     => b
      m1 ~== m2
      m1 !~== m2
      m1 := m2			   (assign elements of m2 to m1)
    
    Matrix multiplication:
      m * m          => m   (matrix multiplication)
    
    Matrix decompositions:
      cholesky       => m         (Cholesky decomposition)
      eigen          => (m, m)    (eigenvector matrix, diag eigenvalue matrix)
      lu             => (m, m)    (L matrix, U matrix)
      qr             => (m, m)    (Q matrix, R matrix)
      svd            => (m, m, m) (U matrix, S matrix, V matrix)
    
    Miscellaneous cogx.utilities:
      abs            => m   (absolute value of each element)
      sgn            => m   (sign of each element: -1, 0, 1)
      rectify        => m   (clip negative elements to 0)
      normalizeRows         (normalize rows using L2 norm)
      normalizeColumns      (normalize columns using L2 norm)
      print                 (print a matrix for debugging)
    Annotations
    @SerialVersionUID()
  5. class PoorFloat extends AnyRef

    Permalink

    A low-precision floating point number, necessary because some GPUs offer a reduced precision mode for multiply-adds that is faster.

    A low-precision floating point number, necessary because some GPUs offer a reduced precision mode for multiply-adds that is faster.

    This supplies the "approximately equal" functionality needed to compare results on the GPU with results on the CPU (which generally has higher precision). The implicit defined in the companion object lets you write code like this:

    val a: Float = ...
    val b: Float = ...
    val approxEqual: Boolean = (a ~== b)

    To access this:

    import cog.algebra.real.PoorFloat._

    User: snider1

  6. class Scalar extends Tensor

    Permalink

    A zero-dimensional Tensor holding a single real value.

  7. trait Tensor extends Serializable

    Permalink

    A Tensor is used to represent general algebraic objects more complex than scalars: vectors, matrices, tensors, pixels, and so on.

    A Tensor is used to represent general algebraic objects more complex than scalars: vectors, matrices, tensors, pixels, and so on.

    It is represented as a shaped, multidimensional array of numbers which are represented internally as a flat array of Floats. The numbers are ordered in the flat array using conventional C semantics: the rightmost index varies the fastest.

    Annotations
    @SerialVersionUID()
  8. class Tensor3 extends AnyRef

    Permalink

    An order-3 Tensor

    An order-3 Tensor

    This is used primarily by the 3D FFT.

  9. class Vector extends Tensor with Serializable

    Permalink

    A column vector.

    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()
  10. trait VirtualArray extends AnyRef

    Permalink

    Interface to an abstract array of Floats.

Value Members

  1. object Dyad2D extends Serializable

    Permalink

    Factory for creating Dyad2Ds.

  2. object Logarithm extends Logarithm

    Permalink
  3. object Matrix extends Serializable

    Permalink

    Factory methods for Matrix.

  4. object PoorFloat

    Permalink

    Library for accessing PoorFloat functionality.

  5. object Scalar extends Serializable

    Permalink

    Companion object for the Scalar class.

  6. object Tensor3

    Permalink

    Factory methods for Tensor3.

  7. object Vector extends Serializable

    Permalink

Ungrouped