def test_Iwik_Jwik_identities(): dW = deltaW(N, m, h).reshape((N, m, 1)) Atilde, I = Iwik(dW, h) M = m * (m - 1) // 2 assert (Atilde.shape == (N, M, 1) and I.shape == (N, m, m)) Im = broadcast_to(np.eye(m), (N, m, m)) assert (np.allclose(I + _t(I), _dot(dW, _t(dW)) - h * Im)) # can get A from Atilde: (Wiktorsson2001 equation between (4.3) and (4.4)) Ims = broadcast_to(np.eye(m * m), (N, m * m, m * m)) Pm = broadcast_to(_P(m), (N, m * m, m * m)) Km = broadcast_to(_K(m), (N, M, m * m)) A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde)) # now can test this A against the identities of Wiktorsson eqn (2.1) assert (np.allclose(A, -_t(A))) assert (np.allclose(2.0 * (I - A), _dot(dW, _t(dW)) - h * Im)) # and tests for Stratonovich case Atilde, J = Jwik(dW, h) assert (Atilde.shape == (N, M, 1) and J.shape == (N, m, m)) assert (np.allclose(J + _t(J), _dot(dW, _t(dW)))) A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde)) assert (np.allclose(2.0 * (J - A), _dot(dW, _t(dW))))
def test_Iwik_Jwik_identities(): dW = deltaW(N, m, h).reshape((N, m, 1)) Atilde, I = Iwik(dW, h) M = m*(m-1)/2 assert(Atilde.shape == (N, M, 1) and I.shape == (N, m, m)) Im = broadcast_to(np.eye(m), (N, m, m)) assert(np.allclose(I + _t(I), _dot(dW, _t(dW)) - h*Im)) # can get A from Atilde: (Wiktorsson2001 equation between (4.3) and (4.4)) Ims = broadcast_to(np.eye(m*m), (N, m*m, m*m)) Pm = broadcast_to(_P(m), (N, m*m, m*m)) Km = broadcast_to(_K(m), (N, M, m*m)) A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde)) # now can test this A against the identities of Wiktorsson eqn (2.1) assert(np.allclose(A, -_t(A))) assert(np.allclose(2.0*(I - A), _dot(dW, _t(dW)) - h*Im)) # and tests for Stratonovich case Atilde, J = Jwik(dW, h) assert(Atilde.shape == (N, M, 1) and J.shape == (N, m, m)) assert(np.allclose(J + _t(J), _dot(dW, _t(dW)))) A = _unvec(_dot(_dot((Ims - Pm), _t(Km)), Atilde)) assert(np.allclose(2.0*(J - A), _dot(dW, _t(dW))))
def test_vec_unvec(): A = np.arange(10 * 3 * 3).reshape((10, 3, 3)) vecA = _vec(A) assert (vecA.shape == (10, 9, 1)) assert (np.allclose(_unvec(vecA) - A, np.zeros((10, 3, 3))))
def test_vec_unvec(): A = np.arange(10*3*3).reshape((10, 3, 3)) vecA = _vec(A) assert(vecA.shape == (10, 9, 1)) assert(np.allclose(_unvec(vecA) - A, np.zeros((10, 3, 3))))