2
# Author: Pearu Peterson, March 2002
5
__all__ = ['get_blas_funcs']
9
# The following ensures that possibly missing flavor (C or Fortran) is
10
# replaced with the available one. If none is available, exception
11
# is raised at the first attempt to use the resources.
15
if hasattr(cblas,'empty_module'):
17
elif hasattr(fblas,'empty_module'):
20
_type_conv = {'f':'s', 'd':'d', 'F':'c', 'D':'z'} # 'd' will be default for 'i',..
21
_inv_type_conv = {'s':'f','d':'d','c':'F','z':'D'}
23
def get_blas_funcs(names,arrays=(),debug=0):
24
"""Return available BLAS function objects with names.
25
arrays are used to determine the optimal prefix of
28
for i in range(len(arrays)):
29
t = arrays[i].typecode()
30
if not _type_conv.has_key(t): t = 'd'
31
ordering.append((t,i))
34
required_prefix = _type_conv[ordering[0][0]]
37
typecode = _inv_type_conv[required_prefix]
39
if ordering and fblas.has_column_major_storage(arrays[ordering[0][1]]):
40
# prefer Fortran code for leading array with column major order
43
# in all other cases, C code is preferred
47
if name=='ger' and typecode in 'FD':
49
func_name = required_prefix + name
50
func = getattr(m1,func_name,None)
52
func = getattr(m2,func_name)
53
func.module_name = string.split(m2.__name__,'.')[-1]
55
func.module_name = string.split(m1.__name__,'.')[-1]
56
func.prefix = required_prefix
57
func.typecode = typecode