The following Matlab project contains the source code and Matlab examples used for ginv(x). Matlab's PINV(X) computes the Moore-Penrose generalized inverse of X, which is unique. Instead, GINV(X) computes any g-inverse of X. In fact, GINV returns a different g-inverse in each draw.
The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there.