Packages

trait ReIndexer[T] extends AnyRef

We often need to "reindex" one array/vec/series/frame so as to produce a new one.

First, note that an array A of values of type T is actually a mapping defined as

              f
[0, A.length) => {T}

That is, each integer index of the array yields a value of type T when it is de-referenced.

ReIndexer has two fields, lTake and rTake, which are array-based maps defined for some integers M and N as

        g
[0, N) => [-1, M)

In other words, lTake and rTake are arrays of length N whose entries are integers between -1 and M-1. We call these "indexers".

Given a reindexer, g, a re-indexing operation on array A yields a new array B of length N which represents the following mapping:

        B
[0, N)  =>  {T}

where B(i) == f(g(i)) if g(i) != -1
            == NA      if g(i) == -1

For this to work, the maximum value M in the co-domain of g must be <= A.length. We also augment the mapping f to send -1 to the corresponding NA value of type T.

For example, suppose we have Index(0,1,2,4) and Index(0,1,2,3). Performing a full outer join would yield the following ReIndexer:

  • lTake = {0, 1, 2, -1, 3},
  • rTake = {0, 1, 2, 3, -1},
  • index = Index(0, 1, 2, 3, 4).

These indexers are then amenable to using with org.saddle.array.take to select elements out of an indexed data structure.

A performance optimization is to make lTake and rTake of type Option[Array], where we make a value of None behave as if it were an array of [0, N). So, the "taking" code knows to take the original values. You will therefore see code that looks like:

val v = Vec(...)
val ixer = ReIndexer(...)
ixer.lTake.map(x => v.take(x)) getOrElse v
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReIndexer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def index: Index[T]

    The new index

  2. abstract def lTake: Option[Array[Int]]

    Offsets into left index corresponding to new index

  3. abstract def rTake: Option[Array[Int]]

    Offsets into right index corresponding to new index

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[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  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
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. def swap: ReIndexer[T]

    Return ReIndexer with lTake and rTake swapped

  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped