# Property M

#### property M: Tensor<bool> list -> Tensor<'T>

Picks elements from a tensor using one or more boolean mask tensors.

##### Declaration

`property M: Tensor<bool> list -> Tensor<'T> with get, set`

##### Parameters

Type | Name | Description |
---|---|---|

Tensor<bool> list | masks | A list of boolean mask tensors or val NoMask. |

##### Property Value

Type | Description |
---|---|

Tensor<'T> | All elements from the tensor for which the mask is true. |

##### Remarks

Masking picks elements from the tensor for which the corresponding element in the mask tensor is true. The mask can, for example, be generated by one or more element-wise comparison operation.

The get operation returns a copy of the selected elements of the tensor.

The set operation replaces the selected elements with a copy of the specified tensor.

If a dimension should not be masked, specify val NoMask instead of a mask tensor.

This mask specification variant is intended for programmatically generated ranges. For most use cases the variant property M: Tensor<bool> -> Tensor<'T> is more succinct and thus the recommended method.

##### Exceptions

Type | Condition |
---|---|

System.InvalidArgumentException | Raised when the mask is incompatible with the tensor. |

##### See Also

#### property M: Tensor<bool> -> Tensor<'T>

Picks elements from a tensor using one or more boolean mask tensors.

##### Declaration

`property M: Tensor<bool> -> Tensor<'T> with get, set`

##### Parameters

Type | Name | Description |
---|---|---|

Tensor<bool> | m0 | A boolean mask tensor or val NoMask. |

##### Property Value

Type | Description |
---|---|

Tensor<'T> | All elements from the tensor for which the mask is true. |

##### Remarks

Masking picks elements from the tensor for which the corresponding element in the mask tensor is true. The mask can, for example, be generated by one or more element-wise comparison operation.

The get operation returns a copy of the selected elements of the tensor.

The set operation replaces the selected elements with a copy of the specified tensor.

If a dimension should not be masked, specify val NoMask instead of a mask tensor.

For clarity the documentation does not list all overloads of `M`

.
However, this masking method can be used for up to 5 dimensions, as shown in the example.
For programmatically generated ranges or for more than 5 dimensions, the mask specification variant
property M: Tensor<bool> list -> Tensor<'T> is available.

Currently this operation is only supported for tensors stored on the host. Support for CUDA tensors is planned in the future.

##### Examples

```
let a = HostTensor.ofList [[1.0; 2.0; 3.0]
[4.0; 5.0; 6.0]]
// masked get with one mask for the whole tensor
let m = HostTensor.ofList [[true; true; false]
[false; false; true ]]
let b = a.M(m) // b = [1.0; 2.0; 6.0]
// an element-wise comparison operator can be used to create the mask
let c = a.M(a >>>> 3.5) // c = [4.0; 5.0; 6.0]
// masked get with one mask per dimension
let m0 = HostTensor.ofList [true; false]
let m1 = HostTensor.ofList [false; false; true]
let d = a.M(m0, m1) // d = [3.0]
// masked get using only one dimension
let m0 = HostTensor.ofList [true; false]
let e = a.M(m0, NoMask) // e = [[1.0; 2.0; 3.0]]
// masked set with one mask for the whole tensor
let m = HostTensor.ofList [[true; true; false]
[false; false; true ]]
a.M(m) <- [8.0; 9.0; 0.0] // a = [[8.0; 9.0; 3.0]
// [4.0; 5.0; 0.0]]
```

##### Exceptions

Type | Condition |
---|---|

System.InvalidArgumentException | Raised when the mask is incompatible with the tensor. |