Pre-devel-move check in

This commit is contained in:
Neil Lawrence 2014-04-29 15:43:35 +01:00
parent 643f338337
commit 5405dbd1bc
3 changed files with 32 additions and 25 deletions

View file

@ -107,14 +107,14 @@ class Symbolic_core():
# Do symbolic work to compute derivatives. # Do symbolic work to compute derivatives.
for key, func in self.expressions.items(): for key, func in self.expressions.items():
if func['function'].is_Matrix: # if func['function'].is_Matrix:
rows = func['function'].shape[0] # rows = func['function'].shape[0]
cols = func['function'].shape[1] # cols = func['function'].shape[1]
self.expressions[key]['derivative'] = sym.zeros(rows, cols) # self.expressions[key]['derivative'] = sym.zeros(rows, cols)
for i in xrange(rows): # for i in xrange(rows):
for j in xrange(cols): # for j in xrange(cols):
self.expressions[key]['derivative'][i, j] = extract_derivative(func['function'][i, j], derivative_arguments) # self.expressions[key]['derivative'][i, j] = extract_derivative(func['function'][i, j], derivative_arguments)
else: # else:
self.expressions[key]['derivative'] = extract_derivative(func['function'], derivative_arguments) self.expressions[key]['derivative'] = extract_derivative(func['function'], derivative_arguments)
def _set_parameters(self, parameters): def _set_parameters(self, parameters):

View file

@ -6,18 +6,18 @@ from poisson import Poisson
from student_t import StudentT from student_t import StudentT
from likelihood import Likelihood from likelihood import Likelihood
from mixed_noise import MixedNoise from mixed_noise import MixedNoise
# TODO need to fix this in a config file. #TODO need to fix this in a config file.
# TODO need to add the files to the git repo! #TODO need to add the files to the git repo!
#try: try:
#import sympy as sym import sympy as sym
#sympy_available=True sympy_available=True
#except ImportError: except ImportError:
#sympy_available=False sympy_available=False
#if sympy_available: if sympy_available:
## These are likelihoods that rely on symbolic. #These are likelihoods that rely on symbolic.
#from symbolic import Symbolic from symbolic import Symbolic
#from sstudent_t import SstudentT from sstudent_t import SstudentT
#from negative_binomial import Negative_binomial from negative_binomial import Negative_binomial
##from skew_normal import Skew_normal from skew_normal import Skew_normal
#from skew_exponential import Skew_exponential from skew_exponential import Skew_exponential
#from null_category import Null_category # from null_category import Null_category

View file

@ -2,15 +2,22 @@ import sys
import numpy as np import numpy as np
import sympy as sym import sympy as sym
from sympy import Function, S, oo, I, cos, sin, asin, log, erf, pi, exp, sqrt, sign, gamma, polygamma from sympy import Function, S, oo, I, cos, sin, asin, log, erf, pi, exp, sqrt, sign, gamma, polygamma
from sympy.matrices import Matrix
######################################## ########################################
## Try to do some matrix functions: problem, you can't do derivatives ## Try to do some matrix functions: problem, you can't do derivatives
## with respect to matrix functions :-( ## with respect to matrix functions :-(
class GPySymMatrix(Matrix):
def __init__(self, indices):
Matrix.__init__(self)
def atoms(self):
return [e2 for e in self for e2 in e.atoms()]
class selector(Function): class selector(Function):
"""A function that returns an element of a Matrix depending on input indices.""" """A function that returns an element of a Matrix depending on input indices."""
nargs = 3 nargs = 3
def fdiff(self, argindex=1):
return selector(*self.args)
@classmethod @classmethod
def eval(cls, X, i, j): def eval(cls, X, i, j):
if i.is_Number and j.is_Number: if i.is_Number and j.is_Number: