import math


def get_distance(vector, configuration):
    """
    Compute Quadratic form distance of given vector and patterns specified in the configuration.

    :param vector: vector that is compared with patterns specified in configuration
    :param configuration: loaded application configuration
    :return: Dictionary of pattern names and its distances from given vector
    """
    distances = {}
    for pattern in configuration['distance']['patterns']:
        distances[pattern['name']] = math.sqrt(sum([((v - p) / float(p)) ** 2 if p else float("inf") for v, p in zip(vector['vector'], pattern['vector'])]))
    return {'distances': distances}