Class MatrixUtil
java.lang.Object
ubic.basecode.dataStructure.matrix.MatrixUtil
- Author:
- Paul
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DoubleMatrix1DapplyToIndicesMatchingCriteria(DoubleMatrix1D x, DoubleFunction<Boolean> criterion, DoubleFunction<Double> action) static final BooleanArrayListCompute the conjuction (logical 'and') of two boolean vectorsstatic booleanstatic DoubleMatrix1Ddiagonal(DoubleMatrix2D matrix) Extract the diagonal from a matrix.static DoubleMatrix2DdropColumn(DoubleMatrix2D n, int indexToDrop) static DoubleMatrix2DdropColumns(DoubleMatrix2D n, Collection<Integer> droppedColumns) static DoubleMatrix1DfromList(DoubleArrayList list) Makes a copystatic <R,C, V> V static <R,C, V> V[] static voidmaskMissing(DoubleMatrix2D source, DoubleMatrix2D target) static BooleanArrayListmatchingCriteria(DoubleMatrix1D x, DoubleFunction<Boolean> criterion) static DoubleMatrix1Dstatic DoubleMatrix1Dstatic DoubleMatrix2DMultiple two matrices, tolerate missing values.static final DoubleMatrix1Dstatic DoubleMatrix1Dstatic DoubleMatrix1DremoveMissingOrInfinite(DoubleMatrix1D reference, DoubleMatrix1D data) Remove values from data corresponding to missing values in reference.static voidreplaceValues(DoubleMatrix1D x, BooleanArrayList toReplace, DoubleMatrix1D replacements) Perform the awkward operation of substituting certain values in a vector from values in another vector.static DoubleMatrix1Dselect(DoubleMatrix1D v, Collection<Integer> selected) static DoubleMatrix2DselectColumns(DoubleMatrix2D n, Collection<Integer> selected) static DoubleMatrix2DselectColumnsAndRows(DoubleMatrix2D n, Collection<Integer> selected) static DoubleMatrix2DselectRows(DoubleMatrix2D n, Collection<Integer> selected) static intstatic final DoubleMatrix1DstripByCriterion(DoubleMatrix1D x, DoubleFunction<Boolean> criterion) static final DoubleMatrix1Dstatic final DoubleMatrix1Dstatic DoubleArrayListtoList(DoubleMatrix1D vector) Makes a copy
-
Constructor Details
-
MatrixUtil
public MatrixUtil()
-
-
Method Details
-
containsNearlyZeros
- Parameters:
d-- Returns:
- true if any of the values are very close to zero.
-
diagonal
Extract the diagonal from a matrix.- Parameters:
matrix-- Returns:
-
dropColumn
- Parameters:
n-indexToDrop-- Returns:
-
dropColumns
- Parameters:
n-droppedColumns-
-
fromList
Makes a copy- Parameters:
list-- Returns:
-
getObject
- Type Parameters:
R-C-V-- Parameters:
matrix-rowIndex-colIndex-- Returns:
-
getRow
- Type Parameters:
R-C-V-- Parameters:
matrix-rowIndex-- Returns:
-
maskMissing
- Parameters:
source- the source of information about missing valuestarget- the target where we want to convert values to missing
-
multWithMissing
-
multWithMissing
- Parameters:
a-b-- Returns:
-
multWithMissing
Multiple two matrices, tolerate missing values.- Parameters:
a-b-- Returns:
-
notNearlyZeroIndices
-
removeMissingOrInfinite
- Parameters:
data-- Returns:
- a copy of the data with missing or infinite values removed (might be empty!)
-
removeMissing
- Parameters:
x-- Returns:
- a copy of x with missing values removed
-
removeMissingOrInfinite
Remove values from data corresponding to missing values in reference.- Parameters:
reference-data-- Returns:
-
stripNegative
-
stripByCriterion
public static final DoubleMatrix1D stripByCriterion(DoubleMatrix1D x, DoubleFunction<Boolean> criterion) -
conjunction
Compute the conjuction (logical 'and') of two boolean vectors- Parameters:
a-b-- Returns:
- conjunction of a and b
-
matchingCriteria
public static BooleanArrayList matchingCriteria(DoubleMatrix1D x, DoubleFunction<Boolean> criterion) - Parameters:
x- vector to be operated oncriterion- a function that returns a boolean if a double matches the desired criteria- Returns:
- booleans indicating which values in x match the criterion func
-
applyToIndicesMatchingCriteria
public static DoubleMatrix1D applyToIndicesMatchingCriteria(DoubleMatrix1D x, DoubleFunction<Boolean> criterion, DoubleFunction<Double> action) - Parameters:
x- vector to be operated oncriterion- criterion used to test values if they should be acted on.action- function applied to values if they match the criterion- Returns:
- copy of x in which the values meeting the criterion have been replaced with the return value of action, otherwise unchanged from the original x
-
stripNonOK
- Parameters:
x- a vector of values to be filteredok- a list of booleans defining which values are "ok".- Returns:
- A copy of x that has the non-ok values removed.
-
replaceValues
public static void replaceValues(DoubleMatrix1D x, BooleanArrayList toReplace, DoubleMatrix1D replacements) Perform the awkward operation of substituting certain values in a vector from values in another vector.- Parameters:
x- vector to be operated on in place (it will be modified).toReplace- boolean indicators of same length of x, 'true' indicates a value to be replaced in x with a value from 'replacements'; 'false' will be unmodified in x.replacements- the replacements, in order, to be substituted in x where toReplace(i) is true. This vector can be shorter than x.
-
select
-
selectColumns
-
selectColumnsAndRows
- Parameters:
n- square matrixselected-- Returns:
-
selectRows
-
sizeWithoutMissingValues
-
toList
Makes a copy- Parameters:
vector-- Returns:
-