function R = sodaRepMat(A,dims)


dimShifter = 0;
for k=numel(dims):-1:3
    if dims(k)==1
        dimShifter=dimShifter+1;
    else
        break
    end
end
B = repmat(A,dims)
R = shiftdim(B,dimShifter);

