Exemplo n.º 1
0
        // (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);
        }
Exemplo n.º 2
0
        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);
        }