SG++-Doxygen-Documentation
Point Distributions (Python)

This simple example demonstrates the different types of 1-D point distributions available in the combigrid module.

point_distributions.png
1 import numpy as np
2 import matplotlib.pyplot as plt
3 
4 import pysgpp
5 
6 n_points = 13
7 y_range = np.ones([1, n_points])
8 points = np.zeros([6, n_points])
9 
10 uni = pysgpp.UniformPointDistribution()
11 unib = pysgpp.UniformBoundaryPointDistribution()
12 cheby = pysgpp.ChebyshevDistribution()
13 ccurtis = pysgpp.ClenshawCurtisDistribution()
14 leja = pysgpp.LejaPointDistribution()
15 l2_leja = pysgpp.L2LejaPointDistribution()
16 
17 
18 for i in range(n_points):
19  points[0, i] = uni.compute(n_points, i)
20  points[1, i] = unib.compute(n_points, i)
21  points[2, i] = cheby.compute(n_points, i)
22  points[3, i] = ccurtis.compute(n_points, i)
23  points[4, i] = leja.compute(n_points, i)
24  points[5, i] = l2_leja.compute(n_points, i)
25 
26 plt.scatter(points[0,], y_range*6, label="Uniform")
27 plt.scatter(points[1,], y_range*5, label="UniformBoundary")
28 plt.scatter(points[2,], y_range*4, label="Chebychev")
29 plt.scatter(points[3,], y_range*3, label="Clenshaw-Curtis")
30 plt.scatter(points[4,], y_range*2, label="Leja")
31 plt.scatter(points[5,], y_range*1, label="L2-Leja")
32 
33 plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.15),
34  ncol=3, fancybox=True)
35 
36 plt.savefig("point_distributions.png")
37 
38 plt.show()