An important attribute, common to all Mappings, is the Invert flag. This is a boolean (integer) attribute that can be assigned a new value at any time. If it is non-zero, it has the effect of interchanging the Mapping's input and output coordinates and the Mapping is then said to be inverted. By default, the Invert attribute is zero.
There is no magic in this. There is no fancy arithmetic involved in inverting mathematical functions, for instance. The Invert flag is simply a switch that interchanges a Mapping's input and output ports. If it is non-zero, the Mapping's Nin and Nout attributes are swapped, its TranForward and TranInverse attributes are swapped, and when you ask for what was once the forward transformation you get the inverse transformation instead (and vice versa). When you return the Invert attribute to zero, or clear it, the Mapping returns to its original behaviour.
Often, the actual value of the Invert attribute is unimportant and you simply wish to invert its boolean sense, so that what was the Mapping's input becomes its output and vice versa. This is most easily accomplished using AST_INVERT, as follows:
INTEGER MAPPING ... CALL AST_INVERT( MAPPING, STATUS )
If the Mapping you have happens to be the wrong way around,
AST_INVERT allows you to correct the problem.
AST A Library for Handling World Coordinate Systems in Astronomy