org.saddle

array

package array

This package contains utilities for working with arrays that are specialized for numeric types.

Visibility
  1. Public
  2. All

Type Members

  1. trait Sorter[T] extends AnyRef

    Typeclass interface for sorting implementations

Value Members

  1. object Sorter extends AnyRef

  2. def argmax[T](arr: Array[T])(implicit arg0: ST[T], arg1: ORD[T], arg2: NUM[T]): Int

    Return the integer offset of the maximum element, or -1 for an empty array

    Return the integer offset of the maximum element, or -1 for an empty array

    Definition Classes
    package
  3. def argmin[T](arr: Array[T])(implicit arg0: ST[T], arg1: ORD[T], arg2: NUM[T]): Int

    Return the integer offset of the minimum element, or -1 for an empty array

    Return the integer offset of the minimum element, or -1 for an empty array

    Definition Classes
    package
  4. def argsort[T](arr: Array[T])(implicit arg0: ST[T], arg1: ORD[T]): Array[Int]

    Stable indirect sort resulting in permutation of numbers [0, n), whose application on an array results in a sorted array.

    Stable indirect sort resulting in permutation of numbers [0, n), whose application on an array results in a sorted array.

    arr

    Array to sort

    Definition Classes
    package
  5. def empty[T](len: Int)(implicit arg0: ST[T]): Array[T]

    Create a new initialized empty array

    Create a new initialized empty array

    Definition Classes
    package
  6. def fill[T](arr: Array[T], v: T)(implicit arg0: ST[T]): Unit

    Fill array with value

    Fill array with value

    Definition Classes
    package
  7. def filter[T](f: (T) ⇒ Boolean)(arr: Array[T])(implicit arg0: ST[T]): Array[T]

    Filter an array based on a predicate function, wherever that predicate is true

    Filter an array based on a predicate function, wherever that predicate is true

    Definition Classes
    package
  8. def flatten[T](arrs: Seq[Array[T]])(implicit arg0: ST[T]): Array[T]

    Flatten a sequence of arrays into a single array

    Flatten a sequence of arrays into a single array

    Definition Classes
    package
  9. def linspace(start: Double, stop: Double, num: Int = 50, endpoint: Boolean = true): Array[Double]

    Derived from numpy 1.

    Derived from numpy 1.7

    Return evenly spaced numbers over a specified interval.

    Returns num evenly spaced samples, calculated over the interval [start, stop].

    The endpoint of the interval can optionally be excluded.

    Definition Classes
    package
  10. def put[T](arr: Array[T], offsets: Array[Boolean], value: T): Array[T]

    Put a value into array arr at particular offsets provided by a boolean array where its locations are true, so as to produce a new array.

    Put a value into array arr at particular offsets provided by a boolean array where its locations are true, so as to produce a new array.

    Definition Classes
    package
  11. def put[T](arr: Array[T], offsets: Array[Int], value: T): Array[T]

    Put a single value into array arr at particular offsets, so as to produce a new array.

    Put a single value into array arr at particular offsets, so as to produce a new array.

    Definition Classes
    package
  12. def putn[T](arr: Array[T], offsets: Array[Int], values: Array[T]): Array[T]

    Put n values into array arr at particular offsets, where the values come from another array, so as to produce a new array.

    Put n values into array arr at particular offsets, where the values come from another array, so as to produce a new array.

    Definition Classes
    package
  13. def randDouble(sz: Int): Array[Double]

    Generate an array of random doubles on [-1, 1] excluding 0

    Generate an array of random doubles on [-1, 1] excluding 0

    Definition Classes
    package
  14. def randDoublePos(sz: Int): Array[Double]

    Generate an array of random positive doubles on (0, 1]

    Generate an array of random positive doubles on (0, 1]

    Definition Classes
    package
  15. def randInt(sz: Int): Array[Int]

    Generate an array of random integers excluding 0

    Generate an array of random integers excluding 0

    Definition Classes
    package
  16. def randIntPos(sz: Int): Array[Int]

    Generate an array of random positive integers excluding 0

    Generate an array of random positive integers excluding 0

    Definition Classes
    package
  17. def randLong(sz: Int): Array[Long]

    Generate an array of a random long integers excluding 0

    Generate an array of a random long integers excluding 0

    Definition Classes
    package
  18. def randLongPos(sz: Int): Array[Long]

    Generate an array of random long positive integers excluding 0

    Generate an array of random long positive integers excluding 0

    Definition Classes
    package
  19. def randNormal(sz: Int): Array[Double]

    Generate an array of random doubles which is normally distributed with a mean of zero and stdev of one.

    Generate an array of random doubles which is normally distributed with a mean of zero and stdev of one.

    Definition Classes
    package
  20. def randNormal2(sz: Int, mu: Double, sigma: Double): Array[Double]

    Generate an array of random doubles which is normally distributed with a mean of mu and stdev of sigma.

    Generate an array of random doubles which is normally distributed with a mean of mu and stdev of sigma.

    Definition Classes
    package
  21. def range(from: Int, until: Int, step: Int = 1): Array[Int]

    Create a new array consisting of a range of numbers from a lower bound up to, but not including, an upper bound, at a particular increment (default 1)

    Create a new array consisting of a range of numbers from a lower bound up to, but not including, an upper bound, at a particular increment (default 1)

    Definition Classes
    package
  22. def remove[T](arr: Array[T], locs: Array[Int])(implicit arg0: ST[T]): Array[T]

    Remove values from array arr at particular offsets so as to produce a new array.

    Remove values from array arr at particular offsets so as to produce a new array.

    Definition Classes
    package
  23. def reverse[T](arr: Array[T])(implicit arg0: ST[T]): Array[T]

    Reverse an array

    Reverse an array

    Definition Classes
    package
  24. def send[T](arr: Array[T], offsets: Array[Int])(implicit arg0: ST[T]): Array[T]

    Sends values from an array to particular offsets so as to produce a new array.

    Sends values from an array to particular offsets so as to produce a new array. This does the inverse of 'take'; ie, each integer I at offset O in offsets works to "send" input[O] to output[I]. Eg, Array(2,0,1) permutes locations as follows:

    • 0 to 2
    • 1 to 0
    • 2 to 1

    For example,

      send(Array(5,6,7), Array(2,0,1)) == Array(6,7,5)
    
    Definition Classes
    package
  25. def shuffle[T](arr: Array[T])(implicit arg0: ST[T]): Array[T]

    Return a uniform random permutation of the array

    Return a uniform random permutation of the array

    Definition Classes
    package
  26. def sort[T](arr: Array[T])(implicit arg0: ST[T], arg1: ORD[T]): Array[T]

    Stable sort of array argument (not destructive), using radix sort implementation wherever possible.

    Stable sort of array argument (not destructive), using radix sort implementation wherever possible.

    arr

    Array to sort

    Definition Classes
    package
  27. def sum[T](arr: Array[T], offsets: Array[Int], missing: ⇒ T)(implicit arg0: ST[T], arg1: NUM[T], arg2: AddOp[T]): T

    Compute the sum of the array at particular offets.

    Compute the sum of the array at particular offets. If any of the offets is -1, the pass-by-name value 'missing' is used instead.

    For example,

      sum(Array(1,2,3,4), Array(0,2,), 0)
    
    Definition Classes
    package
  28. def take[T](arr: Array[T], offsets: Array[Int], missing: ⇒ T)(implicit arg0: ST[T]): Array[T]

    Takes values from array arr at particular offsets so as to produce a new array.

    Takes values from array arr at particular offsets so as to produce a new array. Offset -1 is mapped to by-name parameter missing.

    Note that each integer I at offset O in offsets works to "take" input[I] to output[O]. Eg, Array(2,0,1) permutes locations as follows:

    • 2 to 0
    • 0 to 1
    • 1 to 2

    For example,

      take(Array(5,6,7), Array(2,0,1), -1) == Array(7,5,6)
    
    Definition Classes
    package
  29. def tile[T](arr: Array[T], n: Int)(implicit arg0: ST[T]): Array[T]

    Repeat elements of the array some number of times

    Repeat elements of the array some number of times

    Definition Classes
    package