找回密码
 注册
查看: 629|回复: 0

R语言 spam包 spam solve()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 12:23:52 | 显示全部楼层 |阅读模式
spam solve(spam)
spam solve()所属R语言包:spam

                                        Linear Equation Solving for Sparse Matrices
                                         稀疏矩阵的线性方程组求解

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

backsolve and forwardsolve solve a system of linear equations where the coefficient matrix is upper or lower triangular. <br> solve solves a linear system or computes the inverse of a matrix if the right-hand-side is missing.
backsolve和forwardsolve求解线性方程组的系统,其中系数矩阵是上或下三角。参考solve解决线性系统或者如果右手侧缺少计算逆矩阵。


用法----------Usage----------


# solve(a, b, ...)
# solve.spam(a, b, ...)

## S3 method for class 'spam'
solve(a, b, ...)

# backsolve(r, x, ...)
backsolve.spam(r, x, ...)
# forwardsolve(l, x, ...)
forwardsolve.spam(l, x, ...)

chol2inv(x,...)



参数----------Arguments----------

参数:a
symmetric positive definite matrix of class spam or a Cholesky factor  as the result of a chol call.
对称正定矩阵类spam或Cholesky因子的chol调用的结果。


参数:l,r
object of class spam or spam.chol.method returned by the function chol.
类的对象spam或spam.chol.方法返回的功能chol。


参数:x,b
vector or regular matrix of right-hand-side(s) of a system of linear equations.
矢量或右手侧(s)的线性方程系统的正则矩阵。


参数:...
further arguments passed to or from other methods, see "Details" below.
进一步的参数传递给其他方法,请参见下面的“详细信息”。


Details

详细信息----------Details----------

We can solve A %*% x = b by first computing the Cholesky decomposition A =   t(R)%*%R), then solving t(R)%*%y = b for y, and finally solving R%*%x = y for x. solve combines chol, a Cholesky decomposition of a symmetric positive definite sparse matrix, with forwardsolve and then backsolve.<br>
我们可以解决A %*% x = b通过先计算Cholesky分解A =   t(R)%*%R),然后解决t(R)%*%y = by,并最终解决R%*%x = yx。 solve结合与cholforwardsolve的对称正定稀疏矩阵,Cholesky分解,然后backsolve。<BR>

In case a is from a chol, then solve is an efficient way to calculate backsolve(a, forwardsolve( t(a), b)).
a是从chol,那么solve是一种有效的方式来计算backsolve(a, forwardsolve( t(a), b))。

However, for a.spam and a.mat from a chol call wit a sparse and ordinary matrix,  note that forwardsolve( a.mat, b, transpose=T, upper.tri=T) is equivalent to forwardsolve( t(a.mat), b) and backsolve(a.spam, forwardsolve(a.spam, b, transpose=T, upper.tri=T)) yields the desired result. But backsolve(a.spam,forwardsolve(t(a.spam), resid)) is wrong because  t(a.spam) is a spam and not a spam.chol.NgPeyton object.
然而,a.spam和a.mat从chol调用机智的稀疏和普通的矩阵,请注意,forwardsolve( a.mat, b, transpose=T, upper.tri=T)等于forwardsolve( t(a.mat), b)和backsolve(a.spam, forwardsolve(a.spam, b, transpose=T, upper.tri=T))的,产生所需的结果。但backsolve(a.spam,forwardsolve(t(a.spam), resid))是错误的,因为t(a.spam)是spam,而不是一个spam.chol.NgPeyton对象。

forwardsolve and backsolve solve a system of linear equations where the coefficient matrix is lower (forwardsolve) or upper (backsolve) triangular.  Usually, the triangular matrix is result from a chol call and it is not required to transpose it for forwardsolve.  Note that arguments of the default methods k, upper.tri and transpose do not have any effects here.
forwardsolve和backsolve解决的线性方程系统的系数矩阵是低级(forwardsolve)或上部(backsolve)三角。一般,三角矩阵是从chol呼叫的结果,它不要求它移调forwardsolve。请注意参数的默认方法k,upper.tri和transpose:“没有任何影响。

Notice that it is more efficient to solve successively the linear equations (both triangular solves) than to implement these in the Fortran code.
注意,它是更有效的解决连续的线性方程组(两个三角形解决了),而不是实施这些Fortran代码。

If the right-hand-side in solve is missing it will compute the inverse of a matrix. For details about the specific Cholsesky decomposition, see chol.
如果右手侧solve缺少它会计算一个矩阵的逆。有关的具体Cholsesky分解的详细信息,请参阅chol。

Recall that the Cholesky factors are from ordered matrices.
回想一下,从有序矩阵的Cholesky因素。

chol2inv(x) is a faster way to solve(x).
chol2inv(x)是一个更快的方法solve(x)。


注意----------Note----------

There is intentionally no <acronym>S3</acronym> distinction between the classes
是故意不<acronym> S3 </首字母缩写类之间的区别


(作者)----------Author(s)----------


Reinhard Furrer, based on Ng and Peyton (1993) Fortran routines



参考文献----------References----------



参见----------See Also----------

det, chol and ordering.
det,chol和ordering。


实例----------Examples----------


# Generate multivariate form a covariance inverse:[生成多变量的协方差逆:]
# (usefull for GRMF)[(有用为GRMF)]
set.seed(13)
n &lt;- 25    # dimension[尺寸]
N &lt;- 1000  # sample size[样本量]
Sigmainv <- .25^abs(outer(1:n,1:n,"-"))
Sigmainv <- as.spam( Sigmainv, eps=1e-4)


Sigma &lt;- solve( Sigmainv)  # for verification [为验证]
iidsample <- array(rnorm(N*n),c(n,N))

mvsample <- backsolve( chol(Sigmainv), iidsample)
norm( var(t(mvsample)) - Sigma)

# compare with:[对比:]
mvsample <- backsolve( chol(as.matrix( Sigmainv)), iidsample, n)
   #### ,n as patch [###,n为补丁]
norm( var(t(mvsample)) - Sigma)



# 'solve' step by step:[“解决”一步一步:]
b <- rnorm( n)
R <- chol(Sigmainv)
norm( backsolve( R, forwardsolve( R, b))-
      solve( Sigmainv, b) )
norm( backsolve( R, forwardsolve( R, diag(n)))- Sigma )



转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-9 18:20 , Processed in 0.025927 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表