# Path: Turbine/calc/lcm.py
# def lcm(a, b):
#     return abs(a * b) / gcd(a, b)


from fractions import Fraction
from math import ceil
from numpy.random.mtrand import randint
from Turbine.calc.lcm import lcm
    if not __test_coef(coef, [dataflow.get_initial_marking(arc)]):
        dataflow.set_initial_marking(arc, int(ceil(dataflow.get_initial_marking(arc) * coef)))
    else:
        dataflow.set_initial_marking(arc, int(dataflow.get_initial_marking(arc) * coef))

    if dataflow.is_sdf:
        dataflow.set_prod_rate(arc, int(dataflow.get_prod_rate(arc) * coef))
        dataflow.set_cons_rate(arc, int(dataflow.get_cons_rate(arc) * coef))
    if dataflow.is_csdf:
        dataflow.set_prod_rate_list(arc, [int(x * coef) for x in dataflow.get_prod_rate_list(arc)])
        dataflow.set_cons_rate_list(arc, [int(x * coef) for x in dataflow.get_cons_rate_list(arc)])
    if dataflow.is_pcg:
        dataflow.set_ini_prod_rate_list(arc, [int(x * coef) for x in dataflow.get_ini_prod_rate_list(arc)])
        dataflow.set_ini_cons_rate_list(arc, [int(x * coef) for x in dataflow.get_ini_cons_rate_list(arc)])
        dataflow.set_threshold_list(arc, [int(x * coef) for x in dataflow.get_threshold_list(arc)])
        dataflow.set_ini_threshold_list(arc, [int(x * coef) for x in dataflow.get_ini_threshold_list(arc)])


def get_normalized_vector(dataflow):
    """Compute the normalization vector of an un-normalize graph.

    Return
    ------
    Return the the vector of coefficient for normalize the graph.
    """
    coef_list = {}

    lcm_rf = 1
    lcm_post_mult = 1
    for task in dataflow.get_task_list():

# Path: Turbine/calc/lcm.py
# def lcm(a, b):
#     return abs(a * b) / gcd(a, b)


# Path: Turbine/algorithms/normalized.py
from fractions import Fraction
from math import ceil
from numpy.random.mtrand import randint
from Turbine.calc.lcm import lcm

    if not __test_coef(coef, [dataflow.get_initial_marking(arc)]):
        dataflow.set_initial_marking(arc, int(ceil(dataflow.get_initial_marking(arc) * coef)))
    else:
        dataflow.set_initial_marking(arc, int(dataflow.get_initial_marking(arc) * coef))

    if dataflow.is_sdf:
        dataflow.set_prod_rate(arc, int(dataflow.get_prod_rate(arc) * coef))
        dataflow.set_cons_rate(arc, int(dataflow.get_cons_rate(arc) * coef))
    if dataflow.is_csdf:
        dataflow.set_prod_rate_list(arc, [int(x * coef) for x in dataflow.get_prod_rate_list(arc)])
        dataflow.set_cons_rate_list(arc, [int(x * coef) for x in dataflow.get_cons_rate_list(arc)])
    if dataflow.is_pcg:
        dataflow.set_ini_prod_rate_list(arc, [int(x * coef) for x in dataflow.get_ini_prod_rate_list(arc)])
        dataflow.set_ini_cons_rate_list(arc, [int(x * coef) for x in dataflow.get_ini_cons_rate_list(arc)])
        dataflow.set_threshold_list(arc, [int(x * coef) for x in dataflow.get_threshold_list(arc)])
        dataflow.set_ini_threshold_list(arc, [int(x * coef) for x in dataflow.get_ini_threshold_list(arc)])


def get_normalized_vector(dataflow):
    """Compute the normalization vector of an un-normalize graph.

    Return
    ------
    Return the the vector of coefficient for normalize the graph.
    """
    coef_list = {}

    lcm_rf = 1
    lcm_post_mult = 1
    for task in dataflow.get_task_list():

        lcm_rf = lcm(lcm_rf, dataflow.get_repetition_factor(task))