Hauptübersicht

Klasse Vector

Klasse Vector (mit arithmetischen Operatoren)
Vector(v) (v Liste oder Tupel)
Die Indizes der Elemente von Vector werden (wie in Python-Listen etc.) ab 0 gezählt. Beispiel:
Vector([1,2,3])

Basisklasse: list

Übersicht:

Konstruktor

Vector (n)

Klassenmethoden (statische Methoden)

MethodeBedeutung
fromFunction (n, fn, offset=0)Vector, dessen Elemente mit der Funktion fn berechnet werden
fromString (s)Vector aus String

Operatoren

OperatorBedeutung
x + y
x * y
~x
x * y Multiplikation if both operands are vektors sind: inner product, otherwise scalar multiplication (elementwise)
-x
str(x)
x - y

Objektmethoden

MethodeBedeutung
join (y)Verkettung mit dem Vektor w
norm ()Norm of the Vector v
operators ()Nur zur Dokumentation
transp ()calculates the transposed Matrix (column vektor)

Konstruktor

Vector

Konstruktor

Aufruf: Vector(n)


Klassenmethoden (statische Methoden)

fromFunction

Vector.fromFunction(n, fn, offset=0)

Aufruf: Vector.fromFunction(n, fn, offset=0)

Beschreibung:
Vector, dessen Elemente mit der Funktion fn berechnet werden
Rückgabewert: Vector([fn(i+offset) for i in range(n)])
Beispiel:
Vector.fromFunction(5, sqrt, 1) ergibt Vector([1.0, 1.414, 1.732, 2.0, 2.236])


fromString

Vector.fromString(s)

Aufruf: Vector.fromString(s)

Beschreibung:
Vector aus String
Elemente (auch rationale Zahlen) müssen im String durch Kommas getrennt werden.
Beispiel:
Vector.fromString("1, 2/3, 2")


Operatoren

x + y

operators + and += (Elementwise addition)

Aufruf: x + y

Beschreibung:


x * y

Aufruf: x * y


~x

Operator ~ (transposition)

Aufruf: ~x

Beschreibung:


x * y

Operators * and *=

Aufruf: x * y

Beschreibung:
Multiplikation if both operands are vektors sind: inner product, otherwise scalar multiplication (elementwise)


-x

unary oparator - (negative Vektor)

Aufruf: -x

Beschreibung:


str(x)

Object representation as string

Aufruf: str(x)

Beschreibung:


x - y

operators - and -= (elementwise subtraction)

Aufruf: x - y

Beschreibung:


Objektmethoden

join

v.join(w)

Aufruf: x.join(y)

Beschreibung:
Verkettung mit dem Vektor w


norm

v.norm()

Aufruf: x.norm()

Beschreibung:
Norm of the Vector v


operators

Vector.operators()

Aufruf: self.operators()

Beschreibung:
Nur zur Dokumentation
Die Klasse Vector erlaubt folgende Operatoren:

Op.FunktionBeispiele
+Elementweise Additiona + b; a += b
-Elementweise Subtraktiona - b; a -= b
*wenn beide Operanden Vektoren sind: Skalarprodukt, sonst Skalarmultiplikation (elementweise)a * b; a *= b
-unäres Minus-a
[ ]IndexoperatorA[i] (Element)
Diese Methode dient nur zur Dokumentation. Sie hat keine Wirkung.


transp

v.transp()

Aufruf: v.transp()

Beschreibung:
calculates the transposed Matrix (column vektor)
shorter: ~v