BLASReplacement.cpp
Go to the documentation of this file.
00001 /*
00002  *      This file is part of qpOASES.
00003  *
00004  *      qpOASES -- An Implementation of the Online Active Set Strategy.
00005  *      Copyright (C) 2007-2011 by Hans Joachim Ferreau, Andreas Potschka,
00006  *      Christian Kirches et al. All rights reserved.
00007  *
00008  *      qpOASES is free software; you can redistribute it and/or
00009  *      modify it under the terms of the GNU Lesser General Public
00010  *      License as published by the Free Software Foundation; either
00011  *      version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *      qpOASES is distributed in the hope that it will be useful,
00014  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  *      See the GNU Lesser General Public License for more details.
00017  *
00018  *      You should have received a copy of the GNU Lesser General Public
00019  *      License along with qpOASES; if not, write to the Free Software
00020  *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  */
00023 
00024 
00034 #include <qpOASES/PrivateUtils.hpp>
00035 
00036 USING_NAMESPACE_QPOASES
00037 
00038 extern "C" void dgemm_ ( const char *TRANSA, const char *TRANSB,
00039                 const unsigned long *M, const unsigned long *N, const unsigned long *K,
00040                 const double *ALPHA, const double *A, const unsigned long *LDA, const double *B, const unsigned long *LDB,
00041                 const double *BETA, double *C, const unsigned long *LDC)
00042 {
00043         unsigned int i, j, k;
00044 
00045         if (isExactlyZero(*BETA))
00046                 for (k = 0; k < *N; k++)
00047                         for (j = 0; j < *M; j++)
00048                                 C[j+(*LDC)*k] = 0.0;
00049         else if (isExactlyMinusOne(*BETA))
00050                 for (k = 0; k < *N; k++)
00051                         for (j = 0; j < *M; j++)
00052                                 C[j+(*LDC)*k] = -C[j+(*LDC)*k];
00053         else if (!isExactlyOne(*BETA))
00054                 for (k = 0; k < *N; k++)
00055                         for (j = 0; j < *M; j++)
00056                                 C[j+(*LDC)*k] *= *BETA;
00057 
00058         if (TRANSA[0] == 'N')
00059                 if (isExactlyOne(*ALPHA))
00060                         for (k = 0; k < *N; k++)
00061                                 for (j = 0; j < *M; j++)
00062                                         for (i = 0; i < *K; i++)
00063                                                 C[j+(*LDC)*k] += A[j+(*LDA)*i] * B[i+(*LDB)*k];
00064                 else if (isExactlyMinusOne(*ALPHA))
00065                         for (k = 0; k < *N; k++)
00066                                 for (j = 0; j < *M; j++)
00067                                         for (i = 0; i < *K; i++)
00068                                                 C[j+(*LDC)*k] -= A[j+(*LDA)*i] * B[i+(*LDB)*k];
00069                 else
00070                         for (k = 0; k < *N; k++)
00071                                 for (j = 0; j < *M; j++)
00072                                         for (i = 0; i < *K; i++)
00073                                                 C[j+(*LDC)*k] += *ALPHA * A[j+(*LDA)*i] * B[i+(*LDB)*k];
00074         else
00075                 if (isExactlyOne(*ALPHA))
00076                         for (k = 0; k < *N; k++)
00077                                 for (j = 0; j < *M; j++)
00078                                         for (i = 0; i < *K; i++)
00079                                                 C[j+(*LDC)*k] += A[i+(*LDA)*j] * B[i+(*LDB)*k];
00080                 else if (isExactlyMinusOne(*ALPHA))
00081                         for (k = 0; k < *N; k++)
00082                                 for (j = 0; j < *M; j++)
00083                                         for (i = 0; i < *K; i++)
00084                                                 C[j+(*LDC)*k] -= A[i+(*LDA)*j] * B[i+(*LDB)*k];
00085                 else
00086                         for (k = 0; k < *N; k++)
00087                                 for (j = 0; j < *M; j++)
00088                                         for (i = 0; i < *K; i++)
00089                                                 C[j+(*LDC)*k] += *ALPHA * A[i+(*LDA)*j] * B[i+(*LDB)*k];
00090 }
00091 
00092 extern "C" void sgemm_ ( const char *TRANSA, const char *TRANSB,
00093                 const unsigned long *M, const unsigned long *N, const unsigned long *K,
00094                 const float *ALPHA, const float *A, const unsigned long *LDA, const float *B, const unsigned long *LDB,
00095                 const float *BETA, float *C, const unsigned long *LDC)
00096 {
00097         unsigned int i, j, k;
00098 
00099         if (isExactlyZero(*BETA))
00100                 for (k = 0; k < *N; k++)
00101                         for (j = 0; j < *M; j++)
00102                                 C[j+(*LDC)*k] = 0.0;
00103         else if (isExactlyMinusOne(*BETA))
00104                 for (k = 0; k < *N; k++)
00105                         for (j = 0; j < *M; j++)
00106                                 C[j+(*LDC)*k] = -C[j+(*LDC)*k];
00107         else if (!isExactlyOne(*BETA))
00108                 for (k = 0; k < *N; k++)
00109                         for (j = 0; j < *M; j++)
00110                                 C[j+(*LDC)*k] *= *BETA;
00111 
00112         if (TRANSA[0] == 'N')
00113                 if (isExactlyOne(*ALPHA))
00114                         for (k = 0; k < *N; k++)
00115                                 for (j = 0; j < *M; j++)
00116                                         for (i = 0; i < *K; i++)
00117                                                 C[j+(*LDC)*k] += A[j+(*LDA)*i] * B[i+(*LDB)*k];
00118                 else if (isExactlyMinusOne(*ALPHA))
00119                         for (k = 0; k < *N; k++)
00120                                 for (j = 0; j < *M; j++)
00121                                         for (i = 0; i < *K; i++)
00122                                                 C[j+(*LDC)*k] -= A[j+(*LDA)*i] * B[i+(*LDB)*k];
00123                 else
00124                         for (k = 0; k < *N; k++)
00125                                 for (j = 0; j < *M; j++)
00126                                         for (i = 0; i < *K; i++)
00127                                                 C[j+(*LDC)*k] += *ALPHA * A[j+(*LDA)*i] * B[i+(*LDB)*k];
00128         else
00129                 if (isExactlyOne(*ALPHA))
00130                         for (k = 0; k < *N; k++)
00131                                 for (j = 0; j < *M; j++)
00132                                         for (i = 0; i < *K; i++)
00133                                                 C[j+(*LDC)*k] += A[i+(*LDA)*j] * B[i+(*LDB)*k];
00134                 else if (isExactlyMinusOne(*ALPHA))
00135                         for (k = 0; k < *N; k++)
00136                                 for (j = 0; j < *M; j++)
00137                                         for (i = 0; i < *K; i++)
00138                                                 C[j+(*LDC)*k] -= A[i+(*LDA)*j] * B[i+(*LDB)*k];
00139                 else
00140                         for (k = 0; k < *N; k++)
00141                                 for (j = 0; j < *M; j++)
00142                                         for (i = 0; i < *K; i++)
00143                                                 C[j+(*LDC)*k] += *ALPHA * A[i+(*LDA)*j] * B[i+(*LDB)*k];
00144 }
00145 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:36:47