@@ -528,8 +528,9 @@ def localize(self, i, **kwargs):
528528
529529 Examples
530530 --------
531- Visualize heat diffusion on a grid.
531+ Visualize heat diffusion on a grid by localizing the heat kernel .
532532
533+ >>> import matplotlib
533534 >>> N = 20
534535 >>> G = graphs.Grid2d(N)
535536 >>> G.estimate_lmax()
@@ -540,7 +541,7 @@ def localize(self, i, **kwargs):
540541 """
541542 s = np .zeros (self .G .N )
542543 s [i ] = 1
543- return np .sqrt (self .G .N ) * self .analysis (s , ** kwargs )
544+ return np .sqrt (self .G .N ) * self .filter (s , ** kwargs )
544545
545546 def approx (self , m , N ):
546547 r"""
@@ -662,37 +663,31 @@ def compute_frame(self, **kwargs):
662663
663664 Examples
664665 --------
665- >>>
666- >>> G = graphs.Logo()
666+ Filtering signals as a matrix multiplication.
667+
668+ >>> G = graphs.Sensor(N=1000, seed=42)
667669 >>> G.estimate_lmax()
670+ >>> f = filters.MexicanHat(G, Nf=6)
671+ >>> s = np.random.uniform(size=G.N)
668672 >>>
669- >>> f = filters.MexicanHat(G)
670673 >>> frame = f.compute_frame()
671- >>> print('{} nodes, matrix is {} x {}'.format(G.N, *frame.shape))
672- 1130 nodes, matrix is 1130 x 6780
673- >>>
674- >>> s = np.random.uniform(size=G.N)
675- >>> c1 = frame.T.dot(s)
676- >>> c2 = f.analysis(s)
674+ >>> frame.shape
675+ (1000, 1000, 6)
676+ >>> frame = frame.reshape(G.N, -1).T
677+ >>> s1 = np.dot(frame, s)
678+ >>> s1 = s1.reshape(G.N, 1, -1)
677679 >>>
678- >>> np.linalg.norm(c1 - c2) < 1e-10
680+ >>> s2 = f.filter(s)
681+ >>> np.all((s1 - s2) < 1e-10)
679682 True
680683
681684 """
682-
683- N = self .G .N
684-
685- if N > 2000 :
685+ if self .G .N > 2000 :
686686 _logger .warning ('Creating a big matrix, you can use other means.' )
687687
688- Ft = self .analysis (np .identity (N ), ** kwargs )
689- F = np .empty (Ft .T .shape )
690- tmpN = np .arange (N , dtype = int )
691-
692- for i in range (self .Nf ):
693- F [:, N * i + tmpN ] = Ft [N * i + tmpN ]
694-
695- return F
688+ # Filter one delta per vertex.
689+ s = np .identity (self .G .N )
690+ return self .filter (s , ** kwargs )
696691
697692 def can_dual (self ):
698693 r"""
0 commit comments