File: test_blas.py

package info (click to toggle)
cvxopt 1.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 2,800 kB
  • sloc: ansic: 23,229; python: 11,991; makefile: 75; sh: 7
file content (23 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import unittest
from cvxopt import blas, matrix

class TestBLAS(unittest.TestCase):

    def setUp(self):
        from cvxopt import blas, matrix
        self.a = matrix([1.0,2.0,3.0,4.0])
        self.b = matrix([2.5,-2.0,-4.0,1.0,3.0]) 

    def assertEqualLists(self,L1,L2):
        self.assertEqual(len(L1),len(L2))
        for u,v in zip(L1,L2): self.assertEqual(u,v)

    def assertAlmostEqualLists(self,L1,L2,places=7):
        self.assertEqual(len(L1),len(L2))
        for u,v in zip(L1,L2): self.assertAlmostEqual(u,v,places)

    def test_iamax(self):
        self.assertTrue(blas.iamax(self.a) == 3)
        self.assertTrue(blas.iamax(self.b) == 2)
        self.assertTrue(blas.iamax(self.b,inc=2) == 1)
        self.assertTrue(blas.iamax(self.b,offset=1) == 1)