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: ScGrassMC.m
    path of file: ./repos/mctc4bmi/algs_mc/ScGrassMC
    
    the code of the file until where you have to start completion: function [U S V hist] = scaled_grass_mc(K, A_K, r, varargin)
% function [U S V hist] = scaled_grass_mc(K, A_K, k, varargin)
%
% Adapted from Boumal and Absil, 2011
% Adapted from C. T. Kelley, 1996-1997
%
% Matrix completion by geometric gradient descent with Armijo rule
% and polynomial linesearch 
% 
% Input: 
%   - K: *sparse* mask matrix of known entries (m x n)
%   - A_K: vector of known entries (nnz x 1)
%   - r: desired rank
%   - vargargin:
%     'maxit': max number of iteration (default 100)
%     'tol': tolera
    
function [xt,ft,succ,numf,iarm,lambda] = armijo_search(A_K,K,I,J,xc,fc,gc,lambda,grad_type,sigma_type,regval)
% Armijo line search with polynomial interpolation
% Adapted from Boumal and Absil, 2011
% Adapted from steep by C. T. Kelley, Dec 20, 1996
% xc, current point
% fc = F(sys,xc)
% gc is search direction
%
% returns: xt,ft: Armijo point and F(sys,xt)
%          succ = true if success
%          numf: nb of F evals
%          iarm: nb of Armijo backtrackings

alp = 1e-4;
bhigh=.5; blow=.1;
MAX_IARM = 5;
numf = 0;

% trial evaluation at full step
xt = moveEIG(A_K,K,I,J,xc,gc,lambda,sigma_type,0,regval);
ft = F(xt,regval);
numf = numf+1; iarm = 0;

fgoal = fc-alp*lambda*ip(xc,gc,gc,grad_type);
% polynomial line search
q0=fc; qp0=-ip(xc,gc,gc,grad_type); lamc=lambda; qc=ft;
while(ft > fgoal)    
  iarm=iarm+1;
  if iarm==1
    lambda=polymod(q0, qp0, lamc, qc, blow, bhigh);
  else
    lambda=polymod(q0, qp0, lamc, qc, blow, bhigh, lamm, qm);
  end