Skip to content

MultiVector Class API Reference

MultiVector is the core data type in geometric algebra, representing multivectors (linear combinations of scalars, vectors, bivectors, etc.).

Class Definition

class MultiVector:
    """
    Multivector class, representing multivector elements in geometric algebra.
    Can be a linear combination of scalars, vectors, bivectors, trivectors, etc.
    """

Constructor Methods

zeros(config)

Create a zero multivector.

@classmethod
def zeros(cls, config: AlgebraConfig) -> MultiVector

Parameters: config - Algebra configuration object

Returns: Zero-valued MultiVector


one(config)

Create the unit multivector (scalar 1).

@classmethod
def one(cls, config: AlgebraConfig) -> MultiVector

Returns: Unit scalar MultiVector


from_scalar(config, scalar)

Create a multivector from a scalar value.

@classmethod
def from_scalar(cls, config: AlgebraConfig, scalar: float) -> MultiVector

Parameters: - config - Algebra configuration - scalar - Scalar value

Returns: Scalar MultiVector

Example:

alg = nblade.Algebra.euclidean(3)
s = nblade.MultiVector.from_scalar(alg.config, 5.0)
# Or use the convenience method
s = alg.scalar(5.0)


basis_vector(config, i)

Create basis vector e_i.

@classmethod
def basis_vector(cls, config: AlgebraConfig, i: int) -> MultiVector

Parameters: - config - Algebra configuration - i - Basis vector index (0-based)

Returns: Basis vector MultiVector


from_coefficients(config, coefficients)

Create a multivector from a coefficient array.

@classmethod
def from_coefficients(cls, config: AlgebraConfig, coefficients: List[float]) -> MultiVector

Parameters: - config - Algebra configuration - coefficients - Coefficient array for all basis elements

Returns: MultiVector

Example:

# Coefficient order in 3D: [scalar, e1, e2, e3, e12, e13, e23, e123]
coeffs = [1.0, 2.0, 3.0, 4.0, 0.5, 0.0, 0.0, 0.1]
mv = nblade.MultiVector.from_coefficients(alg.config, coeffs)


from_numpy(config, array)

Create a multivector from a NumPy array.

@classmethod
def from_numpy(cls, config: AlgebraConfig, array: numpy.ndarray) -> MultiVector

Parameters: - config - Algebra configuration - array - NumPy array

Returns: MultiVector


Properties

config

@property
def config(self) -> AlgebraConfig

Returns the associated algebra configuration.


Basic Operations

Geometric Product geometric_product()

def geometric_product(self, other: MultiVector) -> MultiVector

Compute the geometric product with another multivector.

Operator: *

Example:

a = alg.vector([1, 0, 0])
b = alg.vector([0, 1, 0])

# Method call
product = a.geometric_product(b)

# Or use operator
product = a * b


Outer Product outer_product()

def outer_product(self, other: MultiVector) -> MultiVector

Compute the outer product (wedge product).

Operator: ^

Example:

a = alg.vector([1, 0, 0])
b = alg.vector([0, 1, 0])

wedge = a ^ b  # Bivector


Left Inner Product left_inner()

def left_inner(self, other: MultiVector) -> MultiVector

Compute the left inner product (left contraction).

Operator: |

Note: In non-Euclidean signatures (e.g., spacetime G(1,3,0)), (A | B).scalar_part() returns the Euclidean inner product. Use A.norm_squared() or (A * B).scalar_part() for the metric-respecting result.

Example:

a = alg.vector([1, 2, 3])
b = alg.vector([4, 5, 6])

inner = a | b  # Scalar


Right Inner Product right_inner()

def right_inner(self, other: MultiVector) -> MultiVector

Compute the right inner product (right contraction).

Example:

a = alg.vector([1, 2, 3])
b = alg.vector([4, 5, 6])

right = a.right_inner(b)


Grade Operations

grade(r)

Extract the r-grade part.

def grade(self, r: int) -> MultiVector

Parameters: r - Grade (0=scalar, 1=vector, 2=bivector, ...)

Returns: MultiVector of specified grade

Example:

# Mixed multivector
mv = alg.scalar(1.0) + e1 + (e1 ^ e2)

scalar = mv.grade(0)    # Scalar part
vector = mv.grade(1)    # Vector part
bivector = mv.grade(2)  # Bivector part


even_part()

Extract the even-grade part.

def even_part(self) -> MultiVector

Returns: Even-grade components (scalar + bivector + quadvector + ...)


odd_part()

Extract the odd-grade part.

def odd_part(self) -> MultiVector

Returns: Odd-grade components (vector + trivector + ...)


scalar_part()

Extract the scalar part.

def scalar_part(self) -> float

Returns: Scalar value

Example:

a = alg.vector([3, 4, 0])
b = alg.vector([3, 4, 0])

inner = a | b
print(inner.scalar_part())  # 25


coefficients()

Get coefficients for all basis elements.

def coefficients(self) -> numpy.ndarray

Returns: NumPy array of coefficients for all basis elements


Involution Operations

grade_involution()

Grade involution.

def grade_involution(self) -> MultiVector

Multiply r-grade elements by (-1)^r.

Operator: ~ (Note: In Python ~ is bitwise NOT, so use the method)

Example:

v = alg.vector([1, 2, 3])
involution = v.grade_involution()  # -v (vector is grade 1)


reversion()

Reversion.

def reversion(self) -> MultiVector

Multiply r-grade elements by (-1)^(r(r-1)/2).

Example:

v = alg.vector([1, 2, 3])
rev = v.reversion()  # v (vectors are unchanged)

B = e1 ^ e2
B_rev = B.reversion()  # -B (bivectors flip sign)


clifford_conjugate()

Clifford conjugate.

def clifford_conjugate(self) -> MultiVector

Equal to grade involution + reversion.

Example:

mv = alg.scalar(1) + e1 + (e1 ^ e2)
conj = mv.clifford_conjugate()


Dual Operations

dual()

Hodge dual.

def dual(self) -> MultiVector

Maps k-vectors to (n-k)-vectors.

Example:

v = alg.vector([1, 2, 3])
dual_v = v.dual()  # Bivector

# In 3D, the dual establishes the connection between cross product and outer product
# a × b = (a ∧ b).dual()


inverse_dual()

Inverse dual.

def inverse_dual(self) -> MultiVector

Example:

v = alg.vector([1, 2, 3])
original = v.dual().inverse_dual()  # Equals v


Norm and Inverse

norm()

Compute the norm.

def norm(self) -> float

Returns: |A| = sqrt(₀)

Example:

v = alg.vector([3, 4, 0])
print(v.norm())  # 5.0


norm_squared()

Compute the squared norm.

def norm_squared(self) -> float

Returns: |A|²


inverse()

Compute the multiplicative inverse.

def inverse(self) -> MultiVector

Returns: A⁻¹ such that A * A⁻¹ = 1

Exceptions: Raises exception if not invertible

Note: The formula A⁻¹ = rev(A)/|A|² is only valid for pure-grade multivectors (e.g., vectors, bivectors, trivectors). For mixed-grade elements like 1 + e1 + e2∧e3, the result may not be the true inverse.

Example:

v = alg.vector([1, 2, 3])
v_inv = v.inverse()

# Verify
product = v * v_inv
print(product.scalar_part())  # Approximately 1


is_invertible()

Check if invertible.

def is_invertible(self) -> bool

Geometric Operations

project_to(blade)

Project onto the subspace represented by a blade.

def project_to(self, blade: MultiVector) -> MultiVector

Parameters: blade - Blade representing the target subspace

Returns: Projected MultiVector

Example:

v = alg.vector([1, 2, 3])
e1 = alg.basis_vector(0)

proj = v.project_to(e1)  # Project onto x-axis
print(proj)  # e1


reject_from(blade)

Reject from the subspace represented by a blade.

def reject_from(self, blade: MultiVector) -> MultiVector

Returns: Orthogonal component

Example:

v = alg.vector([1, 2, 3])
e1 = alg.basis_vector(0)

reject = v.reject_from(e1)  # Component perpendicular to x-axis
# v = proj + reject


reflect_in(blade)

Reflect in the hyperplane represented by a blade.

def reflect_in(self, blade: MultiVector) -> MultiVector

Formula: v' = -n v n (where n is the normal vector)

Example:

v = alg.vector([1, 2, 3])
e1 = alg.basis_vector(0)

reflected = v.reflect_in(e1)  # Reflect in yz plane
# x component is negated


rotate_by(rotor)

Rotate using a rotor.

def rotate_by(self, rotor: MultiVector) -> MultiVector

Parameters: rotor - Rotation rotor

Returns: Rotated MultiVector

Formula: v' = R v R†

Example:

import math

alg = nblade.Algebra.euclidean(3)
e1, e2, e3 = alg.basis_vectors()

# Create rotor
plane = e1 ^ e2
rotor = alg.rotor(plane, math.pi / 4)

# Rotate
rotated = e1.rotate_by(rotor)


Other Operations

scale(factor)

Scalar multiplication.

def scale(self, factor: float) -> MultiVector

Parameters: factor - Scale factor

Returns: Scaled MultiVector


add(other)

Addition.

def add(self, other: MultiVector) -> MultiVector

Operator: +


commutator(other)

Commutator [A, B] = (AB - BA) / 2.

def commutator(self, other: MultiVector) -> MultiVector

scalar_product(other)

Scalar product ₀.

def scalar_product(self, other: MultiVector) -> float

get_coefficient(index)

Get a single coefficient at the given basis blade index.

def get_coefficient(self, index: int) -> float

Parameters: index - Basis blade index (0 for scalar, 1 for e1, 3 for e1∧e2, etc.)

Returns: Coefficient value

Example:

v = alg.vector([1, 2, 3])
print(v.get_coefficient(1))  # 1.0 (e1 coefficient)
print(v.get_coefficient(3))  # 0.0 (no e1∧e2 component)


is_zero()

Check if zero.

def is_zero(self) -> bool

__eq__() / __ne__()

Equality comparison. Two multivectors are equal if their difference is zero.

def __eq__(self, other: object) -> bool
def __ne__(self, other: object) -> bool

Operator: ==, !=

Example:

a = alg.vector([1, 2, 3])
b = alg.vector([1, 2, 3])
assert a == b


Operator Overloads

Operator Method Description
a + b add Addition
a - b __sub__ Subtraction
a * b geometric_product Geometric product
a ^ b outer_product Outer product
a \| b left_inner Left inner product
-a __neg__ Negation
~a grade_involution Grade involution
a == b __eq__ Equality check
a != b __ne__ Inequality check

Complete Example

import nblade
import math

# Create algebra
alg = nblade.Algebra.euclidean(3)
e1, e2, e3 = alg.basis_vectors()

# Create vectors
v = alg.vector([1.0, 2.0, 3.0])
w = alg.vector([4.0, 5.0, 6.0])

# Basic operations
print("Geometric product:", v * w)
print("Outer product:", v ^ w)
print("Inner product:", v | w)

# Grade operations
mixed = alg.scalar(1.0) + v + (e1 ^ e2)
print("Scalar part:", mixed.grade(0))
print("Vector part:", mixed.grade(1))

# Rotation
rotor = alg.rotor(e1 ^ e2, math.pi / 4)
rotated = v.rotate_by(rotor)
print("Rotated:", rotated)

# Norm and inverse
print("Norm:", v.norm())
print("Inverse:", v.inverse())

# Projection and rejection
proj = v.project_to(e1)
reject = v.reject_from(e1)
print("Projection:", proj)
print("Rejection:", reject)