Esempio n. 1
0
def _product(thetas: ThetaType, operators: tuple_of(Matrix.Type())):
    output = tensor_copy(operators[0])
    output.zero()
    for (theta, operator) in zip(thetas, operators):
        theta = float(theta)
        output += theta * operator
    return ProductOutput(output)
Esempio n. 2
0
def _product(thetas: ThetaType, operators: tuple_of(Vector.Type())):
    output = tensor_copy(operators[0])
    output.zero()
    for (theta, operator) in zip(thetas, operators):
        theta = float(theta)
        output.add_local(theta * operator.get_local())
    output.apply("add")
    return ProductOutput(output)