Method ifThenElse
static member ifThenElse: Tensor<bool> -> Tensor<'T> -> Tensor<'T> -> Tensor<'T>
Element-wise choice between two sources depending on a condition.
Declaration
static member ifThenElse: cond:Tensor<bool> -> ifTrue:Tensor<'T> -> ifFalse:Tensor<'T> -> Tensor<'T>Parameters
| Type | Name | Description | 
|---|---|---|
| Tensor<bool> | cond | The condition tensor. | 
| Tensor<'T> | ifTrue | The tensor containing the values to use for when an element of the condition is true. | 
| Tensor<'T> | ifFalse | The tensor containing the values to use for when an element of the condition is false. | 
Returns
| Type | Description | 
|---|---|
| Tensor<'T> | A new tensor containing the result of this operation. | 
Remarks
Evaluates each element of tensor cond. If it evaluates to true, the corresponding
element of tensor ifTrue is written into the result. Otherwise, the corresponding element
of tensor ifFalse is written into the result.
The tensors cond, ifTrue and ifFalse must have 
the same storage.
Broadcasting rules apply if cond, ifTrue and ifFalse 
have different shapes.
Examples
 let cond = HostTensor.ofList [true; false; false]
 let ifTrue = HostTensor.ofList [2.0; 3.0; 4.0]
 let ifFalse = HostTensor.ofList [5.0; 6.0; 7.0]
 let target = Tensor.ifThenElse cond ifTrue ifFalse // target = [2.0; 6.0; 7.0]