Exemplo n.º 1
0
 def project(self, directions):
     if type(directions) is int:
         directions = [directions]
     directions = core.to_numeric(directions)
     p_coeffs = core.project(self.coeffs, self.position.dim, directions)
     p_pos = self.position.project(directions)
     return Series(p_coeffs, p_pos)
Exemplo n.º 2
0
 def project(self, directions):
     if type(directions) is int:
         directions = [directions]
     directions = core.to_numeric(directions)
     p_matrix = core.project(self.matrix, self.position.dim, directions)
     p_pos = self.position.project(directions)
     return Varf(p_matrix, p_pos)
Exemplo n.º 3
0
 def test_project_matrix_2d_subspace(self):
     n_points, degree = 50, 10
     function = 'exp(x) * cos(y)'
     quad_2d = hm.Quad.gauss_hermite(n_points, dim=2)
     quad_3d = hm.Quad.gauss_hermite(n_points, dim=3)
     varf_2d = quad_2d.varf(function, degree).matrix
     varf_3d = quad_3d.varf(function, degree).matrix
     projection = core.project(varf_3d, 3, [0, 1])
     diff = (la.norm(varf_2d - projection, 2))
     self.assertAlmostEqual(diff, 0)
Exemplo n.º 4
0
 def test_project_matrix(self):
     n_points, degree = 200, 10
     function = 'exp(x)'
     quad_1d = hm.Quad.gauss_hermite(n_points, dim=1)
     quad_2d = hm.Quad.gauss_hermite(n_points, dim=2)
     varf_1d = quad_1d.varf(function, degree).matrix
     varf_2d = quad_2d.varf(function, degree).matrix
     projection = core.project(varf_2d, 2, 0)
     diff = (la.norm(varf_1d - projection, 2))
     self.assertAlmostEqual(diff, 0)
Exemplo n.º 5
0
 def test_project_vector(self):
     n_points = 200
     degree = 10
     quad_1d = hm.Quad.gauss_hermite(n_points, dim=1)
     quad_2d = hm.Quad.gauss_hermite(n_points, dim=2)
     coeffs_1d = quad_1d.transform('exp(x)', degree).coeffs
     coeffs_2d = quad_2d.transform('exp(x)', degree).coeffs
     projection = core.project(coeffs_2d, 2, 0)
     diff = la.norm(coeffs_1d - projection, 2)
     self.assertAlmostEqual(diff, 0)
Exemplo n.º 6
0
 def project(self, directions):
     if isinstance(directions, int):
         directions = [directions]
     rel_dirs = [self.dirs.index(d) for d in directions]
     p_matrix = core.project(self.matrix, self.position.dim, rel_dirs,
                             index_set=self.index_set)
     p_pos = self.position.project(directions)
     factor = self.factor.project(directions)
     return Varf(p_matrix, p_pos,
                 factor=factor, index_set=self.index_set)
Exemplo n.º 7
0
 def test_project_matrix_2d_subspace_sparse(self):
     # hm.settings['tensorize'] = False
     n_points, degree = 50, 10
     function = 'exp(x) * cos(y)'
     quad_2d = hm.Quad.gauss_hermite(n_points, dim=2)
     quad_3d = hm.Quad.gauss_hermite(n_points, dim=3)
     varf_2d = quad_2d.varf(function, degree, sparse=True).matrix
     varf_3d = quad_3d.varf(function, degree, sparse=True).matrix
     projection = core.project(varf_3d, 3, [0, 1])
     diff = (las.norm(varf_2d - projection))
     self.assertAlmostEqual(diff, 0)
Exemplo n.º 8
0
 def project(self, directions):
     if not isinstance(directions, list):
         directions = [directions]
     rel_dirs = [self.position.dirs.index(d) for d in directions]
     p_coeffs = core.project(self.coeffs,
                             self.position.dim,
                             rel_dirs,
                             index_set=self.index_set)
     p_pos = self.position.project(directions)
     factor = self.factor.project(directions)
     return Series(p_coeffs, p_pos, factor=factor, index_set=self.index_set)