I am facing an issue concerning how to store the lower triangular factor of a given symmetric matrix (it's a distance matrix) into a vector.
Generally, I would like directly generating the lower triangular entries by only giving the coordinates (Y,Z) of a set of points on a rectangular grid: and actually it's where I got terribly stuck.
So that, I started thinking to attack the problem from a slightly different point of view: generating the full distance matrix (again given the (Y,Z) couples) and then half vectorize the distance matrix.
Nevertheless, I don't really have a sound idea on how to achieve the goal by means of for loops. 
Besides I also know that there may be any external Java library which implements the vech function: vech returns the vector obtained by eliminating all supradiagonal elements of the square matrix X and stacking the result one column above the other. This has uses in matrix calculus where the underlying matrix is symmetric and it would be pointless to keep values above the main diagonal. 
Substantially, given a matrix A = {{a,c},{b,d}}, by applying vech(A), the result will be
vech(A) = {a,b,d}.
EDIT
I mean something like the following:
    a11 a12 a13 a14
        a22 a23 a24
 A=         a33 a34  (aij = aji)
                a44
Packed storage of the upper triangle of A:
  AP = { a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 }