From cf1d07f31c69a992339c686f0288bdd93a7ecac5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Fri, 16 Dec 2011 16:02:32 +0100
Subject: [PATCH] More unitary tests (multivariate Gaussian quadrature) using
 cartesian_product_of_sets.

---
 matlab/gauss_hermite_weights_and_nodes.m | 36 +++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/matlab/gauss_hermite_weights_and_nodes.m b/matlab/gauss_hermite_weights_and_nodes.m
index 6ae5d5b223..7db89ca26c 100644
--- a/matlab/gauss_hermite_weights_and_nodes.m
+++ b/matlab/gauss_hermite_weights_and_nodes.m
@@ -71,4 +71,38 @@ nodes = sqrt(2)*nodes;
 %$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
 %$ t(2) = dyn_assert(enodes,nodes/sqrt(2),1e-8);
 %$ T = all(t);
-%@eof:1
\ No newline at end of file
+%@eof:1
+
+%@test:2
+%$ n = 9;
+%$ [nodes,weights] = gauss_hermite_weights_and_nodes(n);
+%$
+%$ sum_of_weights = sum(weights);
+%$ expectation = sum(weights.*nodes); 
+%$ variance = sum(weights.*(nodes.^2));
+%$
+%$ % Check the results.
+%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dyn_assert(1.0,variance,1e-12);
+%$ t(3) = dyn_assert(0.0,expectation,1e-12);
+%$ T = all(t);
+%@eof:2
+
+%@test:3
+%$ n = 9;
+%$ [nodes,weights] = gauss_hermite_weights_and_nodes(n);
+%$
+%$ NODES = cartesian_product_of_sets(nodes,nodes);
+%$ WEIGHTS = cartesian_product_of_sets(weights,weights);
+%$ WEIGHTS = prod(WEIGHTS,2);
+%$
+%$ sum_of_weights = sum(WEIGHTS);
+%$ expectation = transpose(WEIGHTS)*NODES;
+%$ variance = transpose(WEIGHTS)*NODES.^2;
+%$
+%$ % Check the results.
+%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dyn_assert(ones(1,2),variance,1e-12);
+%$ t(3) = dyn_assert(zeros(1,2),expectation,1e-12);
+%$ T = all(t);
+%@eof:3
\ No newline at end of file
-- 
GitLab