Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions demos/demo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
degree = 4

# The first way of doing it is by directly supplying the weight function.
wf = lambda(x): 1. / math.sqrt(2. * math.pi) * np.exp(-x ** 2 / 2.)
wf = lambda x: 1. / math.sqrt(2. * math.pi) * np.exp(-x ** 2 / 2.)
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=-np.inf, right=np.inf, # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print(('Number of inputs:', p.num_input))
print(('Number of outputs:', p.num_output))
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print(('Is normalized:', p.is_normalized))
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print(('Polynomial degree:', p.degree))
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print(('Alpha:', p.alpha))
print(('Beta:', p.beta))
# The following should print a description of the polynomial
print str(p)
print((str(p)))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(-2., 2., 100)
# Here is the actual evaluation
Expand All @@ -55,7 +55,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -65,5 +65,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
18 changes: 9 additions & 9 deletions demos/demo10.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
p = orthpol.OrthogonalPolynomial(degree, rv=rv)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(lower, upper, 100)
# Here is the actual evaluation
Expand All @@ -59,7 +59,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -69,5 +69,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
10 changes: 5 additions & 5 deletions demos/demo11.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
# Then construct the product basis
p = orthpol.ProductBasis(degree=degree, rvs=rvs)
# Print info about the polynomials
print str(p)
print(str(p))
# Evaluate the polynomials at some points
X = np.hstack([rvs[0].rvs(size=(100, 1)), rvs[1].rvs(size=(100, 1))])
# Look at the shape of X, it should be 100x2:
print 'X shape:', X.shape
print('X shape:', X.shape)
# Evaluate the polynomials at X
phi = p(X)
# Look at the shape of phi, it should be 100xp.num_output
print 'phi shape:', phi.shape
print('phi shape:', phi.shape)
# Take a look at the phi's also
print 'phi:'
print phi
print('phi:')
print(phi)
20 changes: 10 additions & 10 deletions demos/demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
degree = 4

# The first way of doing it is by directly supplying the weight function.
wf = lambda(x): np.exp(-x)
wf = lambda x: np.exp(-x)
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=0, right=np.inf, # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(0., 2., 100)
# Here is the actual evaluation
Expand All @@ -55,7 +55,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -65,5 +65,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
20 changes: 10 additions & 10 deletions demos/demo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
degree = 4

# The first way of doing it is by directly supplying the weight function.
wf = lambda(x): 1. / np.sqrt(1. - x)
wf = lambda x: 1. / np.sqrt(1. - x)
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=-1., right=1., # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(-1., 1., 100)
# Here is the actual evaluation
Expand All @@ -55,7 +55,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -65,5 +65,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
20 changes: 10 additions & 10 deletions demos/demo4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
# Pick the alpha and beta of the Gegenbauer polynomials
alpha = .5
# The first way of doing it is by directly supplying the weight function.
wf = lambda(x): (1. - x ** 2.) ** (alpha - 0.5)
wf = lambda x: (1. - x ** 2.) ** (alpha - 0.5)
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=-1., right=1., # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(-1., 1., 100)
# Here is the actual evaluation
Expand All @@ -57,7 +57,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -67,5 +67,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
20 changes: 10 additions & 10 deletions demos/demo5.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@
alpha = 2.
beta = 5.
# The first way of doing it is by directly supplying the weight function.
wf = lambda(x): (1. - x) ** alpha * (1 + x) ** beta
wf = lambda x: (1. - x) ** alpha * (1 + x) ** beta
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=-1., right=1., # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(-1., 1., 100)
# Here is the actual evaluation
Expand All @@ -58,7 +58,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -68,5 +68,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
20 changes: 10 additions & 10 deletions demos/demo6.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
degree = 4

# The first way of doing it is by directly supplying the weight function
wf = lambda(x): 1.
wf = lambda x: 1.
# Construct it:
p = orthpol.OrthogonalPolynomial(degree,
left=0., right=1., # Domain
wf=wf)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(0., 1., 100)
# Here is the actual evaluation
Expand All @@ -55,7 +55,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -65,5 +65,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
18 changes: 9 additions & 9 deletions demos/demo7.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
p = orthpol.OrthogonalPolynomial(degree, rv=rv)
# An orthogonal polynomial is though of as a function.
# Here is how to get the number of inputs and outputs of that function
print 'Number of inputs:', p.num_input
print 'Number of outputs:', p.num_output
print('Number of inputs:', p.num_input)
print('Number of outputs:', p.num_output)
# Test if the polynomials are normalized (i.e., their norm is 1.):
print 'Is normalized:', p.is_normalized
print('Is normalized:', p.is_normalized)
# Get the degree of the polynomial:
print 'Polynomial degree:', p.degree
print('Polynomial degree:', p.degree)
# Get the alpha-beta recursion coefficients:
print 'Alpha:', p.alpha
print 'Beta:', p.beta
print('Alpha:', p.alpha)
print('Beta:', p.beta)
# The following should print a description of the polynomial
print str(p)
print(str(p))
# Now you can evaluate the polynomial at any points you want:
X = np.linspace(0., 1., 100)
# Here is the actual evaluation
Expand All @@ -55,7 +55,7 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel('$p_i(x)$', fontsize=16)
plt.legend(['$p_{%d}(x)$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to continue...'
print('Close the window to continue...')
plt.show()
# You may also compute the derivatives of the polynomials:
dphi = p.d(X)
Expand All @@ -65,5 +65,5 @@
plt.xlabel('$x$', fontsize=16)
plt.ylabel(r'$\frac{dp_i(x)}{dx}$', fontsize=16)
plt.legend([r'$\frac{p_{%d}(x)}{dx}$' % i for i in range(p.num_output)], loc='best')
print 'Close the window to end demo...'
print('Close the window to end demo...')
plt.show()
Loading