// (left `binop` right), equivalently: (left - right `binop` 0) // NB: Allocates, does not overwrite the left or right term. public void And(LPSTerm left, InequalityType inequality, LPSTerm right) { LPSTerm t = LPSTerm.Const(0.0); t.Add(left); t.AddMul(right, -1.0); And(t, inequality); }
private LPSTerm doInnerProduct(LPSState state, LPSTerm[] vs, Vector <double> ds) { LPSTerm result = LPSTerm.Const(0.0); for (int i = 0; i < vs.Length; i++) { result.AddMul(vs[i], ds[i]); } return(result); }
public override LPSTerm ApplyKernelSymbolic(LPSState state, LPSTerm[] input, int outIndex, int channel, int row, int column) { int[] selections = state.Instrumentation[Index].Selections; int maxIndex = selections[outIndex]; LPSTerm maxInput = input[maxIndex]; for (int i = 0; i < KernelDimension; i++) { for (int j = 0; j < KernelDimension; j++) { int x = row - Padding + i; int y = column - Padding + j; if (x >= InputCoordinates.RowCount || y >= InputCoordinates.ColumnCount) { continue; } int curIndex = InputCoordinates.GetIndex(channel, x, y); if (curIndex == maxIndex) { continue; } if (curIndex < 0 || curIndex >= input.Length) { continue; } // maxInput - input[curIndex] >= 0 LPSTerm t = LPSTerm.Const(0.0); t.Add(maxInput); t.AddMul(input[curIndex], -1.0); state.DeferredCts.And(t, InequalityType.GE); } } return(maxInput); }