Esempio n. 1
0
def dot_product(x: LRVector, y: TBVector):

    alpha = Scalar(0)

    def kernel(chi: float, psi: float, alpha: float):
        return chi * psi + alpha

    return apply(kernel, x, y, alpha)
def linear_transformation_1(A: TBMatrix, x: TBVector):

    y = generate_tb_vector(0, 0, len(x.value))

    def kernel(a: TBVector, psi: Scalar):
        return dot_product(a, x) + psi

    return apply(kernel, A, y)
def linear_transformation_2(A: LRMatrix, x: TBVector):

    y = FixedVector(generate_list(0, 0, len(x.value), False))

    def kernel(chi: Scalar, a: TBVector, y: FixedVector):
        return axpy(Scalar(chi), a, TBVector(y.value))

    return apply(kernel, x, A, y)
Esempio n. 4
0
def axpy(alpha: Scalar, x: TBVector, y: TBVector):
    def kernel(alpha: float, chi: float, psi: float):
        return alpha * chi + psi

    return apply(kernel, alpha, x, y)
Esempio n. 5
0
def add(x: TBVector, y: TBVector):

    return apply(lambda chi, psi: chi + psi, x, y)
Esempio n. 6
0
def scal(alpha: Scalar, x: TBVector):

    return apply(lambda alpha, x: alpha * x, alpha, x)