Skip to content

Class swarmauri_core.norms.IUseInnerProduct.IUseInnerProduct

swarmauri_core.norms.IUseInnerProduct.IUseInnerProduct

Bases: ABC

Abstract interface marking components using inner product geometry.

This interface indicates dependency on inner product structure and defines methods for operations that rely on inner product geometry, such as computing angles between vectors, verifying orthogonality, projection, and validating the parallelogram law.

get_inner_product abstractmethod

get_inner_product()

Get the inner product implementation used by this component.

Returns

IInnerProduct The inner product implementation

Source code in swarmauri_core/norms/IUseInnerProduct.py
23
24
25
26
27
28
29
30
31
32
33
@abstractmethod
def get_inner_product(self) -> Literal[IInnerProduct]:
    """
    Get the inner product implementation used by this component.

    Returns
    -------
    IInnerProduct
        The inner product implementation
    """
    pass

check_angle_between_vectors abstractmethod

check_angle_between_vectors(v1, v2)

Calculate the angle between two vectors using the inner product.

Parameters

v1 : Vector First vector v2 : Vector Second vector

Returns

float Angle between vectors in radians

Source code in swarmauri_core/norms/IUseInnerProduct.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@abstractmethod
def check_angle_between_vectors(self, v1: Vector, v2: Vector) -> float:
    """
    Calculate the angle between two vectors using the inner product.

    Parameters
    ----------
    v1 : Vector
        First vector
    v2 : Vector
        Second vector

    Returns
    -------
    float
        Angle between vectors in radians
    """
    pass

check_orthogonality abstractmethod

check_orthogonality(v1, v2, tolerance=1e-10)

Verify if two vectors are orthogonal to each other.

Parameters

v1 : Vector First vector v2 : Vector Second vector tolerance : float, optional Numerical tolerance for zero comparison, by default 1e-10

Returns

bool True if vectors are orthogonal, False otherwise

Source code in swarmauri_core/norms/IUseInnerProduct.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@abstractmethod
def check_orthogonality(
    self, v1: Vector, v2: Vector, tolerance: float = 1e-10
) -> bool:
    """
    Verify if two vectors are orthogonal to each other.

    Parameters
    ----------
    v1 : Vector
        First vector
    v2 : Vector
        Second vector
    tolerance : float, optional
        Numerical tolerance for zero comparison, by default 1e-10

    Returns
    -------
    bool
        True if vectors are orthogonal, False otherwise
    """
    pass

check_xy_projection abstractmethod

check_xy_projection(v, basis_x, basis_y)

Project a vector onto the plane defined by two basis vectors.

Parameters

v : Vector Vector to project basis_x : Vector First basis vector (x-axis) basis_y : Vector Second basis vector (y-axis)

Returns

tuple[float, float] The (x, y) coordinates of the projection

Source code in swarmauri_core/norms/IUseInnerProduct.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@abstractmethod
def check_xy_projection(
    self, v: Vector, basis_x: Vector, basis_y: Vector
) -> tuple[float, float]:
    """
    Project a vector onto the plane defined by two basis vectors.

    Parameters
    ----------
    v : Vector
        Vector to project
    basis_x : Vector
        First basis vector (x-axis)
    basis_y : Vector
        Second basis vector (y-axis)

    Returns
    -------
    tuple[float, float]
        The (x, y) coordinates of the projection
    """
    pass

check_parallelogram_law abstractmethod

check_parallelogram_law(v1, v2, tolerance=1e-10)

Verify if the parallelogram law holds for two vectors: ||v1 + v2||² + ||v1 - v2||² = 2(||v1||² + ||v2||²)

Parameters

v1 : Vector First vector v2 : Vector Second vector tolerance : float, optional Numerical tolerance for comparison, by default 1e-10

Returns

bool True if the parallelogram law holds, False otherwise

Source code in swarmauri_core/norms/IUseInnerProduct.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@abstractmethod
def check_parallelogram_law(
    self, v1: Vector, v2: Vector, tolerance: float = 1e-10
) -> bool:
    """
    Verify if the parallelogram law holds for two vectors:
    ||v1 + v2||² + ||v1 - v2||² = 2(||v1||² + ||v2||²)

    Parameters
    ----------
    v1 : Vector
        First vector
    v2 : Vector
        Second vector
    tolerance : float, optional
        Numerical tolerance for comparison, by default 1e-10

    Returns
    -------
    bool
        True if the parallelogram law holds, False otherwise
    """
    pass