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: cpd_minf.m
    path of file: ./repos/lrslibrary/libs/+tensorlab
    
    the code of the file until where you have to start completion: function [U,output] = cpd_minf(T,U0,options)
%CPD_MINF CPD by unconstrained nonlinear optimization.
%   [U,output] = cpd_minf(T,U0) computes the factor matrices U{1}, ...,
%   U{N} belonging to a canonical polyadic decomposition of the N-th order
%   tensor T by minimizing 0.5*frob(T-cpdgen(U))^2. The algorithm is
%   initialized with the factor matrices U0{n}. The structure output
%   returns additional information:
%
%      output.Name  - The name of the selected algorithm.
%      output.<...> - The output of the selected algorithm.
%
%   cpd_minf(T,U0,options) may be used to set the following options:
%
%      options.Algorithm =     - The desired optimization method.

    
function [U,output] = cpd_minf(T,U0,options)
%CPD_MINF CPD by unconstrained nonlinear optimization.
%   [U,output] = cpd_minf(T,U0) computes the factor matrices U{1}, ...,
%   U{N} belonging to a canonical polyadic decomposition of the N-th order
%   tensor T by minimizing 0.5*frob(T-cpdgen(U))^2. The algorithm is
%   initialized with the factor matrices U0{n}. The structure output
%   returns additional information:
%
%      output.Name  - The name of the selected algorithm.
%      output.<...> - The output of the selected algorithm.
%
%   cpd_minf(T,U0,options) may be used to set the following options:
%
%      options.Algorithm =     - The desired optimization method.
%      [{@minf_lbfgsdl}|...
%       @minf_lbfgs|@minf_ncg]
%      options.LineSearch =    - A function handle to the desired line
%      [{'auto'},@ls_mt|...      search algorithm. If the line search
%       @cpd_aels|@cpd_els|...   method has the prefix 'cpd_', it is
%       @cpd_lsb]                modified to be compatible with the
%                                optimization algorithm. Only applicable to
%                                algorithms with line search globalization.
%      options.PlaneSearch =   - A function handle to the desired CPD plane
%      [{false},@cpd_eps]        search algorithm. Only applicable to
%                                algorithms with trust region
%                                globalization.
%      options.<...>           - Parameters passed to the selected method,
%                                e.g., options.TolFun, options.TolX and
%                                options.LineSearchOptions. See also help
%                                [options.Algorithm].
%
%   See also cpd_nls.

%   Authors: Laurent Sorber (Laurent.Sorber@cs.kuleuven.be)
%            Marc Van Barel (Marc.VanBarel@cs.kuleuven.be)
%            Lieven De Lathauwer (Lieven.DeLathauwer@kuleuven-kulak.be)
%
%   References:
%   [1] L. Sorber, M. Van Barel, L. De Lathauwer, "Optimization-based
%       algorithms for tensor decompositions: canonical polyadic
%       decomposition, decomposition in rank-(Lr,Lr,1) terms and a new
%       generalization," SIAM J. Opt., 2013.
%   [2] L. Sorber, M. Van Barel, L. De Lathauwer, "Unconstrained
%       optimization of real functions in complex variables," SIAM J. Opt.,
%       Vol. 22, No. 3, 2012, pp. 879-898.

% Format the tensor T.
T = fmt(T,true);
if isstruct(T), size_tens = T.size;
else size_tens = [size(T) ones(1,length(U0)-ndims(T))]; end