# Path: umap/utils.py
# @numba.njit()
# def norm(vec):
#     """Compute the (standard l2) norm of a vector.
# 
#     Parameters
#     ----------
#     vec: array of shape (dim,)
# 
#     Returns
#     -------
#     The l2 norm of vec.
#     """
#     result = 0.0
#     for i in range(vec.shape[0]):
#         result += vec[i] ** 2
#     return np.sqrt(result)


import locale
import numba
import numpy as np
from umap.utils import norm

@numba.njit()
def sparse_correlation(ind1, data1, ind2, data2, n_features):

    mu_x = 0.0
    mu_y = 0.0
    dot_product = 0.0

    if ind1.shape[0] == 0 and ind2.shape[0] == 0:
        return 0.0
    elif ind1.shape[0] == 0 or ind2.shape[0] == 0:
        return 1.0

    for i in range(data1.shape[0]):
        mu_x += data1[i]
    for i in range(data2.shape[0]):
        mu_y += data2[i]

    mu_x /= n_features
    mu_y /= n_features

    shifted_data1 = np.empty(data1.shape[0], dtype=np.float32)
    shifted_data2 = np.empty(data2.shape[0], dtype=np.float32)

    for i in range(data1.shape[0]):
        shifted_data1[i] = data1[i] - mu_x
    for i in range(data2.shape[0]):
        shifted_data2[i] = data2[i] - mu_y

    norm1 = np.sqrt(

# Path: umap/utils.py
# @numba.njit()
# def norm(vec):
#     """Compute the (standard l2) norm of a vector.
# 
#     Parameters
#     ----------
#     vec: array of shape (dim,)
# 
#     Returns
#     -------
#     The l2 norm of vec.
#     """
#     result = 0.0
#     for i in range(vec.shape[0]):
#         result += vec[i] ** 2
#     return np.sqrt(result)


# Path: umap/sparse.py
import locale
import numba
import numpy as np
from umap.utils import norm


@numba.njit()
def sparse_correlation(ind1, data1, ind2, data2, n_features):

    mu_x = 0.0
    mu_y = 0.0
    dot_product = 0.0

    if ind1.shape[0] == 0 and ind2.shape[0] == 0:
        return 0.0
    elif ind1.shape[0] == 0 or ind2.shape[0] == 0:
        return 1.0

    for i in range(data1.shape[0]):
        mu_x += data1[i]
    for i in range(data2.shape[0]):
        mu_y += data2[i]

    mu_x /= n_features
    mu_y /= n_features

    shifted_data1 = np.empty(data1.shape[0], dtype=np.float32)
    shifted_data2 = np.empty(data2.shape[0], dtype=np.float32)

    for i in range(data1.shape[0]):
        shifted_data1[i] = data1[i] - mu_x
    for i in range(data2.shape[0]):
        shifted_data2[i] = data2[i] - mu_y

    norm1 = np.sqrt(

        (norm(shifted_data1) ** 2) + (n_features - ind1.shape[0]) * (mu_x ** 2)