~daniele-bigoni/spectraltoolbox/hotfixes

« back to all changes in this revision

Viewing changes to SpectralToolbox/SpectralND.py

  • Committer: Daniele Bigoni
  • Date: 2016-01-26 14:39:24 UTC
  • mfrom: (34.1.1 hotfix-PolyND)
  • Revision ID: dabi@limitcycle.it-20160126143924-pb8bgvw8gh74z0ye
merged hotfix for PolyND

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
# Author: Daniele Bigoni
25
25
#
26
26
 
27
 
import logging
28
 
 
29
 
import logging
 
27
import sys
 
28
import logging
 
29
import itertools
30
30
 
31
31
import numpy as np
32
 
 
33
32
from scipy.misc import comb
34
33
 
35
 
import sys
36
 
 
37
 
import itertools
38
 
 
39
34
import Spectral1D
40
35
 
41
36
def MultiIndex(d,N):
117
112
        self.polys = polys
118
113
        self.DIM = len(self.polys)
119
114
 
120
 
    def Quadrature(self, Ns, quadTypes=None,left=None,right=None,end=None, normed=False, warnings=True):
 
115
    def Quadrature(self, Ns, quadTypes=None,left=None,right=None,end=None, norm=True, warnings=True):
121
116
        """
122
117
        GaussQuadrature(): computes the tensor product of the Guass Points and weights
123
118
        
124
119
        Syntax:
125
 
            ``(x,w) = GaussQuadrature(Ns, [quadTypes=None], [normed=False],[warnings=True])``
 
120
            ``(x,w) = GaussQuadrature(Ns, [quadTypes=None], [norm=True],[warnings=True])``
126
121
        
127
122
        Input:
128
123
            * ``Ns`` = (list,int) n-dimensional list with the order of approximation of each polynomial
130
125
            * ``left``: (list,float) list of left values used by ORTHPOL for Gauss-Lobatto rules (the dimensions where the value is not used can be set to anything)
131
126
            * ``right``: (list,float) list of left values used by ORTHPOL for Gauss-Lobatto rules (the dimensions where the value is not used can be set to anything)
132
127
            * ``end``: (list,float) list of left values used by ORTHPOL for Gauss-Radau rules (the dimensions where the value is not used can be set to anything)
133
 
            * ``normed`` = (optional,boolean) whether the weights will be normalized or not
 
128
            * ``norm`` = (optional,boolean) whether the weights will be normalized or not
134
129
            * ``warnings`` = (optional,boolean) set whether to ask for confirmation when it is required to allocate more then 100Mb of memory
135
130
        
136
131
        Output:
192
187
            if (opt ==  'q'):
193
188
                return        
194
189
        
195
 
        x,w = self.polys[0].Quadrature(Ns[0],quadType=quadTypes[0],left=left[0],right=right[0],end=end[0],normed=normed)
 
190
        x,w = self.polys[0].Quadrature(Ns[0],quadType=quadTypes[0],left=left[0],right=right[0],end=end[0],norm=norm)
196
191
        wKron = w
197
192
        xs = [x]
198
193
        for i in range(1,self.DIM):
199
 
            x,w = self.polys[i].Quadrature(Ns[i],quadType=quadTypes[i],left=left[i],right=right[i],end=end[i],normed=normed)
 
194
            x,w = self.polys[i].Quadrature(Ns[i],quadType=quadTypes[i],left=left[i],right=right[i],end=end[i],norm=norm)
200
195
            wKron = np.kron(wKron, w)
201
196
            xs.append(x)
202
197
        xKron = np.asarray(list(itertools.product(*xs)))
203
198
        
204
199
        return (xKron, wKron)
205
200
    
206
 
    def GaussQuadrature(self, Ns, normed=False, warnings=True):
 
201
    def GaussQuadrature(self, Ns, norm=True, warnings=True):
207
202
        """
208
203
        GaussQuadrature(): computes the tensor product of the Guass Points and weights
209
204
        
210
205
        Syntax:
211
 
            ``(x,w) = GaussQuadrature(Ns, [normed=False],[warnings=True])``
 
206
            ``(x,w) = GaussQuadrature(Ns, [norm=True],[warnings=True])``
212
207
        
213
208
        Input:
214
209
            * ``Ns`` = (list,int) n-dimensional list with the order of approximation of each polynomial
215
 
            * ``normed`` = (optional,boolean) whether the weights will be normalized or not
 
210
            * ``norm`` = (optional,boolean) whether the weights will be normalized or not
216
211
            * ``warnings`` = (optional,boolean) set whether to ask for confirmation when it is required to allocate more then 100Mb of memory
217
212
        
218
213
        Output:
257
252
            if (opt ==  'q'):
258
253
                return
259
254
                
260
 
        x,w = self.polys[0].GaussQuadrature(Ns[0],normed=normed)
 
255
        x,w = self.polys[0].GaussQuadrature(Ns[0],norm=norm)
261
256
        wKron = w
262
257
        xs = [x]
263
258
        for i in range(1,self.DIM):
264
 
            x,w = self.polys[i].GaussQuadrature(Ns[i],normed=normed)
 
259
            x,w = self.polys[i].GaussQuadrature(Ns[i],norm=norm)
265
260
            wKron = np.kron(wKron, w)
266
261
            xs.append(x)
267
262
        xKron = np.asarray(list(itertools.product(*xs)))
268
263
        
269
264
        return (xKron, wKron)
270
265
    
271
 
    def GaussLobattoQuadrature(self, Ns, normed=False, warnings=True):
 
266
    def GaussLobattoQuadrature(self, Ns, norm=True, warnings=True):
272
267
        """
273
268
        GaussLobattoQuadrature(): computes the tensor product of the Guass Lobatto Points and weights
274
269
        
275
270
        Syntax:
276
 
            ``(x,w) = GaussLobattoQuadrature(Ns,[normed=False],[warnings=True])``
 
271
            ``(x,w) = GaussLobattoQuadrature(Ns,[norm=True],[warnings=True])``
277
272
        
278
273
        Input:
279
274
            * ``Ns`` = (list,int) n-dimensional list with the order of approximation of each polynomial
280
 
            * ``normed`` = (optional,boolean) whether the weights will be normalized or not
 
275
            * ``norm`` = (optional,boolean) whether the weights will be normalized or not
281
276
            * ``warnings`` = (optional,boolean) set whether to ask for confirmation when it is required to allocate more then 100Mb of memory
282
277
        
283
278
        Output: