Hi,
let me start a new thread here. First a reminder to everybody that
the 'extra.gfn' package is now an add-on so that the code base lives
in git.
I propose the following updates / changes, and wanted to mention
them here first:
1) Add the 'powerset' function as discussed in the other thread.
Please speak up especially if you think another name would be
better, because changing it later is difficult.
2) There's a little bug in the 'commute' function I think, or at
least in the documentation related to non-square matrices.
[commute(vec(B), rows(B)) without the other integer argument will
fail if B is not square.] So I want to clarify the help text and add
an input error check to the function.
3) Want to add an 'eliminate' function as a sister of 'commute',
which returns the result of pre-multiplying with the elimination
matrix. Haven't looked at whether post-multiplication would be
wanted as well. Here's my code:
<hansl>
function matrix eliminate(const matrix vecA)
# The input vecA is assumed to come from the
# operation vec(A) on a square matrix, thus
# rows(vecA) must be a square number.
# Returns vech(A), which is the result of pre-
# multiplying vec(A) with the "elimination"
# matrix L_m.
if cols(vecA) != 1
funcerr "input must be a column vector"
endif
sqr = sqrt(rows(vecA)
if sqr != round(sqr)
funcerr "input must have a square number of elements"
endif
return vech(mshape(vecA, sqr, sqr))
end function
</hansl>
4) Add a remark to the help text that (pre-)multiplication with the
duplication matrix is as simple as doing:
vec(unvech(vechA))
where vechA is supposed to come from vech(A). The relevant input
checks come for free from the unvech() function, hence no new
function.
Comments and also suggestions for other new functions are welcome.
Thanks,
sven