Skip to content

Class swarmauri_core.seminorms.ISeminorm.ISeminorm

swarmauri_core.seminorms.ISeminorm.ISeminorm

Bases: ABC

Interface for seminorm structure.

A seminorm is a function that assigns a non-negative length or size to all vectors in a vector space. Unlike a norm, a seminorm can have a null space that is larger than just the zero vector, meaning some non-zero vectors can have a seminorm of zero.

Seminorms must satisfy: 1. Non-negativity: ||x|| ≥ 0 for all x 2. Triangle inequality: ||x + y|| ≤ ||x|| + ||y|| for all x, y 3. Scalar homogeneity: ||αx|| = |α|·||x|| for all x and scalar α

Unlike norms, seminorms do not require: - Definiteness: ||x|| = 0 implies x = 0

compute abstractmethod

compute(x)

Compute the seminorm of the input.

Parameters

x : InputType The input to compute the seminorm for. Can be a vector, matrix, sequence, string, or callable.

Returns

float The seminorm value (non-negative real number)

Raises

TypeError If the input type is not supported ValueError If the computation cannot be performed on the given input

Source code in swarmauri_core/seminorms/ISeminorm.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@abstractmethod
def compute(self, x: InputType) -> float:
    """
    Compute the seminorm of the input.

    Parameters
    ----------
    x : InputType
        The input to compute the seminorm for. Can be a vector, matrix,
        sequence, string, or callable.

    Returns
    -------
    float
        The seminorm value (non-negative real number)

    Raises
    ------
    TypeError
        If the input type is not supported
    ValueError
        If the computation cannot be performed on the given input
    """
    pass

check_triangle_inequality abstractmethod

check_triangle_inequality(x, y)

Check if the triangle inequality property holds for the given inputs.

The triangle inequality states that: ||x + y|| ≤ ||x|| + ||y||

Parameters

x : InputType First input to check y : InputType Second input to check

Returns

bool True if the triangle inequality holds, False otherwise

Raises

TypeError If the input types are not supported or compatible ValueError If the check cannot be performed on the given inputs

Source code in swarmauri_core/seminorms/ISeminorm.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@abstractmethod
def check_triangle_inequality(self, x: InputType, y: InputType) -> bool:
    """
    Check if the triangle inequality property holds for the given inputs.

    The triangle inequality states that:
    ||x + y|| ≤ ||x|| + ||y||

    Parameters
    ----------
    x : InputType
        First input to check
    y : InputType
        Second input to check

    Returns
    -------
    bool
        True if the triangle inequality holds, False otherwise

    Raises
    ------
    TypeError
        If the input types are not supported or compatible
    ValueError
        If the check cannot be performed on the given inputs
    """
    pass

check_scalar_homogeneity abstractmethod

check_scalar_homogeneity(x, alpha)

Check if the scalar homogeneity property holds for the given input and scalar.

The scalar homogeneity states that: ||αx|| = |α|·||x||

Parameters

x : InputType The input to check alpha : T The scalar to multiply by

Returns

bool True if scalar homogeneity holds, False otherwise

Raises

TypeError If the input type is not supported ValueError If the check cannot be performed on the given input

Source code in swarmauri_core/seminorms/ISeminorm.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
@abstractmethod
def check_scalar_homogeneity(self, x: InputType, alpha: T) -> bool:
    """
    Check if the scalar homogeneity property holds for the given input and scalar.

    The scalar homogeneity states that:
    ||αx|| = |α|·||x||

    Parameters
    ----------
    x : InputType
        The input to check
    alpha : T
        The scalar to multiply by

    Returns
    -------
    bool
        True if scalar homogeneity holds, False otherwise

    Raises
    ------
    TypeError
        If the input type is not supported
    ValueError
        If the check cannot be performed on the given input
    """
    pass