[Scipy-svn] r4415 - in trunk/scipy/sparse/linalg/eigen: arpack lobpcg lobpcg/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri Jun 6 02:54:48 EDT 2008
Author: wnbell
Date: 2008-06-06 01:54:44 -0500 (Fri, 06 Jun 2008)
New Revision: 4415
Modified:
trunk/scipy/sparse/linalg/eigen/arpack/arpack.py
trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
Log:
renamed lobpcg parameters to better conform to other iterative methods
Modified: trunk/scipy/sparse/linalg/eigen/arpack/arpack.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/arpack.py 2008-06-06 06:29:48 UTC (rev 4414)
+++ trunk/scipy/sparse/linalg/eigen/arpack/arpack.py 2008-06-06 06:54:44 UTC (rev 4415)
@@ -62,7 +62,7 @@
Parameters
----------
- A : A : matrix, array, or object with matvec(x) method
+ A : matrix, array, or object with matvec(x) method
An N x N matrix, array, or an object with matvec(x) method to perform
the matrix vector product A * x. The sparse matrix formats
in scipy.sparse are appropriate for A.
@@ -76,8 +76,8 @@
Array of k eigenvalues
v : array
- An array of k eigenvectors
- The v[i] is the eigenvector corresponding to the eigenvector w[i]
+ An array of k eigenvectors
+ The v[i] is the eigenvector corresponding to the eigenvector w[i]
Other Parameters
----------------
Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-06-06 06:29:48 UTC (rev 4414)
+++ trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-06-06 06:54:44 UTC (rev 4415)
@@ -17,6 +17,8 @@
from scipy.sparse.linalg import aslinearoperator, LinearOperator
+__all__ = ['lobpcg']
+
## try:
## from symeig import symeig
## except:
@@ -138,9 +140,9 @@
else:
return blockVectorV, blockVectorBV
-def lobpcg( blockVectorX, A,
- B = None, M = None, blockVectorY = None,
- residualTolerance = None, maxIterations = 20,
+def lobpcg( A, X,
+ B=None, M=None, Y=None,
+ tol= None, maxiter=20,
largest = True, verbosityLevel = 0,
retLambdaHistory = False, retResidualNormsHistory = False ):
"""Solve symmetric partial eigenproblems with optional preconditioning
@@ -148,23 +150,24 @@
This function implements the Locally Optimal Block Preconditioned
Conjugate Gradient Method (LOBPCG).
- TODO write in terms of Ax=lambda B x
-
+
Parameters
----------
- blockVectorX : array_like
- initial approximation to eigenvectors shape=(n,blockSize)
- A : {dense matrix, sparse matrix, LinearOperator}
- the linear operator of the problem, usually a sparse matrix
- often called the "stiffness matrix"
+ A : {sparse matrix, dense matrix, LinearOperator}
+ The symmetric linear operator of the problem, usually a
+ sparse matrix. Often called the "stiffness matrix".
+ X : array_like
+ Initial approximation to the k eigenvectors. If A has
+ shape=(n,n) then X should have shape shape=(n,k).
Returns
-------
- (lambda,blockVectorV) : tuple of arrays
- blockVectorX and lambda are computed blockSize eigenpairs, where
- blockSize=size(blockVectorX,2) for the initial guess blockVectorX
- if it is full rank.
+ w : array
+ Array of k eigenvalues
+ v : array
+ An array of k eigenvectors. V has the same shape as X.
+
Optional Parameters
-------------------
B : {dense matrix, sparse matrix, LinearOperator}
@@ -174,18 +177,19 @@
M : {dense matrix, sparse matrix, LinearOperator}
preconditioner to A; by default M = Identity
M should approximate the inverse of A
- blockVectorY : array_like
+ Y : array_like
n-by-sizeY matrix of constraints, sizeY < n
The iterations will be performed in the B-orthogonal complement
- of the column-space of blockVectorY. blockVectorY must be full rank.
+ of the column-space of Y. Y must be full rank.
Other Parameters
----------------
- residualTolerance : scalar
- solver tolerance. default: residualTolerance=n*sqrt(eps)
- maxIterations: integer
+ tol : scalar
+ Solver tolerance (stopping criterion)
+ by default: tol=n*sqrt(eps)
+ maxiter: integer
maximum number of iterations
- by default: maxIterations=min(n,20)
+ by default: maxiter=min(n,20)
largest : boolean
when True, solve for the largest eigenvalues, otherwise the smallest
verbosityLevel : integer
@@ -200,12 +204,17 @@
-----
If both retLambdaHistory and retResidualNormsHistory are True, the
return tuple has the following format:
- (lambda, blockVectorV, lambda history, residual norms history)
+ (lambda, V, lambda history, residual norms history)
"""
failureFlag = True
import scipy.linalg as sla
+ blockVectorX = X
+ blockVectorY = Y
+ residualTolerance = tol
+ maxIterations = maxiter
+
if blockVectorY is not None:
sizeY = blockVectorY.shape[1]
else:
@@ -213,11 +222,11 @@
# Block size.
if len(blockVectorX.shape) != 2:
- raise ValueError('expected rank-2 array for argument blockVectorX')
+ raise ValueError('expected rank-2 array for argument X')
n, sizeX = blockVectorX.shape
if sizeX > n:
- raise ValueError('blockVectorX column dimension exceeds the row dimension')
+ raise ValueError('X column dimension exceeds the row dimension')
A = makeOperator(A, (n,n))
B = makeOperator(B, (n,n))
Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-06-06 06:29:48 UTC (rev 4414)
+++ trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-06-06 06:54:44 UTC (rev 4415)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env pytho n
""" Test functions for the sparse.linalg.eigen.lobpcg module
"""
@@ -8,7 +8,7 @@
from scipy import array, arange, ones, sort, cos, pi, rand, \
set_printoptions, r_, diag, linalg
from scipy.linalg import eig
-from scipy.sparse.linalg.eigen import lobpcg
+from scipy.sparse.linalg.eigen.lobpcg import lobpcg
set_printoptions(precision=3,linewidth=90)
@@ -47,7 +47,7 @@
V = rand(n,m)
X = linalg.orth(V)
- eigs,vecs = lobpcg.lobpcg(X,A,B,residualTolerance=1e-5, maxIterations=30)
+ eigs,vecs = lobpcg(A, X, B=B, tol=1e-5, maxiter=30)
eigs.sort()
#w,v = symeig(A,B)
More information about the Scipy-svn
mailing list