org.saddle.array

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

Attributes

Members list

Type members

Classlikes

object InsertionSort

An implementation of insertion sort.

An implementation of insertion sort.

Works well for small arrays but due to quadratic complexity is not generally optimal.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object MergeSort

In-place merge sort implementation. This sort is stable but does mutate the given array. It is an in-place sort but it does allocate a temporary array of the same size as the input. It uses InsertionSort for sorting very small arrays.

In-place merge sort implementation. This sort is stable but does mutate the given array. It is an in-place sort but it does allocate a temporary array of the same size as the input. It uses InsertionSort for sorting very small arrays.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
MergeSort.type

An implementation of insertion sort.

An implementation of insertion sort.

Works well for small arrays but due to quadratic complexity is not generally optimal.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

In-place merge sort implementation. This sort is stable but does mutate the given array. It is an in-place sort but it does allocate a temporary array of the same size as the input. It uses InsertionSort for sorting very small arrays.

In-place merge sort implementation. This sort is stable but does mutate the given array. It is an in-place sort but it does allocate a temporary array of the same size as the input. It uses InsertionSort for sorting very small arrays.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait Sorter[T]

Typeclass interface for sorting implementations

Typeclass interface for sorting implementations

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object boolSorter.type
object byteSorter.type
object charSorter.type
object doubleSorter.type
object floatSorter.type
object intSorter.type
object longSorter.type
object shortSorter.type
Show all
object Sorter

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Sorter.type

Value members

Concrete methods

def argmax[T : Numeric](arr: Array[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

Attributes

def argmin[T : Numeric](arr: Array[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

Attributes

def argsort[T : Order](arr: Array[T])(implicit evidence$10: Order[T], st: ScalarTag[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.

Value parameters

arr

Array to sort

Attributes

def argsort[T : Order](vec: Vec[T]): Array[Int]
def copySlice[T : ScalarTag](from: Int, until: Int, source: Array[T]): Array[T]

Copies a contiguous segment of the array into a new array.

Copies a contiguous segment of the array into a new array.

Value parameters

from

start index, inclusive

source

source array to copy

until

end index, exclusive

Attributes

def empty[T : ScalarTag](len: Int): Array[T]

Create a new initialized empty array

Create a new initialized empty array

Attributes

def fill[T](arr: Array[T], v: T): Unit

Fill array with value

Fill array with value

Attributes

def filter[T : ScalarTag](f: T => Boolean)(arr: Array[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

Attributes

def flatten[T : ClassTag](arrs: Seq[Array[T]]): Array[T]

Flatten a sequence of arrays into a single array

Flatten a sequence of arrays into a single array

Attributes

def linspace(start: Double, stop: Double, num: Int, endpoint: Boolean): Array[Double]

Derived from numpy 1.7

Derived from numpy 1.7

Return evenly spaced numbers over a specified interval.

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

If start < stop, then the order of elements are decreasing.

The endpoint of the interval can optionally be excluded.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

def randDouble(sz: Int, rng: Generator): Array[Double]

Generate an array of random doubles on [0,1)

Generate an array of random doubles on [0,1)

Attributes

def randDouble(sz: Int): Array[Double]

Generate an array of random doubles on [0,1)

Generate an array of random doubles on [0,1)

Attributes

def randDouble(sz: Int, n: Double, rng: Generator): Array[Double]

Generate an array of random doubles on [0,n)

Generate an array of random doubles on [0,n)

Attributes

def randDouble(sz: Int, n: Double): Array[Double]

Generate an array of random doubles on [0,n)

Generate an array of random doubles on [0,n)

Attributes

def randDouble(sz: Int, min: Double, until: Double, rng: Generator): Array[Double]

Generate an array of random doubles on [min,until)

Generate an array of random doubles on [min,until)

Attributes

def randDouble(sz: Int, min: Double, until: Double): Array[Double]

Generate an array of random doubles on [min,until)

Generate an array of random doubles on [min,until)

Attributes

def randDoublePos(sz: Int, rng: Generator): Array[Double]

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

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

Attributes

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]

Attributes

def randInt(sz: Int, rng: Generator): Array[Int]

Generate an array of random integers

Generate an array of random integers

Attributes

def randInt(sz: Int): Array[Int]

Generate an array of random integers

Generate an array of random integers

Attributes

def randInt(sz: Int, from: Int, to: Int, rng: Generator): Array[Int]

Generate an array of random integers in [from,to]

Generate an array of random integers in [from,to]

Attributes

def randInt(sz: Int, from: Int, to: Int): Array[Int]

Generate an array of random integers in [from,to]

Generate an array of random integers in [from,to]

Attributes

def randIntPos(sz: Int, rng: Generator): Array[Int]

Generate an array of random positive integers

Generate an array of random positive integers

Attributes

def randIntPos(sz: Int): Array[Int]

Generate an array of random positive integers

Generate an array of random positive integers

Attributes

def randLong(sz: Int, rng: Generator): Array[Long]

Generate an array of a random long integers

Generate an array of a random long integers

Attributes

def randLong(sz: Int): Array[Long]

Generate an array of a random long integers

Generate an array of a random long integers

Attributes

def randLong(sz: Int, from: Long, to: Long, rng: Generator): Array[Long]

Generate an array of a random long integers in [from,to]

Generate an array of a random long integers in [from,to]

Attributes

def randLong(sz: Int, from: Long, to: Long): Array[Long]

Generate an array of a random long integers in [from,to]

Generate an array of a random long integers in [from,to]

Attributes

def randLongPos(sz: Int, rng: Generator): Array[Long]

Generate an array of random long positive integers

Generate an array of random long positive integers

Attributes

def randLongPos(sz: Int): Array[Long]

Generate an array of random long positive integers

Generate an array of random long positive integers

Attributes

def randNormal(sz: Int, rng: Generator): 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.

Attributes

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.

Attributes

def randNormal2(sz: Int, mu: Double, sigma: Double, rng: Generator): 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.

Attributes

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.

Attributes

def range(from: Int, until: Int, step: Int): 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)

Attributes

def remove[T : ScalarTag](arr: Array[T], locs: Array[Int]): 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.

Attributes

def reverse[T : ScalarTag](arr: Array[T]): Array[T]

Reverse an array

Reverse an array

Attributes

def send[T : ScalarTag](arr: Array[T], offsets: Array[Int]): Array[T]

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:

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)

Attributes

def shuffle[T](arr: Array[T], rng: Generator): Array[T]

Return a uniform random permutation of the array

Return a uniform random permutation of the array

Attributes

def shuffle[T](arr: Array[T]): Array[T]

Return a uniform random permutation of the array

Return a uniform random permutation of the array

Attributes

def sort[T : Order](arr: Array[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.

Value parameters

arr

Array to sort

Attributes

def sum[T : Numeric](arr: Array[T], offsets: Array[Int], missing: => T): T

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.

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)

Attributes

def take[T : ScalarTag](arr: Array[T], offsets: Array[Int], missing: => T): Array[T]

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

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)

Attributes

def take[T : ScalarTag](arr: Array[T], offsets: Vec[Int], missing: => T): Array[T]

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

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)

Attributes

def tile[T : ScalarTag](arr: Array[T], n: Int): Array[T]

Repeat elements of the array some number of times

Repeat elements of the array some number of times

Attributes