def l1_cross_distances(X, Y=None):
    if Y is None:      
        X = array2d(X)
        n_samples, n_features = X.shape
        n_nonzero_cross_dist = n_samples * (n_samples - 1) / 2
        D = np.zeros((n_nonzero_cross_dist, n_features))
        ll_1 = 0
        for k in range(n_samples - 1):
            ll_0 = ll_1
            ll_1 = ll_0 + n_samples - k - 1
            D[ll_0:ll_1] = np.abs(X[k] - X[(k + 1):])
    
        return D
        
    else:
        X = array2d(X)
        Y = array2d(Y)
        n_samples_X, n_features_X = X.shape
        n_samples_Y, n_features_Y = Y.shape
        if n_features_X != n_features_Y:
            raise ValueError("X and Y must have the same dimensions.")
        n_features = n_features_X
        
        n_nonzero_cross_dist = n_samples_X * n_samples_Y
        D = np.zeros((n_nonzero_cross_dist, n_features))
        ll_1 = 0
        for k in range(n_samples_X):
            ll_0 = ll_1
            ll_1 = ll_0 + n_samples_Y# - k - 1
            D[ll_0:ll_1] = np.abs(X[k] - Y)
    
        return D
Computes the nonzero componentwise L1 cross-distances between the vectors
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/surrogatemodels/multifi_cokriging_surrogate.py/l1_cross_distances