与给定向量形成正交基的矩阵

发布于 2024-09-07 15:05:11 字数 171 浏览 1 评论 0原文

一道线性代数题;

给定一个 k 变量标准化向量 u (即 u : ||u||_2=1) 如何构造 \Gamma_u,任意 k*(k-1) 单位向量矩阵,使得 (u,\Gamma_u) 形成 正交基 ?

我的意思是:从计算的角度来看: 你用什么算法来构造这样的矩阵?

提前致谢,

A linear algebra question;

Given a k-variate normed vector u (i.e. u : ||u||_2=1)
how do you construct \Gamma_u, any arbitrary k*(k-1)
matrix of unit vectors such that (u,\Gamma_u) forms an
orthogonal basis ?

I mean: from a computationnal stand point of view:
what algorithm do you use to construct such matrices ?

Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新雨望断虹 2024-09-14 15:05:11

最简单的方法是应用 u_0 和 k-1 随机生成向量的 Gram Schmidt 正交化。如果在某个时刻 GS 算法生成零向量,则存在线性相关性,在这种情况下再次随机选择向量。

然而,这种方法不稳定,矢量表示中的微小数值误差会被放大。然而,该算法存在一个稳定的修改:

a_1 = u, a_2,...a_k 为随机选择的向量,

for i = 1 to k do 
        vi = ai
end for 

for i = 1 to k do
    rii = |vi| 
    qi = vi/rii
    for j = i + 1 to k do
       rij =<qi,vj>
       vj =vj −rij*qi 
    end for
end for

所得向量 v1,...vk 将是矩阵的列,其中 v1 = u。如果在某个时刻vj变为零,请选择一个新的向量aj并重新开始。请注意,如果随机选择向量 a2,...,ak,发生这种情况的概率可以忽略不计。

The naive approach would be to apply Gram Schmidt orthogonalisation of u_0, and k-1 randomly generated vectors. If at some point the GS algorithm generates a zero vector, then you have a linear dependency in which case choose the vector randomly again.

However this method is unstable, small numerical errors in the representation of the vectors gets magnified. However there exists a stable modification of this algorithm:

Let a_1 = u, a_2,...a_k be randomly chosen vectors

for i = 1 to k do 
        vi = ai
end for 

for i = 1 to k do
    rii = |vi| 
    qi = vi/rii
    for j = i + 1 to k do
       rij =<qi,vj>
       vj =vj −rij*qi 
    end for
end for

The resulting vectors v1,...vk will be the columns of your matrix, with v1 = u. If at some point vj becomes zero choose a new vector aj and start again. Note that the probability of this happening is negligible if the vectors a2,..,ak are chosen randomly.

愿得七秒忆 2024-09-14 15:05:11

您可以使用 Householder 矩阵来执行此操作。参见
示例 http://en.wikipedia.org/wiki/Householder_reflection
http://en.wikipedia.org/wiki/QR_decomposition

人们可以找到一个 Householder 矩阵Q 使得 Q*u = e_1
(其中 e_k 是除了第 k 个位置上的 1 之外全为 0 的向量)
那么如果f_k = Q*e_k,则f_k形成正交基并且f_1 = u
(因为 Q*Q = I,并且 Q 是正交的。)

所有这些关于矩阵的讨论可能会让例程看起来像是
会很昂贵,但事实并非如此。例如这个 C 函数,
给定长度为 1 的向量,返回具有所需基数的数组
按列顺序,即第 i 个向量的第 j 个分量保存在 b[j+dim*i] 中

   double*  make_basis( int dim, const double* v)
{
    double* B = calloc( dim*dim, sizeof * B);
    double* h = calloc( dim, sizeof *h);
    double  f, s, d;
    int i, j;

    /* compute Householder vector and factor */
    memcpy( h, v, dim*sizeof *h);
    s = ( v[0] > 0.0) ? 1.0 : -1.0;
    h[0] += s;  
    f = s/(s+v[0]);

    /* compute basis */
    memcpy( B, v, dim * sizeof *v); /* first one is v */
    /* others by applying Householder matrix */
    for( i=1; i<dim; ++i)
    {   d = f*h[i];
        for( j=0; j<dim; ++j)
        {   B[dim*i+j] = (i==j) - d*h[j];
        }
    }
    free( h);
    return B;
}

You can use Householder matrices to do this. See for
example http://en.wikipedia.org/wiki/Householder_reflection
and http://en.wikipedia.org/wiki/QR_decomposition

One can find a Householder matrix Q so that Q*u = e_1
(where e_k is the vector that's all 0s apart from a 1 in the k-th place)
Then if f_k = Q*e_k, the f_k form an orthogonal basis and f_1 = u.
(Since Q*Q = I, and Q is orthogonal.)

All this talk of matrices might make it seem that the routine
would be expensive, but this is not so. For example this C function,
given a vector of length 1 returns an array with the required basis
in column order, ie the j'th component of the i'th vector is held in b[j+dim*i]

   double*  make_basis( int dim, const double* v)
{
    double* B = calloc( dim*dim, sizeof * B);
    double* h = calloc( dim, sizeof *h);
    double  f, s, d;
    int i, j;

    /* compute Householder vector and factor */
    memcpy( h, v, dim*sizeof *h);
    s = ( v[0] > 0.0) ? 1.0 : -1.0;
    h[0] += s;  
    f = s/(s+v[0]);

    /* compute basis */
    memcpy( B, v, dim * sizeof *v); /* first one is v */
    /* others by applying Householder matrix */
    for( i=1; i<dim; ++i)
    {   d = f*h[i];
        for( j=0; j<dim; ++j)
        {   B[dim*i+j] = (i==j) - d*h[j];
        }
    }
    free( h);
    return B;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文