1
# This file is part of PyFFTW.
3
# Copyright (C) 2009 Jochen Schroeder
4
# Email: jschrod@berlios.de
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.
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.
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/>.
19
from lib import lib, PyFile_AsFile
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.$libname$_export_wisdom_to_file(c_fp)
28
def export_wisdom_to_string():
29
"""Returns a string with the accumulated wisdom"""
30
return lib.$libname$_export_wisdom_to_string()
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.$libname$_import_wisdom_from_file(c_fp):
39
raise IOError, "Could not read wisdom from file %s" % filename
41
def import_wisdom_from_string(wisdom):
42
"""Import wisdom from the given string"""
43
if lib.$libname$_import_wisdom_from_string(wisdom):
46
raise Exception, "Could not read wisdom from string: %s" % wisdom
48
def import_system_wisdom():
49
"""Import the system wisdom, this lives under /etc/fftw/wisdom on
51
if lib.$libname$_import_system_wisdom():
54
raise IOError, "Could not read system wisdom. On GNU/Linux and Unix "\
55
"system wisdom is located in /etc/fftw/wisdom"
58
"""Clear all wisdom"""
59
lib.$libname$_forget_wisdom()