qpOASES-3.2.0/src/BLASReplacement.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 dgemm_( const char *TRANSA, const char *TRANSB,
39  const unsigned long *M, const unsigned long *N, const unsigned long *K,
40  const double *ALPHA, const double *A, const unsigned long *LDA, const double *B, const unsigned long *LDB,
41  const double *BETA, double *C, const unsigned long *LDC
42  )
43 {
44  unsigned long i, j, k;
45 
47  for (k = 0; k < *N; k++)
48  for (j = 0; j < *M; j++)
49  C[j+(*LDC)*k] = 0.0;
50  else if ( REFER_NAMESPACE_QPOASES isEqual(*BETA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
51  for (k = 0; k < *N; k++)
52  for (j = 0; j < *M; j++)
53  C[j+(*LDC)*k] = -C[j+(*LDC)*k];
55  for (k = 0; k < *N; k++)
56  for (j = 0; j < *M; j++)
57  C[j+(*LDC)*k] *= *BETA;
58 
59  if (TRANSA[0] == 'N')
60  if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
61  for (k = 0; k < *N; k++)
62  for (j = 0; j < *M; j++)
63  for (i = 0; i < *K; i++)
64  C[j+(*LDC)*k] += A[j+(*LDA)*i] * B[i+(*LDB)*k];
65  else if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
66  for (k = 0; k < *N; k++)
67  for (j = 0; j < *M; j++)
68  for (i = 0; i < *K; i++)
69  C[j+(*LDC)*k] -= A[j+(*LDA)*i] * B[i+(*LDB)*k];
70  else
71  for (k = 0; k < *N; k++)
72  for (j = 0; j < *M; j++)
73  for (i = 0; i < *K; i++)
74  C[j+(*LDC)*k] += *ALPHA * A[j+(*LDA)*i] * B[i+(*LDB)*k];
75  else
76  if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
77  for (k = 0; k < *N; k++)
78  for (j = 0; j < *M; j++)
79  for (i = 0; i < *K; i++)
80  C[j+(*LDC)*k] += A[i+(*LDA)*j] * B[i+(*LDB)*k];
81  else if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
82  for (k = 0; k < *N; k++)
83  for (j = 0; j < *M; j++)
84  for (i = 0; i < *K; i++)
85  C[j+(*LDC)*k] -= A[i+(*LDA)*j] * B[i+(*LDB)*k];
86  else
87  for (k = 0; k < *N; k++)
88  for (j = 0; j < *M; j++)
89  for (i = 0; i < *K; i++)
90  C[j+(*LDC)*k] += *ALPHA * A[i+(*LDA)*j] * B[i+(*LDB)*k];
91 }
92 
93 extern "C" void sgemm_( const char *TRANSA, const char *TRANSB,
94  const unsigned long *M, const unsigned long *N, const unsigned long *K,
95  const float *ALPHA, const float *A, const unsigned long *LDA, const float *B, const unsigned long *LDB,
96  const float *BETA, float *C, const unsigned long *LDC
97  )
98 {
99  unsigned long i, j, k;
100 
102  for (k = 0; k < *N; k++)
103  for (j = 0; j < *M; j++)
104  C[j+(*LDC)*k] = 0.0;
105  else if ( REFER_NAMESPACE_QPOASES isEqual(*BETA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
106  for (k = 0; k < *N; k++)
107  for (j = 0; j < *M; j++)
108  C[j+(*LDC)*k] = -C[j+(*LDC)*k];
110  for (k = 0; k < *N; k++)
111  for (j = 0; j < *M; j++)
112  C[j+(*LDC)*k] *= *BETA;
113 
114  if (TRANSA[0] == 'N')
115  if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
116  for (k = 0; k < *N; k++)
117  for (j = 0; j < *M; j++)
118  for (i = 0; i < *K; i++)
119  C[j+(*LDC)*k] += A[j+(*LDA)*i] * B[i+(*LDB)*k];
120  else if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
121  for (k = 0; k < *N; k++)
122  for (j = 0; j < *M; j++)
123  for (i = 0; i < *K; i++)
124  C[j+(*LDC)*k] -= A[j+(*LDA)*i] * B[i+(*LDB)*k];
125  else
126  for (k = 0; k < *N; k++)
127  for (j = 0; j < *M; j++)
128  for (i = 0; i < *K; i++)
129  C[j+(*LDC)*k] += *ALPHA * A[j+(*LDA)*i] * B[i+(*LDB)*k];
130  else
131  if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
132  for (k = 0; k < *N; k++)
133  for (j = 0; j < *M; j++)
134  for (i = 0; i < *K; i++)
135  C[j+(*LDC)*k] += A[i+(*LDA)*j] * B[i+(*LDB)*k];
136  else if ( REFER_NAMESPACE_QPOASES isEqual(*ALPHA,-1.0) == REFER_NAMESPACE_QPOASES BT_TRUE )
137  for (k = 0; k < *N; k++)
138  for (j = 0; j < *M; j++)
139  for (i = 0; i < *K; i++)
140  C[j+(*LDC)*k] -= A[i+(*LDA)*j] * B[i+(*LDB)*k];
141  else
142  for (k = 0; k < *N; k++)
143  for (j = 0; j < *M; j++)
144  for (i = 0; i < *K; i++)
145  C[j+(*LDC)*k] += *ALPHA * A[i+(*LDA)*j] * B[i+(*LDB)*k];
146 }
#define N
BooleanType isZero(real_t x, real_t TOL=ZERO)
#define BT_TRUE
Definition: acado_types.hpp:47
#define BT_FALSE
Definition: acado_types.hpp:49
void sgemm_(const char *TRANSA, const char *TRANSB, const unsigned long *M, const unsigned long *N, const unsigned long *K, const float *ALPHA, const float *A, const unsigned long *LDA, const float *B, const unsigned long *LDB, const float *BETA, float *C, const unsigned long *LDC)
BooleanType isEqual(real_t x, real_t y, real_t TOL=ZERO)
void dgemm_(const char *TRANSA, const char *TRANSB, const unsigned long *M, const unsigned long *N, const unsigned long *K, const double *ALPHA, const double *A, const unsigned long *LDA, const double *B, const unsigned long *LDB, const double *BETA, double *C, const unsigned long *LDC)


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