Vec
is an immutable container for 1D homogeneous data (a "vector"). It is backed by an array and indexed from 0 to length - 1.
Several element access methods are provided.
The apply()
method returns a slice of the original vector:
val v = Vec(1,2,3,4)
v(0) == Vec(1)
v(1, 2) == Vec(2,3)
The at
method returns an instance of a org.saddle.scalar.Scalar, which behaves much like an Option
in that it can be either an instance of org.saddle.scalar.NA or a org.saddle.scalar.Value case class:
Vec[Int](1,2,3,na).at(0) == Scalar(1)
Vec[Int](1,2,3,na).at(3) == NA
The method raw
accesses the underlying value directly.
Vec(1d,2,3).raw(0) == 1d
Vec
may be used in arithmetic expressions which operate on two Vec
s or on a Vec
and a scalar value. A few examples:
Vec(1,2,3,4) + Vec(2,3,4,5) == Vec(3,5,7,9)
Vec(1,2,3,4) * 2 == Vec(2,4,6,8)
Note, Vec is implicitly convertible to an array for convenience; this could be abused to mutate the contents of the Vec. Try to avoid this!
Type parameters
- T
-
Type of elements within the Vec
Attributes
- Companion
- object
- Graph
-
- Supertypes
- Known subtypes
-
class VecDefault[T]
Members list
Value members
Abstract methods
Access an unboxed element of a Vec[A] at a single location Same as raw
Access an unboxed element of a Vec[A] at a single location Same as raw
Value parameters
- loc
-
offset into Vec
- locs
-
locations at which to slice
Attributes
Integer offset of the minimum element of the Vec, if one exists, or else -1
Integer offset of the minimum element of the Vec, if one exists, or else -1
Attributes
Integer offset of the minimum element of the Vec, if one exists, or else -1
Integer offset of the minimum element of the Vec, if one exists, or else -1
Attributes
Access a boxed element of a Vec[A] at a single location
Access a boxed element of a Vec[A] at a single location
Value parameters
- loc
-
offset into Vec
Attributes
Concatenate two Vec instances together, where there exists some way to join the type of elements. For instance, Vec[Double] concat Vec[Int] will promote Int to Double as a result of the implicit existence of an instance of Promoter[Double, Int, Double]
Concatenate two Vec instances together, where there exists some way to join the type of elements. For instance, Vec[Double] concat Vec[Int] will promote Int to Double as a result of the implicit existence of an instance of Promoter[Double, Int, Double]
Type parameters
- B
-
type of other Vec elements
- C
-
type of resulting Vec elements
Value parameters
- mc
-
Implicit evidence of ST[C]
- v
-
Vec[B] to concat
- wd
-
Implicit evidence of Promoter[A, B, C]
Attributes
Return copy of backing array
Return copy of backing array
Attributes
Returns a Vec whose backing array has been copied
Returns a Vec whose backing array has been copied
Attributes
Returns a Vec with the first i
elements removed
Returns a Vec with the first i
elements removed
Attributes
Drop the elements of the Vec which are NA
Drop the elements of the Vec which are NA
Attributes
Returns a Vec with the last i
elements removed
Returns a Vec with the last i
elements removed
Attributes
Return true if there exists some element of the Vec which satisfies the predicate function
Return true if there exists some element of the Vec which satisfies the predicate function
Value parameters
- pred
-
Predicate function from A => Boolean
Attributes
Fill NA values by propagating defined values backward.
Fill NA values by propagating defined values backward.
Value parameters
- limit
-
If > 0, propagate over a maximum of
limit
consecutive NA values
Attributes
Fill NA values by propagating defined values forward.
Fill NA values by propagating defined values forward.
Value parameters
- limit
-
If > 0, propagate over a maximum of
limit
consecutive NA values
Attributes
Fills NA values in vector with result of a function which acts on the index of the particular NA value found
Fills NA values in vector with result of a function which acts on the index of the particular NA value found
Value parameters
- f
-
A function from Int => A; yields value for NA value at ith position
Attributes
Fill NAs by propagating existent values.
Fill NAs by propagating existent values.
Value parameters
- fm
-
Filling method, forward or backward
- limit
-
If > 0, fill a maximum of
limit
consecutive NA values
Attributes
Return Vec whose elements satisfy a predicate function
Return Vec whose elements satisfy a predicate function
Value parameters
- pred
-
Predicate function from A => Boolean
Attributes
Return vec whose offets satisfy a predicate function
Return vec whose offets satisfy a predicate function
Value parameters
- pred
-
Predicate function from Int => Boolean
Attributes
Filtered left fold over the elements of the Vec, as in scala collections library
Filtered left fold over the elements of the Vec, as in scala collections library
Attributes
Filtered left scan over elements of the Vec, as in scala collections library
Filtered left scan over elements of the Vec, as in scala collections library
Attributes
Return Vec of integer locations (offsets) which satisfy some predicate
Return Vec of integer locations (offsets) which satisfy some predicate
Value parameters
- pred
-
Predicate function from A => Boolean
Attributes
Return first integer location which satisfies some predicate, or -1 if there is none
Return first integer location which satisfies some predicate, or -1 if there is none
Value parameters
- pred
-
Predicate function from A => Boolean
Attributes
Access the first element of a Vec[A], or NA if length is zero
Access the first element of a Vec[A], or NA if length is zero
Attributes
Maps a function over elements of the Vec and flattens the result.
Maps a function over elements of the Vec and flattens the result.
NAs are ignored and f
is never called on a NA
Attributes
Left fold over the elements of the Vec, as in scala collections library
Left fold over the elements of the Vec, as in scala collections library
Attributes
Left fold that folds only while the test condition holds true. As soon as the condition function yields false, the fold returns.
Left fold that folds only while the test condition holds true. As soon as the condition function yields false, the fold returns.
Value parameters
- cond
-
Function whose signature is the same as the fold function, except that it evaluates to Boolean
Attributes
Execute a (side-effecting) operation on each (non-NA) element in vec which satisfies some predicate.
Execute a (side-effecting) operation on each (non-NA) element in vec which satisfies some predicate.
Value parameters
- op
-
Side-effecting function
- pred
-
Function A => Boolean
Attributes
Execute a (side-effecting) operation on each (non-NA) element in the vec
Execute a (side-effecting) operation on each (non-NA) element in the vec
Value parameters
- op
-
operation to execute
Attributes
Return true if there is an NA value in the Vec
Return true if there is an NA value in the Vec
Attributes
Return first n elements
Return first n elements
Value parameters
- n
-
Number of elements to access
Attributes
True if and only if number of elements is zero
True if and only if number of elements is zero
Attributes
Access the last element of a Vec[A], or NA if length is zero
Access the last element of a Vec[A], or NA if length is zero
Attributes
The number of elements in the container F
The number of elements in the container F
Attributes
Map a function over the elements of the Vec, as in scala collections library
Map a function over the elements of the Vec, as in scala collections library
Attributes
Returns Vec whose locations corresponding to true entries in the boolean input mask vector are set to NA
Returns Vec whose locations corresponding to true entries in the boolean input mask vector are set to NA
Value parameters
- m
-
Mask vector of Vec[Boolean]
Attributes
Returns Vec whose locations are NA where the result of the provided function evaluates to true
Returns Vec whose locations are NA where the result of the provided function evaluates to true
Value parameters
- f
-
A function taking an element and returning a Boolean
Attributes
Return the mean of the values in the Vec, ignoring NA
Return the mean of the values in the Vec, ignoring NA
Attributes
Return the median of the values in the Vec, ignoring NA
Return the median of the values in the Vec, ignoring NA
Attributes
Set to true when the vec is shifted over the backing array false iff the backing array is a contiguous sequence of the elements of this Vec false iff 0 until length map (raw) == the backing array
Set to true when the vec is shifted over the backing array false iff the backing array is a contiguous sequence of the elements of this Vec false iff 0 until length map (raw) == the backing array
Attributes
Return Vec whose elements are selected via negating a Vec of booleans (where that Vec holds the value true)
Return Vec whose elements are selected via negating a Vec of booleans (where that Vec holds the value true)
Value parameters
- pred
-
Predicate vector: Vec[Boolean]
Attributes
Return the percentile of the values at a particular threshold, ignoring NA
Return the percentile of the values at a particular threshold, ignoring NA
Value parameters
- method
-
The percentile method; one of org.saddle.PctMethod
- tile
-
The percentile in [0, 100] at which to compute the threshold
Attributes
Pretty-printer for Vec, which simply outputs the result of stringify.
Pretty-printer for Vec, which simply outputs the result of stringify.
Value parameters
- len
-
Number of elements to display
Attributes
Product of all the values in the Vec, ignoring NA values
Product of all the values in the Vec, ignoring NA values
Attributes
Return a Vec of ranks corresponding to a Vec of numeric values.
Return a Vec of ranks corresponding to a Vec of numeric values.
Value parameters
- ascending
-
Boolean, default true, whether to give lower values larger rank
- tie
-
Method with which to break ties; a org.saddle.RankTie
Attributes
Access an unboxed element of a Vec[A] at a single location Same as apply
Access an unboxed element of a Vec[A] at a single location Same as apply
Value parameters
- loc
-
offset into Vec
Attributes
Reshapes the Vec into a Mat
Reshapes the Vec into a Mat
May not copy. The new Mat instance may share data with this Vec.
Attributes
Yield a Vec whose elements have been reversed from their original order
Yield a Vec whose elements have been reversed from their original order
Attributes
Produce a Vec whose entries are the result of executing a function on a sliding window of the data.
Produce a Vec whose entries are the result of executing a function on a sliding window of the data.
Type parameters
- B
-
Result type of function
Value parameters
- f
-
Function Vec[A] => B to operate on sliding window
- winSz
-
Window size
Attributes
Rounds elements in the vec (which must be numeric) to a significance level
Rounds elements in the vec (which must be numeric) to a significance level
Value parameters
- sig
-
Significance level to round to (e.g., 2 decimal places)
Attributes
A ScalarTag in the type of the elements of the Vec
A ScalarTag in the type of the elements of the Vec
Attributes
Left scan over the elements of the Vec, as in scala collections library
Left scan over the elements of the Vec, as in scala collections library
Attributes
Creates a view into original Vec, but shifted so that n values at the beginning or end of the Vec are NA's. Data is not copied.
Creates a view into original Vec, but shifted so that n values at the beginning or end of the Vec are NA's. Data is not copied.
Value parameters
- n
-
Number of offsets to shift
Attributes
Creates a view into original vector from an offset up to, but excluding, another offset. Data is not copied.
Creates a view into original vector from an offset up to, but excluding, another offset. Data is not copied.
Value parameters
- from
-
Beginning offset
- stride
-
Increment within slice
- until
-
One past ending offset
Attributes
Creates a view into original vector from an offset up to, and including, another offset. Data is not copied.
Creates a view into original vector from an offset up to, and including, another offset. Data is not copied.
Value parameters
- from
-
Beginning offset
- stride
-
Increment within slice
- to
-
Ending offset
Attributes
Yield a Vec whose elements have been sorted (in ascending order)
Yield a Vec whose elements have been sorted (in ascending order)
Value parameters
- ev
-
evidence of Ordering[A]
Attributes
Split Vec into two Vecs at position i
Split Vec into two Vecs at position i
Value parameters
- i
-
Position at which to split Vec
Attributes
Creates a string representation of Vec
Creates a string representation of Vec
Value parameters
- len
-
Max number of elements to include
Attributes
Return last n elements
Return last n elements
Value parameters
- n
-
Number of elements to access
Attributes
Equivalent to slicing operation; e.g.
Equivalent to slicing operation; e.g.
val v = Vec(1,2,3)
v.take(0,1) == v(0,1)
Value parameters
- locs
-
Location of elements to take
Attributes
Slice a Vec at a bound of locations, e.g.
Slice a Vec at a bound of locations, e.g.
val v = Vec(1,2,3,4,5) v(1->3) == Vec(2,3,4)
Value parameters
- rng
-
evaluates to IRange
Attributes
Returns a Vec with the first i
elements
Returns a Vec with the first i
elements
Attributes
Returns a Vec with the last i
elements
Returns a Vec with the last i
elements
Attributes
Converts Vec to an indexed sequence (default implementation is immutable.Vector)
Converts Vec to an indexed sequence (default implementation is immutable.Vector)
Attributes
Additive inverse of Vec with numeric elements
Additive inverse of Vec with numeric elements
Attributes
Updates (overwrites) a location in the Vec
Updates (overwrites) a location in the Vec
Mutates the underlying array
Attributes
Updates (overwrites) a range in the Vec
Updates (overwrites) a range in the Vec
Mutates the underlying array
Attributes
Updates (overwrites) a range in the Vec
Updates (overwrites) a range in the Vec
Mutates the underlying array
Attributes
Returns a new Vec with the value at offset
set to `value
Returns a new Vec with the value at offset
set to `value
Copies before mutating.
Attributes
Returns a new Vec with the values at offset
set to `value
Returns a new Vec with the values at offset
set to `value
Copies before mutating. Ignores invalid offsets in the array
Attributes
Creates a view into original vector at arbitrary indexes. Data is not copied.
Creates a view into original vector at arbitrary indexes. Data is not copied.
Value parameters
- offsets1
-
indexes into the original array
Attributes
Return Vec whose elements are selected via a Vec of booleans (where that Vec holds the value true)
Return Vec whose elements are selected via a Vec of booleans (where that Vec holds the value true)
Value parameters
- pred
-
Predicate vector: Vec[Boolean]
Attributes
Return Vec whose elements are selected via negating a Vec of booleans (where that Vec holds the value true)
Return Vec whose elements are selected via negating a Vec of booleans (where that Vec holds the value true)
Value parameters
- pred
-
Predicate vector: Vec[Boolean]
Attributes
The complement of the take operation; slice out elements NOT specified in list.
The complement of the take operation; slice out elements NOT specified in list.
Value parameters
- locs
-
Location of elements not to take
Attributes
Zips Vec with another Vec and applies a function to the paired elements. If either of the pair is NA, the result is forced to NA.
Zips Vec with another Vec and applies a function to the paired elements. If either of the pair is NA, the result is forced to NA.
Type parameters
- B
-
Parameter of other Vec
- C
-
Result of function
Value parameters
- f
-
Function (A, B) => C
- other
-
Vec[B]
Attributes
Concrete methods
True if all elements are true
True if all elements are true
Attributes
Number of elements which are false
Number of elements which are false
Attributes
Number of elements which are true
Number of elements which are true
Attributes
True if no elements are true
True if no elements are true
Attributes
One pass Pearson correlation coefficient. Does not filter out NAs. https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf
One pass Pearson correlation coefficient. Does not filter out NAs. https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf
Attributes
One pass covariance of two vectors
One pass covariance of two vectors
https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2008/086212.pdf
Attributes
True if some elements are true
True if some elements are true
Attributes
Inherited methods
Integer modulus of division
Integer modulus of division
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance (divisor)
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Bit-wise AND
Bit-wise AND
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Logical AND
Logical AND
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Multiplication
Multiplication
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Exponentiation
Exponentiation
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance (exponent)
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Addition
Addition
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Subtraction
Subtraction
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Division
Division
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance (divisor)
Attributes
- Inherited from:
- NumericOps
Attributes
- Inherited from:
- NumericOps
Less-than comparison operator
Less-than comparison operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Bit-shift left
Bit-shift left
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Less-than-or-equal-to comparison operator
Less-than-or-equal-to comparison operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Element-wise inequality operator
Element-wise inequality operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Element-wise equality operator
Element-wise equality operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Greater-than comparison operator
Greater-than comparison operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Greater-than-or-equal-to comparison operator
Greater-than-or-equal-to comparison operator
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Bit-shift right (arithmetic)
Bit-shift right (arithmetic)
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Bit-shift right (logical)
Bit-shift right (logical)
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Bit-wise EXCLUSIVE OR
Bit-wise EXCLUSIVE OR
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Dot (inner) product
Dot (inner) product
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Outer product
Outer product
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Logical EXCLUSIVE OR
Logical EXCLUSIVE OR
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Bit-wise OR
Bit-wise OR
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps
Logical OR
Logical OR
Type parameters
- B
-
type of the other operand
- That
-
result type of operation
Value parameters
- op
-
implicit evidence for operation between this and other
- other
-
other operand instance
Attributes
- Inherited from:
- NumericOps