Regarding vech() for array

Hello I just wanted to check whether there is any function similar to vech() in GAUSS. For example if I have a 100 by 4 by 4 array and I want a 100 by 4*(4+1)/2 matrix where each row is basically the vech of each of the 100 4 by 4 array, is there any way of doing that, without looping through each plane of the 100 by 4 by 4 array, and using vech on each of 4 by 4 matrices?

Thank you much

Annesha

2 Answers



0



There is no built-in procedure to perform the equivalent of vech on each sub-matrix of a multi-dimensional array. However, you could write a procedure to do it. Something like this would work:

proc (1) = avech(a);
    local a_orders, out, i, n_mats, r;
    
    //This assumes a 3-dimensional array
    //where the last two dimensions are the same
    a_orders = getorders(a);
    n_mats = a_orders[1];
    r = a_orders[2];
    out = zeros(n_mats, r * (r + 1) / 2);
    
    for i(1, n_mats, 1);
        out[i,.] = vech(arraytomat(a[i,.,.]))';
    endfor;
    
    retp(out);
endp;

aptech

1,773


0



Yes this is how I have been doing it right now. Thanks.

Your Answer

2 Answers

0

There is no built-in procedure to perform the equivalent of vech on each sub-matrix of a multi-dimensional array. However, you could write a procedure to do it. Something like this would work:

proc (1) = avech(a);
    local a_orders, out, i, n_mats, r;
    
    //This assumes a 3-dimensional array
    //where the last two dimensions are the same
    a_orders = getorders(a);
    n_mats = a_orders[1];
    r = a_orders[2];
    out = zeros(n_mats, r * (r + 1) / 2);
    
    for i(1, n_mats, 1);
        out[i,.] = vech(arraytomat(a[i,.,.]))';
    endfor;
    
    retp(out);
endp;
0

Yes this is how I have been doing it right now. Thanks.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.