1 /*
2  *   Copyright (c) 2012, Michael Lehn, Klaus Pototzky
3  *
4  *   All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *   1) Redistributions of source code must retain the above copyright
11  *      notice, this list of conditions and the following disclaimer.
12  *   2) Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in
14  *      the documentation and/or other materials provided with the
15  *      distribution.
16  *   3) Neither the name of the FLENS development group nor the names of
17  *      its contributors may be used to endorse or promote products derived
18  *      from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef CXXLAPACK_INTERFACE_ORM2L_TCC
34 #define CXXLAPACK_INTERFACE_ORM2L_TCC 1
35 
36 #include <iostream>
37 #include "xflens/cxxlapack/interface/interface.h"
38 #include "xflens/cxxlapack/netlib/netlib.h"
39 
40 namespace cxxlapack {
41 
42 template <typename IndexType>
43 IndexType
orm2l(char side,char trans,IndexType m,IndexType n,IndexType k,const float * A,IndexType ldA,float * C,IndexType ldC,float * work)44 orm2l(char                  side,
45       char                  trans,
46       IndexType             m,
47       IndexType             n,
48       IndexType             k,
49       const float           *A,
50       IndexType             ldA,
51       float                 *C,
52       IndexType             ldC,
53       float                 *work)
54 {
55     CXXLAPACK_DEBUG_OUT("sorm2l");
56 
57     IndexType info;
58     LAPACK_IMPL(sorm2l)(&side,
59                         &trans,
60                         &m,
61                         &n,
62                         &k,
63                         A,
64                         &ldA,
65                         C,
66                         &ldC,
67                         work,
68                         &info);
69 #   ifndef NDEBUG
70     if (info<0) {
71         std::cerr << "info = " << info << std::endl;
72     }
73 #   endif
74     ASSERT(info>=0);
75     return info;
76 }
77 
78 template <typename IndexType>
79 IndexType
orm2l(char side,char trans,IndexType m,IndexType n,IndexType k,const double * A,IndexType ldA,double * C,IndexType ldC,double * work)80 orm2l(char                  side,
81       char                  trans,
82       IndexType             m,
83       IndexType             n,
84       IndexType             k,
85       const double          *A,
86       IndexType             ldA,
87       double                *C,
88       IndexType             ldC,
89       double                *work)
90 {
91     CXXLAPACK_DEBUG_OUT("dorm2l");
92 
93     IndexType info;
94     LAPACK_IMPL(dorm2l)(&side,
95                         &trans,
96                         &m,
97                         &n,
98                         &k,
99                         A,
100                         &ldA,
101                         C,
102                         &ldC,
103                         work,
104                         &info);
105 #   ifndef NDEBUG
106     if (info<0) {
107         std::cerr << "info = " << info << std::endl;
108     }
109 #   endif
110     ASSERT(info>=0);
111     return info;
112 }
113 
114 } // namespace cxxlapack
115 
116 #endif // CXXLAPACK_INTERFACE_ORM2L_TCC
117