1 #include <iostream>
2 ///
3 /// With header __flens.cxx__ all of FLENS gets included.
4 ///
5 /// :links: __flens.cxx__ -> file:flens/flens.cxx
6 #include <flens/flens.cxx>
7
8 using namespace std;
9 using namespace flens;
10
11 typedef double T;
12
13 int
14 main()
15 {
16 ///
17 /// Define some convenient typedefs for the matrix/vector types
18 /// of our system of linear equations.
19 ///
20 typedef GeMatrix<FullStorage<T> > Matrix;
21 typedef DenseVector<Array<T> > Vector;
22
23 ///
24 /// We also need an extra vector type for the pivots. The type of the
25 /// pivots is taken for the system matrix.
26 ///
27 typedef Matrix::IndexType IndexType;
28 typedef DenseVector<Array<IndexType> > IndexVector;
29
30 ///
31 /// Define an underscore operator for convenient matrix slicing
32 ///
33 const Underscore<IndexType> _;
34
35 ///
36 /// Set up the baby problem ...
37 ///
38 const IndexType m = 4,
39 n = 5;
40
41 Matrix Ab(m, n);
42 IndexVector piv(m);
43
44 Ab = 2, 3, -1, 0, 20,
45 -6, -5, 0, 2, -33,
46 2, -5, 6, -6, -43,
47 4, 6, 2, -3, 49;
48
49 cout << "Ab = " << Ab << endl;
50
51 ///
52 /// Compute the $LU$ factorization with __lapack::trf__
53 ///
54 lapack::trf(Ab, piv);
55
56 ///
57 /// Solve the system of linear equation $Ax =B$ using __blas::sm__
58 ///
59 const auto A = Ab(_,_(1,m));
60 auto B = Ab(_,_(m+1,n));
61
62 blas::sm(Left, NoTrans, T(1), A.upper(), B);
63
64 cout << "X = " << B << endl;
65 }
66
67 ///
68 /// :links: __lapack::trf__ -> file:flens/lapack/gesv/trf.h
69 /// __blas::sm__ -> file:flens/blas/level3/sm.h
70 ///
2 ///
3 /// With header __flens.cxx__ all of FLENS gets included.
4 ///
5 /// :links: __flens.cxx__ -> file:flens/flens.cxx
6 #include <flens/flens.cxx>
7
8 using namespace std;
9 using namespace flens;
10
11 typedef double T;
12
13 int
14 main()
15 {
16 ///
17 /// Define some convenient typedefs for the matrix/vector types
18 /// of our system of linear equations.
19 ///
20 typedef GeMatrix<FullStorage<T> > Matrix;
21 typedef DenseVector<Array<T> > Vector;
22
23 ///
24 /// We also need an extra vector type for the pivots. The type of the
25 /// pivots is taken for the system matrix.
26 ///
27 typedef Matrix::IndexType IndexType;
28 typedef DenseVector<Array<IndexType> > IndexVector;
29
30 ///
31 /// Define an underscore operator for convenient matrix slicing
32 ///
33 const Underscore<IndexType> _;
34
35 ///
36 /// Set up the baby problem ...
37 ///
38 const IndexType m = 4,
39 n = 5;
40
41 Matrix Ab(m, n);
42 IndexVector piv(m);
43
44 Ab = 2, 3, -1, 0, 20,
45 -6, -5, 0, 2, -33,
46 2, -5, 6, -6, -43,
47 4, 6, 2, -3, 49;
48
49 cout << "Ab = " << Ab << endl;
50
51 ///
52 /// Compute the $LU$ factorization with __lapack::trf__
53 ///
54 lapack::trf(Ab, piv);
55
56 ///
57 /// Solve the system of linear equation $Ax =B$ using __blas::sm__
58 ///
59 const auto A = Ab(_,_(1,m));
60 auto B = Ab(_,_(m+1,n));
61
62 blas::sm(Left, NoTrans, T(1), A.upper(), B);
63
64 cout << "X = " << B << endl;
65 }
66
67 ///
68 /// :links: __lapack::trf__ -> file:flens/lapack/gesv/trf.h
69 /// __blas::sm__ -> file:flens/blas/level3/sm.h
70 ///