1
2 #define START 0
3
4 #include "TMV.h"
5 #include "TMV_Band.h"
6 #include "TMV_Test.h"
7 #include "TMV_Test_2.h"
8 #include "TMV_TestBandArith.h"
9
10 #include "TMV_TestMatrixDivArith.h"
11
12 template <class T>
TestBandDiv_B1(tmv::DivType dt)13 void TestBandDiv_B1(tmv::DivType dt)
14 {
15 const int N = 10;
16
17 std::vector<tmv::BandMatrixView<T> > b;
18 std::vector<tmv::BandMatrixView<std::complex<T> > > cb;
19 MakeBandList(b,cb);
20
21 tmv::Matrix<T> a1(N,N);
22 for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(3+i-2*j);
23 a1.diag().addToAll(T(10)*N);
24 a1 /= T(10);
25 tmv::Matrix<std::complex<T> > ca1 = a1 * std::complex<T>(3,-4);
26 tmv::MatrixView<T> a1v = a1.view();
27 tmv::MatrixView<std::complex<T> > ca1v = ca1.view();
28
29 #if (XTEST & 2)
30 tmv::Matrix<T> a3 = a1.colRange(0,N/2);
31 tmv::Matrix<std::complex<T> > ca3 = ca1.colRange(0,N/2);
32 tmv::Matrix<T> a4 = a1.rowRange(0,N/2);
33 tmv::Matrix<std::complex<T> > ca4 = ca1.rowRange(0,N/2);
34 tmv::Matrix<T> a5 = a1.colRange(0,0);
35 tmv::Matrix<std::complex<T> > ca5 = ca1.colRange(0,0);
36 tmv::Matrix<T> a6 = a1.rowRange(0,0);
37 tmv::Matrix<std::complex<T> > ca6 = ca1.rowRange(0,0);
38
39 tmv::MatrixView<T> a3v = a3.view();
40 tmv::MatrixView<std::complex<T> > ca3v = ca3.view();
41 tmv::MatrixView<T> a4v = a4.view();
42 tmv::MatrixView<std::complex<T> > ca4v = ca4.view();
43 tmv::MatrixView<T> a5v = a5.view();
44 tmv::MatrixView<std::complex<T> > ca5v = ca5.view();
45 tmv::MatrixView<T> a6v = a6.view();
46 tmv::MatrixView<std::complex<T> > ca6v = ca6.view();
47
48 #endif
49
50 for(size_t i=START;i<b.size();i++) {
51 if (showstartdone)
52 std::cout<<"Start B1 loop: i = "<<i<<"\nbi = "<<tmv::TMV_Text(b[i])<<
53 " "<<b[i]<<std::endl;
54 tmv::BandMatrixView<T> bi = b[i];
55 tmv::BandMatrixView<std::complex<T> > cbi = cb[i];
56 if (dt == tmv::LU && !bi.isSquare()) continue;
57
58 bi.saveDiv();
59 cbi.saveDiv();
60
61 TestMatrixDivArith1(dt,bi,a1v,cbi,ca1v,"SquareMatrix/Band");
62 #if (XTEST & 2)
63 TestMatrixDivArith1(dt,bi,a3v,cbi,ca3v,"NonSquareMatrix/Band");
64 TestMatrixDivArith1(dt,bi,a4v,cbi,ca4v,"NonSquareMatrix/Band");
65 TestMatrixDivArith1(dt,bi,a5v,cbi,ca5v,"DegenerateMatrix/Band");
66 TestMatrixDivArith1(dt,bi,a6v,cbi,ca6v,"DegenerateMatrix/Band");
67 #endif
68 }
69 }
70
71 #ifdef TEST_DOUBLE
72 template void TestBandDiv_B1<double>(tmv::DivType dt);
73 #endif
74 #ifdef TEST_FLOAT
75 template void TestBandDiv_B1<float>(tmv::DivType dt);
76 #endif
77 #ifdef TEST_LONGDOUBLE
78 template void TestBandDiv_B1<long double>(tmv::DivType dt);
79 #endif
80