diff options
Diffstat (limited to 'ot/utils.py')
-rw-r--r-- | ot/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ot/utils.py b/ot/utils.py new file mode 100644 index 0000000..1a1c6b8 --- /dev/null +++ b/ot/utils.py @@ -0,0 +1,15 @@ + +import numpy as np +from scipy.spatial.distance import cdist, pdist + + +def dist(x1,x2=None,metric='sqeuclidean'): + """Compute distance between samples in x1 and x2""" + if x2 is None: + return pdist(x1,metric=metric) + else: + return cdist(x1,x2,metric=metric) + +def dots(*args): + """ Stupid but nice dots function for multiple matrix multiply """ + return reduce(np.dot,args)
\ No newline at end of file |