Package pod :: Module util
[frames] | no frames]

Module util

source code

Operations on matrices and various tools.


Author: Christophe Alexandre <ch.alexandre at bluewin dot ch>

License: Copyright(C) 2010 Christophe Alexandre

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.

Classes
  NullHandler
Null logging in order to avoid warning messages in client applications.
Functions
 
numbering(v)
Maps every element of to its position.
source code
 
prod_scalar(v1, v2) source code
 
norm(v) source code
 
gauss_jordan(m, eps=1e-10)
Puts given matrix (2D array) into the Reduced Row Echelon Form.
source code
 
system_solve(M, b)
solves M*x = b
source code
 
mat_inverse(M)
Returns: the inverse of the matrix M
source code
 
zeros(size, zero=0)
Returns: matrix of dimension size
source code
Function Details

gauss_jordan(m, eps=1e-10)

source code 

Puts given matrix (2D array) into the Reduced Row Echelon Form.

NOTE: make sure all the matrix items support fractions! Int matrix will NOT work! Written by Jarno Elonen in April 2005, released into Public Domain

Returns:
True if successful, False if 'm' is singular.

system_solve(M, b)

source code 

solves M*x = b

Parameters:
  • M - a matrix in the form of a list of list
  • b - a vector in the form of a simple list of scalars
Returns:
vector x so that M*x = b

mat_inverse(M)

source code 
Returns:
the inverse of the matrix M

zeros(size, zero=0)

source code 
Parameters:
  • size - a tuple containing dimensions of the matrix
  • zero - the value to use to fill the matrix (zero by default)
Returns:
matrix of dimension size