ただのメモ

  • d_1次元空間\Omegaに次のような線形なd_2次元亜空間Sがある
    • Sは、あるS上の点Pを通り、d_2個の線形独立なベクトルQ_i;i=1,2,...,d_2によって張られている
  • \Omega上にあって、Sの外の点をAとし、そのSへの垂線の足をBとする
  • ここでP=(p_t),Q_i=(q_{i,t}),A=(a_t),B=(b_t); t=1,2,...d_1とする
  • 今、BはS上の点であるから、B=P+\sum_{i=1}^{d_2} x_i Q_i、ただしx=(x_u);u=1,2,...,d_2と表せる
  • また、ABはSに垂直であるから\forall i,(A-B) \perp Q_i
  • 別の書き方をすれば、M(A-B)=0
    • ただしM=\begin{pmatrix} Q_1\\ Q_2\\ ...\\Q_{d_2} \end{pmatrix}
  • このMを使うと
    • B=P+M^tx
  • M(A-B)=M(A-P-M^tx)=MA-MP-MM^tx=0
  • M(A-P)=MM^tx
  • (MM^t)^{-1}M(A-P)=x
d1<-5
d2<-2
M<-matrix(rnorm(d2*d1),nrow=d2)
P<-rnorm(d1)
A<-rnorm(d1)
x<-solve(M%*%t(M))%*%M%*%(A-P)
#x<-solve(t(M))%*%(A-P)
B<-P+t(M)%*%x
# たしかに垂直
M%*%(A-B)
B
> d1<-5
> d2<-2
> M<-matrix(rnorm(d2*d1),nrow=d2)
> P<-rnorm(d1)
> A<-rnorm(d1)
> 
> x<-solve(M%*%t(M))%*%M%*%(A-P)
> B<-P+t(M)%*%x
> M%*%(A-B)
              [,1]
[1,] -2.363900e-17
[2,]  3.838076e-16
> B
           [,1]
[1,] -0.2219434
[2,]  0.9811735
[3,]  0.4207855
[4,] -1.3255867
[5,]  0.9538941
  • 関数化
# VはNxM行列
# Mは次元
# Nはベクトルの本数
# Aは亜空間外の1点、もしくは、数点の列ベクトルを並べた行列
# Pは亜空間上の1点
PerpFoot<-function(V,A,P=NULL){
	if(is.null(P))P<-rep(0,length(A))
	
	x<-solve(V%*%t(V))%*%V%*%(A-P)
	B<-P+t(V)%*%x
	return(list(X=B,k=x))
}