You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: pinv_plus.m
    path of file: ./repos/spm/toolbox/DAiSS/private
    
    the code of the file until where you have to start completion: 
function [X, pca_order] = pinv_plus(A,varargin)
% PINV_PLUS   Modified Pseudoinverse which allows a specified
% dimensionality (order) to be passed in.
%
%   pinv_plus(A) is the same as pinv(A)
%
%   [X, pca_order]=pinv_plus(A,pca_order) uses at most only the top pca_order PCs to compute inverse
% 
    
function [X, pca_order] = pinv_plus(A,varargin)
% PINV_PLUS   Modified Pseudoinverse which allows a specified
% dimensionality (order) to be passed in.
%
%   pinv_plus(A) is the same as pinv(A)
%
%   [X, pca_order]=pinv_plus(A,pca_order) uses at most only the top pca_order PCs to compute inverse
% 
%   pinv_plus(A,pca_order,1) uses precisely the top pca_order PCs to compute inverse
%
%   If pca_order=-1 then calls spm_pca_order to compute order to use
%
%   Class support for input A: 
%      float: double, single
%
%   Mark Woolrich

tol=[];
r=size(A,1);

if nargin >= 2,
   pca_order = varargin{1};
   if(pca_order==-1),
      pca_order=spm_pca_order(A);
   end