Main Overview

Class Vector

Class Vector (with arithmetic operators)
Vector(v) (v Liste or Tuple)
The Indices of the elements of Vector are counted from 0 (as in Python lists etc.). Example:
Vector([1,2,3])

Base Class: list

Overview:

Constructor

Vector (n)

Class methods (static methods)

MethodMeaning
fromFunction (n, fn, offset=0)Vector, the elements of which are to be calculated using the function fn
fromString (s)Vector from String

Operators

OperatorMeaning
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

Object Methods

MethodMeaning
join (y)Concatenation with Vector w
norm ()Norm des Vektors v
operators ()For documentation only
transp ()berechnet die transponierte Matrix (Spaltenvektor)

Constructor

Vector

Constructor

Usage: Vector(n)


Class methods (static methods)

fromFunction

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

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

Description:
Vector, the elements of which are to be calculated using the function fn
Returns: Vector([fn(i+offset) for i in range(n)])
Example:
Vector.fromFunction(5, sqrt, 1) returns Vector([1.0, 1.414, 1.732, 2.0, 2.236])


fromString

Vector.fromString(s)

Usage: Vector.fromString(s)

Description:
Vector from String
Elements (may also bbe Rationals) must be given as comma separated string.
Example:
Vector.fromString("1, 2/3, 2")


Operators

x + y

operators + and += (Elementwise addition)

Usage: x + y

Description:


x * y

Usage: x * y


~x

Operator ~ (transposition)

Usage: ~x

Description:


x * y

Operators * and *=

Usage: x * y

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


-x

unary oparator - (negative Vektor)

Usage: -x

Description:


str(x)

Object representation as string

Usage: str(x)

Description:


x - y

operators - and -= (elementwise subtraction)

Usage: x - y

Description:


Object Methods

join

v.join(w)

Usage: x.join(y)

Description:
Concatenation with Vector w


norm

v.norm()

Usage: x.norm()

Description:
Norm des Vektors v


operators

Vector.operators()

Usage: self.operators()

Description:
For documentation only
The following operators are defined in the class Vector:

Op.FunctionExamples
+elementwise Additiona + b; a += b
-elementwise Subtractiona - b; a -= b
*if both operators are Vectors: inner product, otherwise: scalar multiplication (elementwise)a * b; a *= b
-Unary minus-a
[ ]Index operatorA[i] (Element)
This method is for documentation only. It has no effect.


transp

v.transp()

Usage: v.transp()

Description:
berechnet die transponierte Matrix (Spaltenvektor)
kürzer: ~v