To provide the most recent news and documentation www.pymvpa.org reflects the development 2.0 series (renamed 0.6 series) of PyMVPA. If you are interested in the documentation of the previous stable 0.4 series of PyMVPA, please visit v04.pymvpa.org.

mvpa2.clfs.gpr.NLAsolve

mvpa2.clfs.gpr.NLAsolve(a, b)

Solve a linear matrix equation, or system of linear scalar equations.

Computes the “exact” solution, x, of the well-determined, i.e., full rank, linear matrix equation ax = b.

Parameters :

a : array_like, shape (M, M)

Coefficient matrix.

b : array_like, shape (M,) or (M, N)

Ordinate or “dependent variable” values.

Returns :

x : ndarray, shape (M,) or (M, N) depending on b

Solution to the system a x = b

Raises :

LinAlgError :

If a is singular or not square.

Notes

solve is a wrapper for the LAPACK routines dgesv and zgesv, the former being used if a is real-valued, the latter if it is complex-valued. The solution to the system of linear equations is computed using an LU decomposition [2] with partial pivoting and row interchanges.

a must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent; if either is not true, use lstsq for the least-squares best “solution” of the system/equation.

References

[2]G. Strang, Linear Algebra and Its Applications, 2nd Ed., Orlando, FL, Academic Press, Inc., 1980, pg. 22.

Examples

Solve the system of equations 3 * x0 + x1 = 9 and x0 + 2 * x1 = 8:

>>> a = np.array([[3,1], [1,2]])
>>> b = np.array([9,8])
>>> x = np.linalg.solve(a, b)
>>> x
array([ 2.,  3.])

Check that the solution is correct:

>>> (np.dot(a, x) == b).all()
True

NeuroDebian

NITRC-listed