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: interpd.m
    path of file: ./repos/qups/kern
    
    the code of the file until where you have to start completion: function [y, k] = interpd(x, t, dim, interp, extrapval)
% INTERPD GPU-enabled interpolation in one dimension
%
% y = INTERPD(x, t) interpolates the data x at the indices t. It uses the
% matching and non-matching dimensions of the data to implicitly broadcast
% operations across the data. In other words, the data is formatted into
% the following:
%
%   x is (T x N' x      F')
%   t is (I x N' x M'     )
%   y is (I x N' x M' x F')
%
% Sampling is performed in the dimension matching I/T, element-wise in N'
% (where matc
    
function to determine type
isftype = @(x,T) strcmp(class(x), T) || any(arrayfun(@(c)isa(x,c),["tall", "gpuArray"])) && strcmp(classUnderlying(x), T);

% use ptx on gpu if available or use native MATLAB
if exist('interpd.ptx', 'file') ...
        && ( isa(x, 'gpuArray') || isa(t, 'gpuArray') ) ...
        && (ismember(interp, ["nearest", "linear", "cubic", "lanczos3"]))
    
    % determine the data type
    if     isftype(x, 'double')
        suffix = "" ; [x,t] = dealfun(@double, x, t);
    elseif isftype(x, 'single')
        suffix = "f"; [x,t] = dealfun(@single, x, t);
    elseif isftype(x, 'halfT'  )
        suffix = "h"; [x,t] = dealfun(@(x)gpuArray(halfT(x)), x, t); % custom type
    else
        warning("Datatype " + class(x) + " not recognized as a GPU compatible type.");
        suffix = "f" ;
    end