This is potentially inefficient because it copies all of `X`. Prefer

    X *= X
    X *= -1
    X += 1