Action: SELECT_WITH_MASK
Module | valtools |
---|---|
Description | Usage |
Use a mask to select elements of an array | |
output value | type |
a vector/matrix of values that is obtained using a mask to select elements of interest | vector/matrix |
Input
The arguments that serve as the input for this action are specified using one or more of the keywords in the following table.
Keyword | Type | Description |
---|---|---|
ARG | scalar/vector/matrix | the label for the value upon which you are going to apply the mask |
ROW_MASK | vector | an array with ones in the rows of the matrix that you want to discard |
COLUMN_MASK | vector | an array with ones in the columns of the matrix that you want to discard |
MASK | vector/matrix | an array with ones in the components that you want to discard |
Further details and examples
Use a mask to select elements of an array
Output a scalar, vector or matrix that contains a subset of the elements in the input vector or matrix.
The following example shows how we can output a scalar, v
, that contains the distance between and 3 and 4
by using the mask vector m
to select this element from the three element vector d
:
dDISTANCECalculate the distance/s between pairs of atoms. More details ATOMS1the pair of atom that we are calculating the distance between=1,2 ATOMS2the pair of atom that we are calculating the distance between=3,4 ATOMS3the pair of atom that we are calculating the distance between=5,6 mCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=1,0,1 : v : SELECT_WITH_MASKUse a mask to select elements of an array More details ARGthe label for the value upon which you are going to apply the mask=d MASKan array with ones in the components that you want to discard=m:
The value, m
, that is passed to the keyword MASK here is a vector with the same length as d
.
Elements of d
that whose corresponding elements in m
are zero are copied to the output value v
.
When elements of m
are non-zero the corresponding elements in d
are not transferred to the output
value - they are masked.
If you use this action with matrices you must use the keywords ROW_MASK
and COLUMN_MASK
. As shown in the example
inputs below, these keywords take vectors as input. In this first example, the output matrix is 3×5 as rows
of the matrix whose corresponding elements in m
are non-zero are not transferred:
dDISTANCE_MATRIXCalculate a matrix of distances between atoms. This action has hidden defaults. More details GROUPthe atoms for which you would like to calculate the adjacency matrix=1-5 : mCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=0,1,1,0,0 : v : SELECT_WITH_MASKUse a mask to select elements of an array More details ARGthe label for the value upon which you are going to apply the mask=d ROW_MASKan array with ones in the rows of the matrix that you want to discard=m
For this second example the output matrix is 5×3 as columns of the matrix whose corresponding elements in m
are non-zero
are not transferred:
dDISTANCE_MATRIXCalculate a matrix of distances between atoms. This action has hidden defaults. More details GROUPthe atoms for which you would like to calculate the adjacency matrix=1-5 : mCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=0,1,1,0,0 : v : SELECT_WITH_MASKUse a mask to select elements of an array More details ARGthe label for the value upon which you are going to apply the mask=d COLUMN_MASKan array with ones in the columns of the matrix that you want to discard=m
For this final example the output matrix is 3×3 as we do not transfer the rows and the columns in d
whose corresponding
elements in m
are non-zero.
dDISTANCE_MATRIXCalculate a matrix of distances between atoms. This action has hidden defaults. More details GROUPthe atoms for which you would like to calculate the adjacency matrix=1-5 : mCONSTANTCreate a constant value that can be passed to actions This action has hidden defaults. More details VALUESthe numbers that are in your constant value=0,1,1,0,0 : v : SELECT_WITH_MASKUse a mask to select elements of an array More details ARGthe label for the value upon which you are going to apply the mask=d ROW_MASKan array with ones in the rows of the matrix that you want to discard=m COLUMN_MASKan array with ones in the columns of the matrix that you want to discard=m
Syntax
The following table describes the keywords and options that can be used with this action
Keyword | Type | Default | Description |
---|---|---|---|
ARG | input | none | the label for the value upon which you are going to apply the mask |
ROW_MASK | input | none | an array with ones in the rows of the matrix that you want to discard |
COLUMN_MASK | input | none | an array with ones in the columns of the matrix that you want to discard |
MASK | input | none | an array with ones in the components that you want to discard |
NUMERICAL_DERIVATIVES | optional | false | calculate the derivatives for these quantities numerically |