Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2011 Drew Keppel 2 # 3 # This program is free software; you can redistribute it and/or modify it 4 # under the terms of the GNU General Public License as published by the 5 # Free Software Foundation; either version 2 of the License, or (at your 6 # option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11 # Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License along 14 # with this program; if not, write to the Free Software Foundation, Inc., 15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 1618 """ 19 A function to project waveforms given as rows of T onto the basis 20 vectors given as rows of U and normalized by the singular values S. 21 This returns the reconstruction coefficients associated with these 22 waveforms, basis vectors, and singular values. 23 """ 24 V = [] 25 for idx,t in enumerate(T): 26 print >> sys.stderr, "\r\ttemplate %i/%i"%(idx+1,len(T)), 27 template_copy = numpy.array([t for x in range(len(S))]) 28 V.append((U*template_copy).sum(axis=1)/S) 29 print >> sys.stderr, '' 30 return numpy.array(V)3133 """ 34 A function to reconstruct waveforms from the reconstruction 35 coefficients V, singular values S, and basis vectors U. The top n 36 basis vectors are used for the reconstruction. If the normalize flag 37 is set to True, the waveforms are normalized when before being 38 returned. 39 """ 40 U = numpy.dot(numpy.diag(S), U)[:n,:] 41 T = numpy.tensordot(V[:,:n], U, axes=1) 42 if normalize: 43 for idx,t in enumerate(T): 44 T[idx] /= sum(t*t)**.5 45 return T46
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Dec 12 01:21:51 2017 | http://epydoc.sourceforge.net |