__init__.py :  » Math » SciPy » scipy » scipy » lib » blas » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Math » SciPy 
SciPy » scipy » scipy » lib » blas » __init__.py
#
# BLAS wrappers
#

from info import __doc__

__all__ = ['fblas','cblas','get_blas_funcs']

import fblas
import cblas

_use_force_cblas = 1
if hasattr(cblas,'empty_module'):
    cblas = fblas
    _use_force_cblas = 0
elif hasattr(fblas,'empty_module'):
    fblas = cblas

_type_conv = {'f':'s', 'd':'d', 'F':'c', 'D':'z'} # 'd' will be default for 'i',..
_inv_type_conv = {'s':'f','d':'d','c':'F','z':'D'}

def get_blas_funcs(names,arrays=(),debug=0):
    """Return available BLAS function objects with names.
    arrays are used to determine the optimal prefix of
    BLAS routines."""
    ordering = []
    for i in range(len(arrays)):
        t = arrays[i].dtype.char
        if t not in _type_conv:
            t = 'd'
        ordering.append((t,i))
    if ordering:
        ordering.sort()
        required_prefix = _type_conv[ordering[0][0]]
    else:
        required_prefix = 'd'
    dtypechar = _inv_type_conv[required_prefix]
    # Default lookup:
    if ordering and arrays[ordering[0][1]].flags['FORTRAN']:
        # prefer Fortran code for leading array with column major order
        m1,m2 = fblas,cblas
    else:
        # in all other cases, C code is preferred
        m1,m2 = cblas,fblas
    funcs = []
    for name in names:
        if name=='ger' and dtypechar in 'FD':
            name = 'gerc'
        elif name in ('dotc', 'dotu') and dtypechar in 'fd':
            name = 'dot'
        func_name = required_prefix + name
        if name == 'nrm2' and dtypechar == 'D':
            func_name = 'dznrm2'
        elif name == 'nrm2' and dtypechar == 'F':
            func_name = 'scnrm2'
        func = getattr(m1,func_name,None)
        if func is None:
            func = getattr(m2,func_name)
            func.module_name = m2.__name__.split('.')[-1]
        else:
            func.module_name = m1.__name__.split('.')[-1]
        func.prefix = required_prefix
        func.dtypechar = dtypechar
        funcs.append(func)
    return tuple(funcs)

from numpy.testing import Tester
test = Tester().test
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.