Class swarmauri_core.norms.INorm.INorm
swarmauri_core.norms.INorm.INorm
Bases: ABC
Interface for norm computations on vector spaces.
This interface defines the contract for norm behavior, enforcing point-separating distance logic. Norms provide a way to measure the "size" or "length" of elements in a vector space.
A norm must satisfy the following properties: 1. Non-negativity: norm(x) >= 0 for all x 2. Definiteness: norm(x) = 0 if and only if x = 0 3. Triangle inequality: norm(x + y) <= norm(x) + norm(y) 4. Absolute homogeneity: norm(ax) = |a|norm(x) for scalar a
compute
abstractmethod
compute(x)
Compute the norm of the input.
Parameters
x : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The input for which to compute the norm.
Returns
float The computed norm value.
Raises
TypeError If the input type is not supported. ValueError If the norm cannot be computed for the given input.
Source code in swarmauri_core/norms/INorm.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
check_non_negativity
abstractmethod
check_non_negativity(x)
Check if the norm satisfies the non-negativity property.
Parameters
x : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The input to check.
Returns
bool True if the norm is non-negative, False otherwise.
Source code in swarmauri_core/norms/INorm.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
check_definiteness
abstractmethod
check_definiteness(x)
Check if the norm satisfies the definiteness property.
The definiteness property states that the norm of x is 0 if and only if x is 0.
Parameters
x : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The input to check.
Returns
bool True if the norm satisfies the definiteness property, False otherwise.
Source code in swarmauri_core/norms/INorm.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
check_triangle_inequality
abstractmethod
check_triangle_inequality(x, y)
Check if the norm satisfies the triangle inequality.
The triangle inequality states that norm(x + y) <= norm(x) + norm(y).
Parameters
x : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The first input. y : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The second input.
Returns
bool True if the norm satisfies the triangle inequality, False otherwise.
Raises
TypeError If the inputs are not of the same type or cannot be added.
Source code in swarmauri_core/norms/INorm.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
check_absolute_homogeneity
abstractmethod
check_absolute_homogeneity(x, scalar)
Check if the norm satisfies the absolute homogeneity property.
The absolute homogeneity property states that norm(ax) = |a|norm(x) for scalar a.
Parameters
x : Union[VectorType, MatrixType, SequenceType, StringType, CallableType] The input. scalar : float The scalar value.
Returns
bool True if the norm satisfies the absolute homogeneity property, False otherwise.
Raises
TypeError If the input cannot be scaled by the scalar.
Source code in swarmauri_core/norms/INorm.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|