strict_lower.hpp 1.21 KB
Newer Older
1
// Software License for MTL
2
//
3
4
5
6
7
// Copyright (c) 2007 The Trustees of Indiana University.
//               2008 Dresden University of Technology and the Trustees of Indiana University.
//               2010 SimuNova UG (haftungsbeschränkt), www.simunova.com.
// All rights reserved.
// Authors: Peter Gottschling and Andrew Lumsdaine
8
//
9
// This file is part of the Matrix Template Library
10
//
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// See also license.mtl.txt in the distribution.

#ifndef MTL_MATRIX_STRICT_LOWER_INCLUDE
#define MTL_MATRIX_STRICT_LOWER_INCLUDE

namespace mtl { namespace matrix {

namespace traits {

    template <typename Matrix>
    struct strict_lower
    {
	typedef typename traits::bands<Matrix>::type type;
    };
}

///  Strict lower triangular matrix
28
template <typename Matrix>
29
30
31
32
33
34
35
typename traits::strict_lower<Matrix>::type
inline strict_lower(const Matrix& A)
{
    return bands(A, std::numeric_limits<long>::min(), 0);
}

/// Triangle-lower starting at off-diagonoal \p d (for compatibility with matlib)
36
template <typename Matrix>
37
38
39
40
41
42
43
44
45
46
typename traits::strict_lower<Matrix>::type
inline tril(const Matrix& A, long d= 0)
{
    return bands(A, std::numeric_limits<long>::min(), d+1);
}


}} // namespace mtl::matrix

#endif // MTL_MATRIX_STRICT_LOWER_INCLUDE