/*! \brief apply iterative refinement of the solution of a matrix inversion
*
* iteratively compute and apply a correction to the inverse inva of the complex matrix aorig, for a maximum number of maxiters times, or until achieving a maximum residual better than accuracygoal
*
* \param aorig: pointer to the first element of the matrix of complex to be inverted.
* \param inva: pointer to the first element of inverse.
* \param n: `np_int` The number of rows and columns of the [n x n] matrices.
* \param jer: `int &` Reference to an integer return flag.
* \param maxrefiters: `int` Maximum number of refinement iterations to apply.
* \param accuracygoal: `double` Accuracy to achieve in iterative refinement, defined as the module of the maximum difference between the identity matrix and the matrix product of the (approximate) inverse times the original matrix. On return, it contains the actually achieved accuracy
* \param device_id: `int` ID of the device for matrix inversion offloading.