Package wiat :: Package MM :: Module Functions
[hide private]
[frames] | no frames]

Module Functions

source code

Functions.py - Utility functions for the multimodal solver.

In order to solve a complex matricial system of ordinary differential equations, it must be convert to a real system of equation. Two functions are used to convert back and forth from the matrix notation to the vectorial form: flat2matrix and matrix2flat.

Functions [hide private]
 
flat2matrix(flat_matrix, N)
Convert a flat vector (obtained with matrix2flat) to a matrix of complex numbers
source code
 
matrix2flat(matrix)
Transform a matrix of complex numbers in a vector of real number consisting of a flatten version of the original.
source code
Function Details [hide private]

flat2matrix(flat_matrix, N)

source code 

Convert a flat vector (obtained with matrix2flat) to a matrix of complex numbers

Parameters:
  • flat_matrix - a flat vector representation of a matrix
  • N - the size of the square matrix

matrix2flat(matrix)

source code 

Transform a matrix of complex numbers in a vector of real number consisting of a flatten version of the original.

Example

>>> import numpy
>>> import wiat
>>> mat = numpy.array([[complex(1.,1.), complex(2.,2.)],
...                    [complex(3.,3.), complex(4.,4.)]])
>>> fmat = wiat.MM.Functions.matrix2flat(mat)
>>> print mat
[[ 1.+1.j  2.+2.j]
 [ 3.+3.j  4.+4.j]]
>>> print fmat
[ 1.  2.  3.  4.  1.  2.  3.  4.]