Squashed 'third_party/blasfeo/' content from commit 2a828ca

Change-Id: If1c3caa4799b2d4eb287ef83fa17043587ef07a3
git-subtree-dir: third_party/blasfeo
git-subtree-split: 2a828ca5442108c4c58e4b42b061a0469043f6ea
diff --git a/include/blasfeo_common.h b/include/blasfeo_common.h
new file mode 100644
index 0000000..3f95c91
--- /dev/null
+++ b/include/blasfeo_common.h
@@ -0,0 +1,146 @@
+/**************************************************************************************************
+*                                                                                                 *
+* This file is part of BLASFEO.                                                                   *
+*                                                                                                 *
+* BLASFEO -- BLAS For Embedded Optimization.                                                      *
+* Copyright (C) 2016-2017 by Gianluca Frison.                                                     *
+* Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl.              *
+* All rights reserved.                                                                            *
+*                                                                                                 *
+* HPMPC 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.                              *
+*                                                                                                 *
+* HPMPC 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 HPMPC; if not, write to the Free Software                                    *
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                  *
+*                                                                                                 *
+* Author: Gianluca Frison, giaf (at) dtu.dk                                                       *
+*                          gianluca.frison (at) imtek.uni-freiburg.de                             *
+*                                                                                                 *
+**************************************************************************************************/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#ifndef BLASFEO_COMMON
+#define BLASFEO_COMMON
+
+
+
+#if defined(LA_HIGH_PERFORMANCE)
+
+#include "blasfeo_block_size.h"
+
+// matrix structure
+struct d_strmat
+	{
+	int m; // rows
+	int n; // cols
+	int pm; // packed number or rows
+	int cn; // packed number or cols
+	double *pA; // pointer to a pm*pn array of doubles, the first is aligned to cache line size
+	double *dA; // pointer to a min(m,n) (or max???) array of doubles
+	int use_dA; // flag to tell if dA can be used
+	int memory_size; // size of needed memory
+	};
+
+struct s_strmat
+	{
+	int m; // rows
+	int n; // cols
+	int pm; // packed number or rows
+	int cn; // packed number or cols
+	float *pA; // pointer to a pm*pn array of floats, the first is aligned to cache line size
+	float *dA; // pointer to a min(m,n) (or max???) array of floats
+	int use_dA; // flag to tell if dA can be used
+	int memory_size; // size of needed memory
+	};
+
+// vector structure
+struct d_strvec
+	{
+	int m; // size
+	int pm; // packed size
+	double *pa; // pointer to a pm array of doubles, the first is aligned to cache line size
+	int memory_size; // size of needed memory
+	};
+
+struct s_strvec
+	{
+	int m; // size
+	int pm; // packed size
+	float *pa; // pointer to a pm array of floats, the first is aligned to cache line size
+	int memory_size; // size of needed memory
+	};
+
+#define DMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(D_PS-1)))*(sA)->cn+(aj)*D_PS+((ai)&(D_PS-1))])
+#define SMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[((ai)-((ai)&(S_PS-1)))*(sA)->cn+(aj)*S_PS+((ai)&(S_PS-1))])
+#define DVECEL_LIBSTR(sa,ai) ((sa)->pa[ai])
+#define SVECEL_LIBSTR(sa,ai) ((sa)->pa[ai])
+
+#elif defined(LA_BLAS) | defined(LA_REFERENCE)
+
+// matrix structure
+struct d_strmat
+	{
+	int m; // rows
+	int n; // cols
+	double *pA; // pointer to a m*n array of doubles
+	double *dA; // pointer to a min(m,n) (or max???) array of doubles
+	int use_dA; // flag to tell if dA can be used
+	int memory_size; // size of needed memory
+	};
+
+struct s_strmat
+	{
+	int m; // rows
+	int n; // cols
+	float *pA; // pointer to a m*n array of floats
+	float *dA; // pointer to a min(m,n) (or max???) array of floats
+	int use_dA; // flag to tell if dA can be used
+	int memory_size; // size of needed memory
+	};
+
+// vector structure
+struct d_strvec
+	{
+	int m; // size
+	double *pa; // pointer to a m array of doubles, the first is aligned to cache line size
+	int memory_size; // size of needed memory
+	};
+
+struct s_strvec
+	{
+	int m; // size
+	float *pa; // pointer to a m array of floats, the first is aligned to cache line size
+	int memory_size; // size of needed memory
+	};
+
+#define DMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m])
+#define SMATEL_LIBSTR(sA,ai,aj) ((sA)->pA[(ai)+(aj)*(sA)->m])
+#define DVECEL_LIBSTR(sa,ai) ((sa)->pa[ai])
+#define SVECEL_LIBSTR(sa,ai) ((sa)->pa[ai])
+
+#else
+
+#error : wrong LA choice
+
+#endif
+
+#endif  // BLASFEO_COMMON
+
+
+#ifdef __cplusplus
+}
+#endif