Package fftw3f :: Module wisdom
[hide private]
[frames] | no frames]

Source Code for Module fftw3f.wisdom

 1  #   This file is part of PyFFTW. 
 2  # 
 3  #    Copyright (C) 2009 Jochen Schroeder 
 4  #    Email: jschrod@berlios.de 
 5  # 
 6  #    PyFFTW is free software: you can redistribute it and/or modify 
 7  #    it under the terms of the GNU General Public License as published by 
 8  #    the Free Software Foundation, either version 3 of the License, or 
 9  #    (at your option) any later version. 
10  # 
11  #    PyFFTW is distributed in the hope that it will be useful, 
12  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  #    GNU General Public License for more details. 
15  # 
16  #    You should have received a copy of the GNU General Public License 
17  #    along with PyFFTW.  If not, see <http://www.gnu.org/licenses/>. 
18   
19  from lib import lib, PyFile_AsFile 
20   
21 -def export_wisdom_to_file(filename):
22 """Export accumulated wisdom to file given by the filename""" 23 fp = open(filename, 'a') 24 c_fp = PyFile_AsFile(fp) 25 lib.fftwf_export_wisdom_to_file(c_fp) 26 fp.close()
27
28 -def export_wisdom_to_string():
29 """Returns a string with the accumulated wisdom""" 30 return lib.fftwf_export_wisdom_to_string()
31
32 -def import_wisdom_from_file(filename):
33 """Imports wisdom from the file given by the filename""" 34 fp = open(filename,'r') 35 c_fp = PyFile_AsFile(fp) 36 if lib.fftwf_import_wisdom_from_file(c_fp): 37 pass 38 else: 39 raise IOError, "Could not read wisdom from file %s" % filename
40
41 -def import_wisdom_from_string(wisdom):
42 """Import wisdom from the given string""" 43 if lib.fftwf_import_wisdom_from_string(wisdom): 44 pass 45 else: 46 raise Exception, "Could not read wisdom from string: %s" % wisdom
47
48 -def import_system_wisdom():
49 """Import the system wisdom, this lives under /etc/fftw/wisdom on 50 Unix/Linux systems""" 51 if lib.fftwf_import_system_wisdom(): 52 pass 53 else: 54 raise IOError, "Could not read system wisdom. On GNU/Linux and Unix "\ 55 "system wisdom is located in /etc/fftw/wisdom"
56
57 -def forget_wisdom():
58 """Clear all wisdom""" 59 lib.fftwf_forget_wisdom()
60