Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
x, w = vals.real, vecs[0, :]**2
indices = np.argsort(x)
x, w = x[indices], w[indices]
else:
x, w = np.array([a[d, 0]]), np.array([1.])
X.append(x)
W.append(w)
if dim==1:
x = np.array(X).reshape(1,o[0])
w = np.array(W).reshape(o[0])
else:
x = cp.utils.combine(X).T
w = np.prod(cp.utils.combine(W), -1)
assert len(x)==dim
assert len(w)==len(x.T)
return x, w
if not composite.shape:
composite = composite.flatten()
if len(composite.shape)==1:
composite = np.array([composite])
composite = ((composite.T-lo)/(up-lo)).T
if growth:
q = [_clenshaw_curtis(2**N[i]-1*(N[i]==0), composite[i]) \
for i in range(dim)]
else:
q = [_clenshaw_curtis(N[i], composite[i]) for i in range(dim)]
x = [_[0] for _ in q]
w = [_[1] for _ in q]
x = cp.utils.combine(x, part=part).T
w = cp.utils.combine(w, part=part)
x = ((up-lo)*x.T + lo).T
w = np.prod(w*(up-lo), -1)
assert len(x)==dim
assert len(w)==len(x.T)
return x, w
X : np.ndarray
Abscissas
W : np.ndarray
Weights
"""
if len(dist) > 1:
if isinstance(n, int):
xw = [gp(n, d) for d in dist]
else:
xw = [gp(n[i], dist[i]) for i in range(len(dist))]
x = [_[0][0] for _ in xw]
w = [_[1] for _ in xw]
x = chaospy.utils.combine(x).T
w = np.prod(chaospy.utils.combine(w), -1)
return x, w
n = [1,3,7,15,31,63,127,255,511][n]
x = np.zeros(n)
w = np.zeros(n)
if n==1 :
x[0] = 0.0e+00
w[0] = 2.0e+00
elif n==3 :
x, w = vals.real, vecs[0, :]**2
indices = np.argsort(x)
x, w = x[indices], w[indices]
else:
x, w = np.array([a[d, 0]]), np.array([1.])
X.append(x)
W.append(w)
if dim==1:
x = np.array(X).reshape(1,o[0])
w = np.array(W).reshape(o[0])
else:
x = cp.utils.combine(X).T
w = np.prod(cp.utils.combine(W), -1)
assert len(x)==dim
assert len(w)==len(x.T)
return x, w
def tensprod_rule(N, part=None):
N = N*np.ones(dim, int)
q = [funcs[i](N[i]) \
for i in range(dim)]
x = [np.array(_[0]).flatten() for _ in q]
x = cp.utils.combine(x, part=part).T
w = [np.array(_[1]).flatten() for _ in q]
w = np.prod(cp.utils.combine(w, part=part), -1)
return x, w
tensprod_rule = cp.utils.lazy_eval(tensprod_rule)
----------
N : int
Upper quadrature order
Returns
-------
samples : np.ndarray
The quadrature nodes with `samples.shape=(D,K)` where
`D=len(dist)` and `K` is the number of nodes.
"""
dim = len(self.dist)
if self.sparse==0 or self.scheme in (3,4,5,6):
X = self.segment(N)
if self.scheme in (1,2):
X = combine((X,)*dim)
out = self.trans(X)
else:
out = []
for i in xrange(be.terms(N-self.sparse, dim),
be.terms(N, dim)):
I = be.multi_index(i, dim)
out.append(combine([self.segment(n) for n in I]))
out = self.trans(np.concatenate(out, 0))
return out.T
composite = composite.flatten()
if len(composite.shape)==1:
composite = np.array([composite])
composite = ((composite.T-lo)/(up-lo)).T
if growth:
q = [_clenshaw_curtis(2**N[i]-1*(N[i]==0), composite[i]) \
for i in range(dim)]
else:
q = [_clenshaw_curtis(N[i], composite[i]) for i in range(dim)]
x = [_[0] for _ in q]
w = [_[1] for _ in q]
x = cp.utils.combine(x, part=part).T
w = cp.utils.combine(w, part=part)
x = ((up-lo)*x.T + lo).T
w = np.prod(w*(up-lo), -1)
assert len(x)==dim
assert len(w)==len(x.T)
return x, w
`D=len(dist)` and `K` is the number of nodes.
"""
dim = len(self.dist)
if self.sparse==0 or self.scheme in (3,4,5,6):
X = self.segment(N)
if self.scheme in (1,2):
X = combine((X,)*dim)
out = self.trans(X)
else:
out = []
for i in xrange(be.terms(N-self.sparse, dim),
be.terms(N, dim)):
I = be.multi_index(i, dim)
out.append(combine([self.segment(n) for n in I]))
out = self.trans(np.concatenate(out, 0))
return out.T