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: sbesselh2.m
    path of file: ./repos/ott/+ott/+utils
    
    the code of the file until where you have to start completion: function [hn,dhn] = sbesselh2(n,kr, varargin)
% SBESSELH2 spherical hankel function hn(kr) of the second kind
% hn(kr) = sqrt(pi/2kr) Hn+0.5(kr)
%
% hn = SBESSELH2(n,z) calculates the hankel function of the second kind.
%
% [hn,dzhn] = SBESSELH2(n,z) additionally, calculates the derivative
% of the appropriate Ricatti-Bessel function divided by z.
%
% See also besselj and bessely.

% This file is part of the optical tweezers toolbox.
% See LICENSE.md for information about using/distributing this file.

ott.warning('internal');

    
function [hn,dhn] = sbesselh2(n,kr, varargin)
% SBESSELH2 spherical hankel function hn(kr) of the second kind
% hn(kr) = sqrt(pi/2kr) Hn+0.5(kr)
%
% hn = SBESSELH2(n,z) calculates the hankel function of the second kind.
%
% [hn,dzhn] = SBESSELH2(n,z) additionally, calculates the derivative
% of the appropriate Ricatti-Bessel function divided by z.
%
% See also besselj and bessely.

% This file is part of the optical tweezers toolbox.
% See LICENSE.md for information about using/distributing this file.

ott.warning('internal');

p = inputParser;
p.addParameter('method', []);
p.parse(varargin{:});

method = p.Results.method;
if isempty(method)
  if any(abs(kr) < max(abs(n)))
    method = 'besselj+bessely';
  else
    method = 'besselh';
  end