I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for ea
I believe the only way to compute an inverse is to solve n times the equation: A x = y, where y spans the unit vectors, i.e., the first one is (1,0,0,0), the second is (0,1,0,0), etc.
(Using the cofactors (Cramer's rule) is a bad idea, unless you want a symbolic formula for the inverse.)
Most linear algebra libraries will allow you to solve those linear systems, and even to compute an inverse. Example in python (using numpy):
from numpy.linalg import inv
inv(A) # here you go