gsl.Matrix

Module Contents

class gsl.Matrix.Matrix(shape, data=None, **kwds)

A wrapper over a gsl matrix

defaultFormat = +16.7
upperTriangular = 1
lowerTriangular = 0
unitDiagonal = 1
nonUnitDiagonal = 0
opNoTrans = 0
opTrans = 1
opConjTrans = 2
sideRight = 1
sideLeft = 0
sortValueAscending = 0
sortValueDescending = 1
sortMagnitudeAscending = 2
sortMagnitudeDescending = 3
data
shape = [0, 0]
excerpt(self, communicator=None, source=0, matrix=None)

Scatter {matrix} held by the task {source} among all tasks in {communicator} and fill me with the partition values. Only {source} has to provide a {matrix}; the other tasks can use the default value.

zero(self)

Set all my elements to zero

fill(self, value)

Set all my elements to {value}

view(self, start, shape)

Build a view to my data anchored at {start} with the given {shape}

load(self, filename, binary=None)

Read my values from {filename}

This method attempts to distinguish between text and binary representations of the data, based on the parameter {mode}, or the {filename} extension if {mode} is absent

save(self, filename, binary=None, format=defaultFormat)

Write my values to {filename}

This method attempts to distinguish between text and binary representations of the data, based on the parameter {mode}, or the {filename} extension if {mode} is absent

read(self, filename)

Read my values from {filename}

write(self, filename)

Write my values to {filename}

scanf(self, filename)

Read my values from {filename}

printf(self, filename, format=defaultFormat)

Write my values to {filename}

print(self, format='{:+13.4e}', indent='', interactive=True)

Print my values using the given {format}

identity(self)

Initialize me as an identity matrix: all elements are set to zero except along the diagonal, which are set to one

random(self, pdf)

Fill me with random numbers using the probability distribution {pdf}

clone(self)

Allocate a new matrix and initialize it using my values

copy(self, other)

Fill me with values from {other}, which is assumed to be of compatible shape

tuple(self)

Build a representation of my contents as a tuple of tuples

This is suitable for converting to other matrix representations, such as numpy

transpose(self, destination=None)

Compute the transpose of a matrix.

If {destination} is {None} and the matrix is square, the operation happens in-place. Otherwise, the transpose is stored in {destination}, which is assumed to be shaped correctly.

getRow(self, index)

Return a view to the requested row

getColumn(self, index)

Return a view to the requested column

setRow(self, index, v)

Set the row at {index} to the contents of the given vector {v}

setColumn(self, index, v)

Set the column at {index} to the contents of the given vector {v}

max(self)

Compute my maximum value

min(self)

Compute my maximum value

minmax(self)

Compute my minimum and maximum values

symmetricEigensystem(self, order=sortValueAscending)

Computed my eigenvalues and eigenvectors assuming i am a real symmetric matrix

mean(self, axis=None, out=None)

Compute the mean values of a matrix axis = None, 0, or 1, along which the mean are computed

mean_sd(self, axis=None, out=None, sample=True)

Compute the mean values of matrix axis: int or None

axis along which the means are computed. None for all elements
out: tuple of two vectors (mean, sd)
vector size is 1 (axis=None), columns(axis=0), rows(axis=1)
sample: True or False
when True, the sample standard deviation is computed 1/(N-1) when False, the population standard deviation is computed 1/N
std(self, axis=None, sample=False)

Compute the standard deviation of a matrix

ndarray(self, copy=False)

Return a numpy array reference (w/ shared data) if {copy} is False, or a new copy if {copy} is {True}

__iter__(self)

Iterate over all my elements in shape order

__contains__(self, value)
__getitem__(self, index)
__setitem__(self, index, value)
__eq__(self, other)
__ne__(self, other)
__iadd__(self, other)

In-place addition with the elements of {other}

__isub__(self, other)

In-place subtraction with the elements of {other}

__imul__(self, other)

In-place multiplication with the elements of {other}

__itruediv__(self, other)

In-place addition with the elements of {other}