amino  1.0-beta2
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
clapack_impl.h
1 /* -*- mode: C; c-basic-offset: 4 -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2011-2012, Georgia Tech Research Corporation
5  * All rights reserved.
6  *
7  * Author(s): Neil T. Dantam <ntd@gatech.edu>
8  * Georgia Tech Humanoid Robotics Lab
9  * Under Direction of Prof. Mike Stilman <mstilman@cc.gatech.edu>
10  *
11  *
12  * This file is provided under the following "BSD-style" License:
13  *
14  *
15  * Redistribution and use in source and binary forms, with or
16  * without modification, are permitted provided that the following
17  * conditions are met:
18  *
19  * * Redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer.
21  *
22  * * Redistributions in binary form must reproduce the above
23  * copyright notice, this list of conditions and the following
24  * disclaimer in the documentation and/or other materials provided
25  * with the distribution.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
28  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
29  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39  * POSSIBILITY OF SUCH DAMAGE.
40  *
41  */
42 
43 #include "amino/def.h"
44 
49 static inline int AA_CLA_NAME(getrf)
50 ( int m, int n, AA_TYPE *A, int lda, int *ipiv ) {
51  int info = 0;
52  AA_LAPACK_NAME( getrf)
53  (&m, &n, A, &lda, ipiv, &info );
54  return info;
55 }
56 
61 static inline int AA_CLA_NAME(getri)
62 ( int n, AA_TYPE *A, int lda, int *ipiv, AA_TYPE *work, int lwork ) {
63  int info = 0;
64  AA_LAPACK_NAME( getri )
65  ( &n, A, &lda, ipiv, work, &lwork, &info );
66  return info;
67 }
68 
69 
70 static inline int AA_CLA_NAME(gesdd)
71 (char jobz, int m, int n,
72  AA_TYPE *A, int lda,
73  AA_TYPE *S,
74  AA_TYPE *U, int ldu,
75  AA_TYPE *VT, int ldvt,
76  AA_TYPE *work, int lwork,
77  int *iwork )
78 {
79  int info = 0;
80  AA_LAPACK_NAME(gesdd)( &jobz, &m, &n,
81  A, &lda,
82  S,
83  U, &ldu,
84  VT, &ldvt,
85  work, &lwork,
86  iwork, &info );
87  return info;
88 }
89 
90 
96 static inline int AA_CLA_NAME(geqrf)
97 ( int m, int n, AA_TYPE *A, int lda,
98  AA_TYPE *tau, AA_TYPE *work, int lwork )
99 {
100  int info = 0;
101  AA_LAPACK_NAME(geqrf)
102  (&m, &n, A, &lda, tau,
103  work, &lwork,
104  &info );
105  return info;
106 }
107 
108 static inline int AA_CLA_NAME(orgqr)
109 ( const int m, const int n, const int k,
110  AA_TYPE *A, const int lda, const AA_TYPE *tau,
111  AA_TYPE *work, const int lwork )
112 {
113  int info = 0;
114  AA_LAPACK_NAME(orgqr)(&m, &n, &k,
115  A, &lda, tau,
116  work, &lwork, &info);
117  return info;
118 }
119 
120 
121 static inline int AA_CLA_NAME(posv)
122 ( char uplo, int n, int nrhs,
123  AA_TYPE *A, int lda,
124  AA_TYPE *B, int ldb )
125 {
126  int info = 0;
127  AA_LAPACK_NAME(posv)(&uplo, &n, &nrhs,
128  A, &lda,
129  B, &ldb,
130  &info );
131  return info;
132 }
133 
135 static inline int AA_CLA_NAME(gelsd_smlsiz) () {
136  return aa_cla_ilaenv( 9, AA_LAPACK_PREFIX_STR
137  "GELSD", "", 0, 0, 0, 0 );
138 }
139 
141 static inline int AA_CLA_NAME(gelsd_nlvl)
142 ( int m, int n ) {
143  int minmn = AA_MIN(m,n);
144  int smlsiz = AA_CLA_NAME(gelsd_smlsiz)();
145  return (int)AA_MAX(0, 1 + log2( minmn / (1 + smlsiz)));
146 }
147 
149 static inline int AA_CLA_NAME(gelsd_miniwork)
150 ( int m, int n ) {
151  int minmn = AA_MIN(m,n);
152  int nlvl = AA_CLA_NAME(gelsd_nlvl)(m,n);
153  return AA_MAX(1,
154  3 * minmn * nlvl + 11 * minmn);
155 }
156 
161 static inline int AA_CLA_NAME(gelsd)
162 ( int m, int n, int nrhs,
163  AA_TYPE *A, int lda,
164  AA_TYPE *B, int ldb,
165  AA_TYPE *S, AA_TYPE *rcond, int *rank,
166  AA_TYPE *work, int lwork, int *iwork ) {
167  int info = 0;
168  AA_LAPACK_NAME( gelsd )
169  ( &m, &n, &nrhs, A, &lda, B, &ldb,
170  S, rcond, rank, work, &lwork, iwork, &info );
171  return info;
172 }
173 
178 static inline void AA_CLA_NAME(lacpy)
179 ( char uplo, int m, int n,
180  const AA_TYPE *A, int lda,
181  AA_TYPE *B, int ldb ) {
182  AA_LAPACK_NAME(lacpy) (&uplo, &m, &n,
183  A, &lda, B, &ldb );
184 }
185 
190 static inline void AA_CLA_NAME(laset)
191 ( char UPLO, int M, int N,
192  AA_TYPE ALPHA,
193  AA_TYPE BETA,
194  AA_TYPE *A, int LDA )
195 {
196  AA_LAPACK_NAME(laset) (&UPLO, &M, &N,
197  &ALPHA, &BETA,
198  A, &LDA);
199 }
200 
205 static inline AA_TYPE AA_CLA_NAME(lapy2)
206 ( AA_TYPE x, AA_TYPE y )
207 {
208  return AA_LAPACK_NAME(lapy2)(&x, &y);
209 }
210 
215 static inline AA_TYPE AA_CLA_NAME(lapy3)
216 ( AA_TYPE x, AA_TYPE y, AA_TYPE z )
217 {
218  return AA_LAPACK_NAME(lapy3)(&x, &y, &z);
219 }
220 
225 static inline void AA_CLA_NAME(laruv)
226 ( int iseed[4], int n, AA_TYPE *X )
227 {
228  AA_LAPACK_NAME(laruv) (iseed, &n, X);
229 }
230 
235 static inline void AA_CLA_NAME(larnv)
236 ( int idist, int iseed[4], int n, AA_TYPE *X )
237 {
238  AA_LAPACK_NAME(larnv) (&idist, iseed, &n, X);
239 }
240 
245 static inline int AA_CLA_NAME(lascl)
246 ( char TYPE, int KL, int KU,
247  AA_TYPE CFROM, AA_TYPE CTO,
248  int M, int N, AA_TYPE *A, int LDA ) {
249  int info = 0;
250  AA_LAPACK_NAME( lascl )
251  ( &TYPE, &KL, &KU, &CFROM, &CTO,
252  &M, &N, A, &LDA, &info );
253  return info;
254 }
255 
256 #if AA_TYPE == double
257 
261 static inline int AA_CLA_NAME(lag2s)
262 ( int M, int N,
263  double *A, int LDA,
264  float *SA, int LDSA ) {
265  int info = 0;
266  dlag2s_( &M, &N, A, &LDA, SA, &LDSA, &info);
267  return info;
268 }
269 
270 #endif // AA_TYPE == double
271 
272 #if AA_TYPE == float
273 
277 static inline int AA_CLA_NAME(lag2d)
278 ( int M, int N,
279  float * SA, int LDSA,
280  double *A, int LDA ) {
281  int info = 0;
282  slag2d_( &M, &N, SA, &LDSA, A, &LDA, &info );
283  return info;
284 }
285 
286 #endif // AA_TYPE == float
287 
288 #include "amino/undef.h"
#define AA_MIN(a, b)
minimum of a and b
Definition: math.h:69
#define AA_MAX(a, b)
maximum of a and b
Definition: math.h:63