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: bfgs.m
    path of file: ./repos/SGDLibrary/gd_solver
    
    the code of the file until where you have to start completion: function [w, infos] = bfgs(problem, options)
% BFGS algorithm.
%
% Inputs:
%       problem     function (cost/grad/hess)
%       options     options
%                   update_mode     'H'     Approximation inverse hessian (Eq. (6.17)) 
%                                   'B'     Approximation hessian (Eq. (6.19)) 
%                                   'Damp"  Damped BFGS updating by B (Procedure 18.2)
%
% Output:
%       w           solution of w
%       infos       information
%
% Reference:
%       Jorge Nocedal and Stephen Wright,
%       "Numerical optimization,"
%       Springer Science & Business Media, 2006.
%
%       Algorithm 6.1 in Section 6.1.
%       Procedure 18.2 in Section 18.3.
%
% This file is part of GDLibrary.
%
% Created by H.Kasai on Feb. 15, 2016
% Modified by H.Kasai on Mar. 25, 2018
% Modified by H.Kasai on May 11, 2023

    
function [w, infos] = bfgs(problem, options)
% BFGS algorithm.
%
% Inputs:
%       problem     function (cost/grad/hess)
%       options     options
%                   update_mode     'H'     Approximation inverse hessian (Eq. (6.17)) 
%                                   'B'     Approximation hessian (Eq. (6.19)) 
%                                   'Damp"  Damped BFGS updating by B (Procedure 18.2)
%
% Output:
%       w           solution of w
%       infos       information
%
% Reference:
%       Jorge Nocedal and Stephen Wright,
%       "Numerical optimization,"
%       Springer Science & Business Media, 2006.
%
%       Algorithm 6.1 in Section 6.1.
%       Procedure 18.2 in Section 18.3.
%
% This file is part of GDLibrary.
%
% Created by H.Kasai on Feb. 15, 2016
% Modified by H.Kasai on Mar. 25, 2018
% Modified by H.Kasai on May 11, 2023


    % set dimensions and samples
    d = problem.dim();
    n = problem.samples();  


    % extract options
    if ~isfield(options, 'step_init')
        step_init = 0.1;
    else
        step_init = options.step_init;
    end