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: vl_test_kdtree.m
    path of file: ./repos/CS_MoCo_LAB/reconstruction/matlab/CS_LAB_matlab/utils/utils_SURF/toolbox/xtest
    
    the code of the file until where you have to start completion: function results = vl_test_kdtree(varargin)
% VL_TEST_KDTREE
vl_test_init ;

function s = setup()
randn('state',0) ;
s.X = single(randn(10, 1000)) ;
s.Q = single(randn(10, 10)) ;


    
function results = vl_test_kdtree(varargin)
% VL_TEST_KDTREE
vl_test_init ;

function s = setup()
randn('state',0) ;
s.X = single(randn(10, 1000)) ;
s.Q = single(randn(10, 10)) ;

function test_nearest(s)
for tmethod = {'median', 'mean'}
  for type = {@single, @double}
    conv = type{1} ;
    tmethod = char(tmethod) ;

    X = conv(s.X) ;
    Q = conv(s.Q) ;
    tree = vl_kdtreebuild(X,'ThresholdMethod', tmethod) ;
    [nn, d2] = vl_kdtreequery(tree, X, Q) ;

    D2 = vl_alldist2(X, Q, 'l2') ;
    [d2_, nn_] = min(D2) ;

    vl_assert_equal(...
      nn,uint32(nn_),...
      'incorrect nns: type=%s th. method=%s', func2str(conv), tmethod) ;
    vl_assert_almost_equal(...
      d2,d2_,...
      'incorrect distances: type=%s th. method=%s', func2str(conv), tmethod) ;
  end