Given that X is a matrix of dtype floatX, x should probably be converted into floatX too, otherwise the test will probably fail when floatX=float32, as it would force a loss of precision inside function.