User | Revision | Line number | New contents of line |
ykuroda |
0:13a5d365ba16
|
1
|
/*
|
ykuroda |
0:13a5d365ba16
|
2
|
Copyright (c) 2011, Intel Corporation. All rights reserved.
|
ykuroda |
0:13a5d365ba16
|
3
|
|
ykuroda |
0:13a5d365ba16
|
4
|
Redistribution and use in source and binary forms, with or without modification,
|
ykuroda |
0:13a5d365ba16
|
5
|
are permitted provided that the following conditions are met:
|
ykuroda |
0:13a5d365ba16
|
6
|
|
ykuroda |
0:13a5d365ba16
|
7
|
* Redistributions of source code must retain the above copyright notice, this
|
ykuroda |
0:13a5d365ba16
|
8
|
list of conditions and the following disclaimer.
|
ykuroda |
0:13a5d365ba16
|
9
|
* Redistributions in binary form must reproduce the above copyright notice,
|
ykuroda |
0:13a5d365ba16
|
10
|
this list of conditions and the following disclaimer in the documentation
|
ykuroda |
0:13a5d365ba16
|
11
|
and/or other materials provided with the distribution.
|
ykuroda |
0:13a5d365ba16
|
12
|
* Neither the name of Intel Corporation nor the names of its contributors may
|
ykuroda |
0:13a5d365ba16
|
13
|
be used to endorse or promote products derived from this software without
|
ykuroda |
0:13a5d365ba16
|
14
|
specific prior written permission.
|
ykuroda |
0:13a5d365ba16
|
15
|
|
ykuroda |
0:13a5d365ba16
|
16
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
ykuroda |
0:13a5d365ba16
|
17
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
ykuroda |
0:13a5d365ba16
|
18
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
ykuroda |
0:13a5d365ba16
|
19
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
ykuroda |
0:13a5d365ba16
|
20
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
ykuroda |
0:13a5d365ba16
|
21
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
ykuroda |
0:13a5d365ba16
|
22
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
ykuroda |
0:13a5d365ba16
|
23
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
ykuroda |
0:13a5d365ba16
|
24
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
ykuroda |
0:13a5d365ba16
|
25
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
ykuroda |
0:13a5d365ba16
|
26
|
|
ykuroda |
0:13a5d365ba16
|
27
|
********************************************************************************
|
ykuroda |
0:13a5d365ba16
|
28
|
* Content : Eigen bindings to Intel(R) MKL
|
ykuroda |
0:13a5d365ba16
|
29
|
* LU decomposition with partial pivoting based on LAPACKE_?getrf function.
|
ykuroda |
0:13a5d365ba16
|
30
|
********************************************************************************
|
ykuroda |
0:13a5d365ba16
|
31
|
*/
|
ykuroda |
0:13a5d365ba16
|
32
|
|
ykuroda |
0:13a5d365ba16
|
33
|
#ifndef EIGEN_PARTIALLU_LAPACK_H
|
ykuroda |
0:13a5d365ba16
|
34
|
#define EIGEN_PARTIALLU_LAPACK_H
|
ykuroda |
0:13a5d365ba16
|
35
|
|
ykuroda |
0:13a5d365ba16
|
36
|
#include "Eigen/src/Core/util/MKL_support.h"
|
ykuroda |
0:13a5d365ba16
|
37
|
|
ykuroda |
0:13a5d365ba16
|
38
|
namespace Eigen {
|
ykuroda |
0:13a5d365ba16
|
39
|
|
ykuroda |
0:13a5d365ba16
|
40
|
namespace internal {
|
ykuroda |
0:13a5d365ba16
|
41
|
|
ykuroda |
0:13a5d365ba16
|
42
|
/** \internal Specialization for the data types supported by MKL */
|
ykuroda |
0:13a5d365ba16
|
43
|
|
ykuroda |
0:13a5d365ba16
|
44
|
#define EIGEN_MKL_LU_PARTPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \
|
ykuroda |
0:13a5d365ba16
|
45
|
template<int StorageOrder> \
|
ykuroda |
0:13a5d365ba16
|
46
|
struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \
|
ykuroda |
0:13a5d365ba16
|
47
|
{ \
|
ykuroda |
0:13a5d365ba16
|
48
|
/* \internal performs the LU decomposition in-place of the matrix represented */ \
|
ykuroda |
0:13a5d365ba16
|
49
|
static lapack_int blocked_lu(lapack_int rows, lapack_int cols, EIGTYPE* lu_data, lapack_int luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \
|
ykuroda |
0:13a5d365ba16
|
50
|
{ \
|
ykuroda |
0:13a5d365ba16
|
51
|
EIGEN_UNUSED_VARIABLE(maxBlockSize);\
|
ykuroda |
0:13a5d365ba16
|
52
|
lapack_int matrix_order, first_zero_pivot; \
|
ykuroda |
0:13a5d365ba16
|
53
|
lapack_int m, n, lda, *ipiv, info; \
|
ykuroda |
0:13a5d365ba16
|
54
|
EIGTYPE* a; \
|
ykuroda |
0:13a5d365ba16
|
55
|
/* Set up parameters for ?getrf */ \
|
ykuroda |
0:13a5d365ba16
|
56
|
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
|
ykuroda |
0:13a5d365ba16
|
57
|
lda = luStride; \
|
ykuroda |
0:13a5d365ba16
|
58
|
a = lu_data; \
|
ykuroda |
0:13a5d365ba16
|
59
|
ipiv = row_transpositions; \
|
ykuroda |
0:13a5d365ba16
|
60
|
m = rows; \
|
ykuroda |
0:13a5d365ba16
|
61
|
n = cols; \
|
ykuroda |
0:13a5d365ba16
|
62
|
nb_transpositions = 0; \
|
ykuroda |
0:13a5d365ba16
|
63
|
\
|
ykuroda |
0:13a5d365ba16
|
64
|
info = LAPACKE_##MKLPREFIX##getrf( matrix_order, m, n, (MKLTYPE*)a, lda, ipiv ); \
|
ykuroda |
0:13a5d365ba16
|
65
|
\
|
ykuroda |
0:13a5d365ba16
|
66
|
for(int i=0;i<m;i++) { ipiv[i]--; if (ipiv[i]!=i) nb_transpositions++; } \
|
ykuroda |
0:13a5d365ba16
|
67
|
\
|
ykuroda |
0:13a5d365ba16
|
68
|
eigen_assert(info >= 0); \
|
ykuroda |
0:13a5d365ba16
|
69
|
/* something should be done with nb_transpositions */ \
|
ykuroda |
0:13a5d365ba16
|
70
|
\
|
ykuroda |
0:13a5d365ba16
|
71
|
first_zero_pivot = info; \
|
ykuroda |
0:13a5d365ba16
|
72
|
return first_zero_pivot; \
|
ykuroda |
0:13a5d365ba16
|
73
|
} \
|
ykuroda |
0:13a5d365ba16
|
74
|
};
|
ykuroda |
0:13a5d365ba16
|
75
|
|
ykuroda |
0:13a5d365ba16
|
76
|
EIGEN_MKL_LU_PARTPIV(double, double, d)
|
ykuroda |
0:13a5d365ba16
|
77
|
EIGEN_MKL_LU_PARTPIV(float, float, s)
|
ykuroda |
0:13a5d365ba16
|
78
|
EIGEN_MKL_LU_PARTPIV(dcomplex, MKL_Complex16, z)
|
ykuroda |
0:13a5d365ba16
|
79
|
EIGEN_MKL_LU_PARTPIV(scomplex, MKL_Complex8, c)
|
ykuroda |
0:13a5d365ba16
|
80
|
|
ykuroda |
0:13a5d365ba16
|
81
|
} // end namespace internal
|
ykuroda |
0:13a5d365ba16
|
82
|
|
ykuroda |
0:13a5d365ba16
|
83
|
} // end namespace Eigen
|
ykuroda |
0:13a5d365ba16
|
84
|
|
ykuroda |
0:13a5d365ba16
|
85
|
#endif // EIGEN_PARTIALLU_LAPACK_H |