FgMatrixV<T>
fgConcatVert(
    const FgMatrixV<T> &    upper,
    const FgMatrixV<T> &    lower)
{
    if (upper.empty())
        return lower;
    if (lower.empty())
        return upper;
    FGASSERT(upper.numCols() == lower.numCols());
    FgMatrixV<T>      ret(upper.numRows()+lower.numRows(),upper.numCols());
    for (uint ii=0; ii<upper.numElems(); ++ii)
        ret[ii] = upper[ii];
    uint    off = upper.numElems();
    for (uint ii=0; ii<lower.numElems(); ++ii)
        ret[off+ii] = lower[ii];
    return ret;
}
FgMatrixV<T>
fgModulateCols(
    const FgMatrixV<T> &    matrix,
    const FgMatrixV<T> &    modVector)
{
    FGASSERT(matrix.numCols() == modVector.numElems());
    FgMatrixD       ret = matrix;
    for (uint rr=0; rr<matrix.numRows(); ++rr)
        for (uint cc=0; cc<matrix.numCols(); ++cc)
            ret.elem(rr,cc) *= modVector[cc];
    return ret;
}