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: adimat_opdiff_epow_right.m
    path of file: ./repos/d2d/arFramework3/ThirdParty/StrucID/adimat/vector_directderivs
    
    the code of the file until where you have to start completion: % function d_res = adimat_opdiff_epow_right(d_val1, val1, val2)

    
function d_res = adimat_opdiff_epow_right(d_val1, val1, val2)
%
% Copyright 2014 Johannes Willkomm
% Copyright 2010-2012 Johannes Willkomm, Institute for Scientific Computing   
%                     RWTH Aachen University
%
% This file is part of the ADiMat runtime environment
%
function d_val1 = adimat_opdiff_epow_right(d_val1, val1, val2)
  ndd = size(d_val1, 1);
  factor1 = full(val2 .* val1 .^ (val2 - 1));
  if any((val2 - 1) < 0 & val1 == 0)
    warning('adimat:power:argZero', '%s', ...
            'x .^ y is evaluated with y < 0 and x == 0');
    factor1(isinf(factor1)) = adimat_missing_derivative_value();
  end