ltindex.m
来自「马尔可夫链」· M 代码 · 共 31 行
M
31 行
% LTINDEX - Lower Triangular Index% Copyright (c) 1998, Harvard University. Full copyright in the file Copyright%% [irow, icol] = ltindex(index, dim) ;%% If a lower triangular matrix is packed in to a vector (column wise),% this calculates the matching row and column in the matrix for a % given index and dimension. (1,p) -> (1,1), (2,p) -> (2,1),% (p+1,p) -> (2,2), etc.%% See also: LTVEC%function [irow, icol] = ltindex(index, dim) ;irow = index ;icol = 1 ;while irow>dim & icol<= dim, icol = icol+1 ; irow = irow - dim + (icol-1) ;endif icol>dim, disp(sprintf('Error: ltindex: index=%d is too big for dim=%d',index,dim)); irow=NaN ; icol=NaN ; end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?