jmath.linearalgebra package

Submodules

jmath.linearalgebra.lines module

Line defined by vectors and point.

class jmath.linearalgebra.lines.Line(point, vector)

Bases: object

Defines a line from direction and point vectors.

Parameters
  • point (jmath.linearalgebra.lines.Point) – Position vector for line.

  • vector (jmath.linearalgebra.lines.Vector) – Direction vector for line.

jmath.linearalgebra.planes module

Plane defined by vectors and point.

class jmath.linearalgebra.planes.Plane(point, vector1, vector2)

Bases: object

Defines a plane

Parameters
  • point (jmath.linearalgebra.planes.Point) – Point on the plane.

  • vector1 (jmath.linearalgebra.planes.Vector) – Direction vector.

  • vector2 (jmath.linearalgebra.planes.Vector) – Direction vector.

Raises

VectorsNotSameSize – If the vectors are not the same size this error will be raised.

jmath.linearalgebra.vectors module

Vector Objects

class jmath.linearalgebra.vectors.Point(*components)

Bases: jmath.linearalgebra.vectors.Vector

Points based on vector framework. Can be thought of as a vector from origin.

Parameters

components (List[float]) – Coordinates in n-space

on_line(line)

Determines whether a point is on a line, returns bool.

Parameters

line (jmath.linearalgebra.lines.Line) – Line to determine if on

Return type

bool

class jmath.linearalgebra.vectors.Vector(*components)

Bases: object

n-dimensional Vectors

Parameters

components (List[float]) – Scalar vector components

Examples

>>> Vector(3, 2, 1) + Vector(2, 1, 1)
Vector(5, 3, 2)
>>> Vector(3, 1, 0) - Vector(9, 8, 8)
Vector(-6, -7, -8)
>>> 3 * Vector(1, 2, -4)
Vector(3, 6, -12)
>>> Vector(3, 6, 9)/3
Vector(1, 2, 3)
>>> Vector(10, 2, 1) @ Vector(1, 2, 3)
17
>>> Vector(1, 1).magnitude()
2
angle_between(vector)

Determines the angle (in radians) between two vectors to 5 d.p.

Parameters

vector (jmath.linearalgebra.vectors.Vector) – Vector or line to calculate angle between.

Raises

VectorsNotSameSize – If the vectors are not the same size this error will be raised.

Return type

float

d(*wrt)

Differentiate short hand.

Return type

jmath.linearalgebra.vectors.Vector

differentiate(*wrt)

Differentiate functions in vector with respect to a variable.

Parameters

wrt – The variables to differentiate with respect to.

Return type

jmath.linearalgebra.vectors.Vector

magnitude()

Calculates the vector magnitude.

Return type

float

negative()

Returns a vector of the same magnitude pointing in the opposite direction.

Return type

jmath.linearalgebra.vectors.Vector

projection(vector)

Returns projection of current vector onto the passed vector or line.

Parameters

vector (Union[jmath.linearalgebra.vectors.Vector, jmath.linearalgebra.lines.Line, jmath.linearalgebra.planes.Plane]) – Vector or line to calculate the projection onto.

Raises

VectorsNotSameSize – If the vectors are not the same size this error will be raised.

Return type

jmath.linearalgebra.vectors.Vector

unit()

Returns a unit vector in the same direction as the vector.

Return type

jmath.linearalgebra.vectors.Vector

Module contents

Linear Algebra Tools

Default Packages