Skip to content

Class swarmauri_core.inner_products.IInnerProduct.IInnerProduct

swarmauri_core.inner_products.IInnerProduct.IInnerProduct

Bases: ABC

Interface defining the contract for inner product operations.

This interface requires implementation of methods to compute inner products between vectors, matrices, or callables, as well as methods to verify mathematical properties of the inner product such as conjugate symmetry, linearity, and positivity.

compute abstractmethod

compute(a, b)

Compute the inner product between two objects.

Parameters

a : Union[Vector, Matrix, Callable] The first object for inner product calculation b : Union[Vector, Matrix, Callable] The second object for inner product calculation

Returns

float The inner product value

Source code in swarmauri_core/inner_products/IInnerProduct.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@abstractmethod
def compute(
    self, a: Union[Vector, Matrix, Callable], b: Union[Vector, Matrix, Callable]
) -> float:
    """
    Compute the inner product between two objects.

    Parameters
    ----------
    a : Union[Vector, Matrix, Callable]
        The first object for inner product calculation
    b : Union[Vector, Matrix, Callable]
        The second object for inner product calculation

    Returns
    -------
    float
        The inner product value
    """
    pass

check_conjugate_symmetry abstractmethod

check_conjugate_symmetry(a, b)

Check if the inner product satisfies the conjugate symmetry property: = * (complex conjugate).

Parameters

a : Union[Vector, Matrix, Callable] The first object b : Union[Vector, Matrix, Callable] The second object

Returns

bool True if conjugate symmetry holds, False otherwise

Source code in swarmauri_core/inner_products/IInnerProduct.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@abstractmethod
def check_conjugate_symmetry(
    self, a: Union[Vector, Matrix, Callable], b: Union[Vector, Matrix, Callable]
) -> bool:
    """
    Check if the inner product satisfies the conjugate symmetry property:
    <a, b> = <b, a>* (complex conjugate).

    Parameters
    ----------
    a : Union[Vector, Matrix, Callable]
        The first object
    b : Union[Vector, Matrix, Callable]
        The second object

    Returns
    -------
    bool
        True if conjugate symmetry holds, False otherwise
    """
    pass

check_linearity_first_argument abstractmethod

check_linearity_first_argument(a1, a2, b, alpha, beta)

Check if the inner product satisfies linearity in the first argument: = alpha + beta.

Parameters

a1 : Union[Vector, Matrix, Callable] First component of the first argument a2 : Union[Vector, Matrix, Callable] Second component of the first argument b : Union[Vector, Matrix, Callable] The second object alpha : float Scalar multiplier for a1 beta : float Scalar multiplier for a2

Returns

bool True if linearity in the first argument holds, False otherwise

Source code in swarmauri_core/inner_products/IInnerProduct.py
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@abstractmethod
def check_linearity_first_argument(
    self,
    a1: Union[Vector, Matrix, Callable],
    a2: Union[Vector, Matrix, Callable],
    b: Union[Vector, Matrix, Callable],
    alpha: float,
    beta: float,
) -> bool:
    """
    Check if the inner product satisfies linearity in the first argument:
    <alpha*a1 + beta*a2, b> = alpha*<a1, b> + beta*<a2, b>.

    Parameters
    ----------
    a1 : Union[Vector, Matrix, Callable]
        First component of the first argument
    a2 : Union[Vector, Matrix, Callable]
        Second component of the first argument
    b : Union[Vector, Matrix, Callable]
        The second object
    alpha : float
        Scalar multiplier for a1
    beta : float
        Scalar multiplier for a2

    Returns
    -------
    bool
        True if linearity in the first argument holds, False otherwise
    """
    pass

check_positivity abstractmethod

check_positivity(a)

Check if the inner product satisfies the positivity property: >= 0 and = 0 iff a = 0.

Parameters

a : Union[Vector, Matrix, Callable] The object to check positivity for

Returns

bool True if positivity holds, False otherwise

Source code in swarmauri_core/inner_products/IInnerProduct.py
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@abstractmethod
def check_positivity(self, a: Union[Vector, Matrix, Callable]) -> bool:
    """
    Check if the inner product satisfies the positivity property:
    <a, a> >= 0 and <a, a> = 0 iff a = 0.

    Parameters
    ----------
    a : Union[Vector, Matrix, Callable]
        The object to check positivity for

    Returns
    -------
    bool
        True if positivity holds, False otherwise
    """
    pass