def test_quartic(self):
import math
# Use a fixed seed so the test is deterministic and round
# the nodes to 8 bits of precision to avoid round-off.
nodes = utils.get_random_nodes(
shape=(15, 2), seed=11112222, num_bits=8)
lambda_vals = (0.125, 0.375, 0.5)
index = 0
expected = np.asfortranarray([[0.0, 0.0]])
for k in range(4 + 1):
for j in range(4 + 1 - k):
i = 4 - j - k
denom = (math.factorial(i) * math.factorial(j) *
math.factorial(k))
coeff = 24 / denom
expected += (
coeff * lambda_vals[0]**i * lambda_vals[1]**j *
lambda_vals[2]**k * nodes[[index], :])
index += 1
result = self._call_function_under_test(nodes, 4, *lambda_vals)
self.assertEqual(result, expected)
评论列表
文章目录