Exemplo n.º 1
0
 def __call__(self, A, b, inference=False):
     if inference is True:
         solve = slinalg.Solve()
         x = solve(A, b)
     else:
         x = nlinalg.matrix_inverse(A).dot(b)
     return x
Exemplo n.º 2
0
 def energy(self, x):
     L1x = slinalg.Solve(lower=True)(self.L, x)
     return .5 * L1x.T.dot(L1x)
Exemplo n.º 3
0
 def velocity(self, x):
     solve = slinalg.Solve(lower=True)
     y = solve(self.L, x)
     return solve(self.L.T, y)
Exemplo n.º 4
0
    def __getattr__(cls, attr):
        if config.lazy:
            return getattr(tt, attr)
        else:
            return getattr(np, attr)


class math(metaclass=MathType):
    """Alias for ``numpy`` or ``theano.tensor``, depending on `config.lazy`."""

    pass


# Cholesky solve
_solve_lower = sla.Solve(A_structure="lower_triangular", lower=True)
_solve_upper = sla.Solve(A_structure="upper_triangular", lower=False)


def _cho_solve(cho_A, b):
    return _solve_upper(tt.transpose(cho_A), _solve_lower(cho_A, b))


class LinAlgType(type):
    """Linear algebra operations."""
    @autocompile
    def cho_solve(self, cho_A, b):
        return _cho_solve(cho_A, b)

    @autocompile
    def solve(self, X, flux, cho_C, mu, LInv):