Пример #1
0
    def solve_nonlinear(self, params, unknowns, resids):

        x = params['x']
        y = params['y']
        A = params['A']

        unknowns['f_xy'] = x**2 + y**2 + np.sin(A).sum()
        unknowns['g_xy'] = np.linalg.dot(A**2, np.array([y, x**2]))
Пример #2
0
 def test_dg_dA(self):
     B = 2*self.A * np.array([self.y, self.x**2])
     actual = np.kron(B, np.array([[1],[0],[0]]))[:4].flatten()
     computed = self.deriv['g_xy', 'A']['J_fwd'].flatten()
     self.assertAlmostEquals(np.linalg.norm(actual - computed), 0)