qpOASES-3.2.0/src/LAPACKReplacement.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
35 #include <qpOASES/Utils.hpp>
36 
37 
38 extern "C" void dpotrf_( const char *uplo, const unsigned long *_n, double *a,
39  const unsigned long *_lda, long *info
40  )
41 {
42  double sum;
43  long i, j, k;
44  long n = (long)(*_n);
45  long lda = (long)(*_lda);
46 
47  for( i=0; i<n; ++i )
48  {
49  /* j == i */
50  sum = a[i + lda*i];
51 
52  for( k=(i-1); k>=0; --k )
53  sum -= a[k+lda*i] * a[k+lda*i];
54 
55  if ( sum > 0.0 )
56  a[i+lda*i] = REFER_NAMESPACE_QPOASES getSqrt( sum );
57  else
58  {
59  a[0] = sum; /* tunnel negative diagonal element to caller */
60  if (info != 0)
61  *info = (long)i+1;
62  return;
63  }
64 
65  for( j=(i+1); j<n; ++j )
66  {
67  sum = a[j*lda + i];
68 
69  for( k=(i-1); k>=0; --k )
70  sum -= a[k+lda*i] * a[k+lda*j];
71 
72  a[i+lda*j] = sum / a[i+lda*i];
73  }
74  }
75  if (info != 0)
76  *info = 0;
77 }
78 
79 
80 extern "C" void spotrf_( const char *uplo, const unsigned long *_n, float *a,
81  const unsigned long *_lda, long *info
82  )
83 {
84  float sum;
85  long i, j, k;
86  long n = (long)(*_n);
87  long lda = (long)(*_lda);
88 
89  for( i=0; i<n; ++i )
90  {
91  /* j == i */
92  sum = a[i + lda*i];
93 
94  for( k=(i-1); k>=0; --k )
95  sum -= a[k+lda*i] * a[k+lda*i];
96 
97  if ( sum > 0.0 )
98  a[i+lda*i] = (float)(REFER_NAMESPACE_QPOASES getSqrt( sum ));
99  else
100  {
101  a[0] = sum; /* tunnel negative diagonal element to caller */
102  if (info != 0)
103  *info = (long)i+1;
104  return;
105  }
106 
107  for( j=(i+1); j<n; ++j )
108  {
109  sum = a[j*lda + i];
110 
111  for( k=(i-1); k>=0; --k )
112  sum -= a[k+lda*i] * a[k+lda*j];
113 
114  a[i+lda*j] = sum / a[i+lda*i];
115  }
116  }
117  if (info != 0)
118  *info = 0;
119 }
120 
121 extern "C" void dtrtrs_( const char *UPLO, const char *TRANS, const char *DIAG,
122  const unsigned long *N, const unsigned long *NRHS,
123  double *A, const unsigned long *LDA, double *B, const unsigned long *LDB, long *INFO
124  )
125 {
126  ; /* Dummy. If SQProblemSchur is to be used, system LAPACK must be used */
127 }
128 
129 extern "C" void strtrs_( const char *UPLO, const char *TRANS, const char *DIAG,
130  const unsigned long *N, const unsigned long *NRHS,
131  float *A, const unsigned long *LDA, float *B, const unsigned long *LDB, long *INFO
132  )
133 {
134  ; /* Dummy. If SQProblemSchur is to be used, system LAPACK must be used */
135 }
136 
137 extern "C" void dtrcon_( const char *NORM, const char *UPLO, const char *DIAG,
138  const unsigned long *N, double *A, const unsigned long *LDA,
139  double *RCOND, double *WORK, const unsigned long *IWORK, long *INFO
140  )
141 {
142  ; /* Dummy. If SQProblemSchur is to be used, system LAPACK must be used */
143 }
144 
145 extern "C" void strcon_( const char *NORM, const char *UPLO, const char *DIAG,
146  const unsigned long *N, float *A, const unsigned long *LDA,
147  float *RCOND, float *WORK, const unsigned long *IWORK, long *INFO
148  )
149 {
150  ; /* Dummy. If SQProblemSchur is to be used, system LAPACK must be used */
151 }
#define N
void strtrs_(const char *UPLO, const char *TRANS, const char *DIAG, const unsigned long *N, const unsigned long *NRHS, float *A, const unsigned long *LDA, float *B, const unsigned long *LDB, long *INFO)
real_t getSqrt(real_t x)
void dpotrf_(const char *uplo, const unsigned long *_n, double *a, const unsigned long *_lda, long *info)
void dtrcon_(const char *NORM, const char *UPLO, const char *DIAG, const unsigned long *N, double *A, const unsigned long *LDA, double *RCOND, double *WORK, const unsigned long *IWORK, long *INFO)
#define WORK(I)
void spotrf_(const char *uplo, const unsigned long *_n, float *a, const unsigned long *_lda, long *info)
void dtrtrs_(const char *UPLO, const char *TRANS, const char *DIAG, const unsigned long *N, const unsigned long *NRHS, double *A, const unsigned long *LDA, double *B, const unsigned long *LDB, long *INFO)
void strcon_(const char *NORM, const char *UPLO, const char *DIAG, const unsigned long *N, float *A, const unsigned long *LDA, float *RCOND, float *WORK, const unsigned long *IWORK, long *INFO)
BEGIN_NAMESPACE_QPOASES const char *const TRANS


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:47