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: a_zeros_index1.m
    path of file: ./repos/d2d/arFramework3/ThirdParty/StrucID/adimat/runtime
    
    the code of the file until where you have to start completion: % function r = a_zeros_index1(adjArrayVar, arrayVar, index1)
%   Zero adjoint of index expression after assignment. If the forward
%   assignment changed the size of the array variable, then mayb
    
function r = a_zeros_index1(adjArrayVar, arrayVar, index1)
%   Zero adjoint of index expression after assignment. If the forward
%   assignment changed the size of the array variable, then maybe
%   resize the adjoint here, undoing the size change.  If the size did
%   not change then fill the indexed adjoint with a_zeros.
%
% see also a_zeros, adimat_push_index, adimat_pop_index
%
% This file is part of the ADiMat runtime environment
%
function adj = a_zeros_index1(adj, arrayVar, ind)
  szAdj = size(adj);
  szVar = size(arrayVar);
  if isequal(szAdj, szVar)
    adj(ind) = a_zeros(arrayVar(ind));
  else
    test2 = zeros(szVar);
    test2(ind) = 1;
    test3 = ones(szVar);
    topIndex = num2cell(szAdj);
    test3(topIndex{:}) = 0;
    selwrit = test2 == 1;
    selold = test3 == 1;
    adj(selwrit) = a_zeros(adj(selwrit));
    adj = reshape(adj(selold), szVar);
  end