gsl.Vector

Module Contents

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

A wrapper over a gsl vector

defaultFormat = +16.7
data
excerpt(self, communicator=None, source=0, vector=None)

Scatter {vector} held by the task {source} among all tasks in {communicator} and fill me with the partition values. Only {source} has to provide a {vector}; 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}

basis(self, index)

Initialize me as a basis vector: all elements are set to zero except {index}, which is set to one

random(self, pdf)

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

clone(self)

Allocate a new vector 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

view(self, start, shape)

Build a view of my from {start} to {start+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}

max(self)

Compute my maximum value

min(self)

Compute my maximum value

minmax(self)

Compute my minimum and maximum values

sort(self)

In-place sort of the elements of a vector

sortIndirect(self)

Construct the permutation that would sort me in ascending order

shuffle(self, rng)

Shuffle the elements :param rng: gsl.rng handle :return: self

mean(self, weights=None)

Compute the mean value of my elements, weighted by the optional {weights}

median(self)

Compute the median value of my elements; only works on previously sorted vectors

variance(self, mean=None)

Compute the variance of my elements with respect to {mean}. If {mean} is {None}, it is computed on the fly

sdev(self, mean=None)

Compute the mean value of my elements with respect to {mean}. If {mean} is {None}, it is computed on the fly

ndarray(self, copy=False)

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

__len__(self)
__iter__(self)
__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}

_slice(self, index)

Build a generator that yields the values described in the {index}