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: ltindex.m
    path of file: ./repos/supermodeling/算法代码案例/蒙特卡罗算法/蒙特卡罗算法mcmc
    
    the code of the file until where you have to start completion: % LTINDEX - Lower Triangular Index
% Copyright (c) 1998, Harvar
    
function [irow, icol] = ltindex(index, dim) ;

irow = index ;

icol = 1 ;
while irow>dim & icol<= dim,
  icol = icol+1 ;
  irow = irow - dim + (icol-1) ;
end