test_gesv.py :  » Math » SciPy » scipy » scipy » lib » lapack » tests » 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 » lapack » tests » test_gesv.py
import numpy as np
from numpy.testing import TestCase,assert_array_almost_equal,dec,\
                          assert_equal

from common import FUNCS_TP,FLAPACK_IS_EMPTY,CLAPACK_IS_EMPTY,FUNCS_FLAPACK,\
                   FUNCS_CLAPACK, PREC

A = np.array([[1,2,3],[2,2,3],[3,3,6]])
B = np.array([[10,-1,1],[-1,8,-2],[1,-2,6]])

class TestSygv(TestCase):
    def _test_base(self, func, lang, itype):
        tp = FUNCS_TP[func]
        a = A.astype(tp)
        b = B.astype(tp)
        if lang == 'C':
            f = FUNCS_CLAPACK[func]
        elif lang == 'F':
            f = FUNCS_FLAPACK[func]
        else:
            raise ValueError("Lang %s ??" % lang)

        w, v, info = f(a, b, itype=itype)

        assert not info, `info`
        for i in range(3):
            if itype == 1:
                assert_array_almost_equal(np.dot(a,v[:,i]), w[i]*np.dot(b,v[:,i]),
                                          decimal=PREC[tp])
            elif itype == 2:
                assert_array_almost_equal(np.dot(a,np.dot(b,v[:,i])), w[i]*v[:,i],
                                          decimal=PREC[tp])
            elif itype == 3:
                assert_array_almost_equal(np.dot(b,np.dot(a,v[:,i])),
                                          w[i]*v[:,i], decimal=PREC[tp] - 1)
            else:
                raise ValueError, `itype`

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_ssygv_1(self):
        self._test_base('ssygv', 'F', 1)

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_ssygv_2(self):
        self._test_base('ssygv', 'F', 2)

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_ssygv_3(self):
        self._test_base('ssygv', 'F', 3)

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_dsygv_1(self):
        self._test_base('dsygv', 'F', 1)

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_dsygv_2(self):
        self._test_base('dsygv', 'F', 2)

    @dec.skipif(FLAPACK_IS_EMPTY, "Flapack empty, skip flapack test")
    def test_dsygv_3(self):
        self._test_base('dsygv', 'F', 3)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["ssygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_ssygv_1(self):
        self._test_base('ssygv', 'C', 1)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["ssygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_ssygv_2(self):
        self._test_base('ssygv', 'C', 2)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["ssygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_ssygv_3(self):
        self._test_base('ssygv', 'C', 3)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["dsygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_dsygv_1(self):
        self._test_base('dsygv', 'C', 1)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["dsygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_dsygv_2(self):
        self._test_base('dsygv', 'C', 2)

    @dec.skipif(CLAPACK_IS_EMPTY or not FUNCS_CLAPACK["dsygv"],
                "Clapack empty, skip flapack test")
    def test_clapack_dsygv_3(self):
        self._test_base('dsygv', 'C', 3)

if __name__=="__main__":
    run_module_suite()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.