Skip to content

Class swarmauri_core.vector_stores.IVectorNorm.IVectorNorm

swarmauri_core.vector_stores.IVectorNorm.IVectorNorm

Bases: ABC

Interface for calculating vector norms. Supports L1 norm, L2 norm, and Max norm calculations.

l1_norm abstractmethod

l1_norm(vector)

Calculate the L1 norm (Manhattan norm) of a vector.

Parameters: - vector (List[Union[int, float]]): The vector for which to calculate the L1 norm.

Returns: - float: The L1 norm of the vector.

Source code in swarmauri_core/vector_stores/IVectorNorm.py
13
14
15
16
17
18
19
20
21
22
23
24
@abstractmethod
def l1_norm(self, vector: List[Union[int, float]]) -> float:
    """
    Calculate the L1 norm (Manhattan norm) of a vector.

    Parameters:
    - vector (List[Union[int, float]]): The vector for which to calculate the L1 norm.

    Returns:
    - float: The L1 norm of the vector.
    """
    pass

l2_norm abstractmethod

l2_norm(vector)

Calculate the L2 norm (Euclidean norm) of a vector.

Parameters: - vector (List[Union[int, float]]): The vector for which to calculate the L2 norm.

Returns: - float: The L2 norm of the vector.

Source code in swarmauri_core/vector_stores/IVectorNorm.py
26
27
28
29
30
31
32
33
34
35
36
37
@abstractmethod
def l2_norm(self, vector: List[Union[int, float]]) -> float:
    """
    Calculate the L2 norm (Euclidean norm) of a vector.

    Parameters:
    - vector (List[Union[int, float]]): The vector for which to calculate the L2 norm.

    Returns:
    - float: The L2 norm of the vector.
    """
    pass

max_norm abstractmethod

max_norm(vector)

Calculate the Max norm (infinity norm) of a vector.

Parameters: - vector (List[Union[int, float]]): The vector for which to calculate the Max norm.

Returns: - float: The Max norm of the vector.

Source code in swarmauri_core/vector_stores/IVectorNorm.py
39
40
41
42
43
44
45
46
47
48
49
50
@abstractmethod
def max_norm(self, vector: List[Union[int, float]]) -> float:
    """
    Calculate the Max norm (infinity norm) of a vector.

    Parameters:
    - vector (List[Union[int, float]]): The vector for which to calculate the Max norm.

    Returns:
    - float: The Max norm of the vector.
    """
    pass