In optimization applications, it is very rare that anyone wants to see an entire matrix inverse. Thus AMPL does not contain any routines for inverting a matrix; rather, matrix algorithms are left to the solvers.
I recommend using a library routine for the matrix inverse in some popular general-purpose language (for example, a SciPy routine in Python, or a matrix function in MATLAB). Then use the corresponding
AMPL API to call AMPL to do your optimization.