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