// THIS IS AUTO-GENERATED BY minimath_generate.pl. DO NOT EDIT BY HAND

// This contains dot products, norms, basic vector arithmetic and multiplication

static inline double dot_vec(int n, const double* restrict a, const double* restrict b)
{
  double dot = 0.0;
  for(int i=0; i<n; i++)
    dot += a[i]*b[i];
  return dot;
}
static inline double norm2_vec(int n, const double* restrict a)
{
  double dot = 0.0;
  for(int i=0; i<n; i++)
    dot += a[i]*a[i];
  return dot;
}
// a + b -> vout
static inline void add_vec_vout(int n, const double* restrict a, const double* restrict b, double* restrict vout)
{
  for(int i=0; i<n; i++)
    vout[i] = a[i] + b[i];
}
// a - b -> vout
static inline void sub_vec_vout(int n, const double* restrict a, const double* restrict b, double* restrict vout)
{
  for(int i=0; i<n; i++)
    vout[i] = a[i] - b[i];
}
// a + scale*b -> vout
static inline void add_vec_vout_scaled(int n, const double* restrict a, const double* restrict b, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    vout[i] = a[i] + scale*b[i];
}
// a - scale*b -> vout
static inline void sub_vec_vout_scaled(int n, const double* restrict a, const double* restrict b, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    vout[i] = a[i] - scale*b[i];
}
// a + b -> a
static inline void add_vec(int n, double* restrict a, const double* restrict b)
{
  for(int i=0; i<n; i++)
    a[i] = a[i] + b[i];
}
// a - b -> a
static inline void sub_vec(int n, double* restrict a, const double* restrict b)
{
  for(int i=0; i<n; i++)
    a[i] = a[i] - b[i];
}
// a + scale*b -> a
static inline void add_vec_scaled(int n, double* restrict a, const double* restrict b, double scale)
{
  for(int i=0; i<n; i++)
    a[i] = a[i] + scale*b[i];
}
// a - scale*b -> a
static inline void sub_vec_scaled(int n, double* restrict a, const double* restrict b, double scale)
{
  for(int i=0; i<n; i++)
    a[i] = a[i] - scale*b[i];
}
// a + b -> + vaccum
static inline void add_vec_vaccum(int n, const double* restrict a, const double* restrict b, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    vaccum[i] += a[i] + b[i];
}
// a - b -> + vaccum
static inline void sub_vec_vaccum(int n, const double* restrict a, const double* restrict b, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    vaccum[i] += a[i] - b[i];
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22_vout(const double* restrict v, const double* restrict s, double* restrict vout)
{
  vout[0] = s[0]*v[0] + s[1]*v[1];
  vout[1] = s[1]*v[0] + s[2]*v[1];
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22(double* restrict v, const double* restrict s)
{
  double t[1] = {v[0]};
  v[0] = s[0]*t[0] + s[1]*v[1];
  v[1] = s[1]*t[0] + s[2]*v[1];
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22_vaccum(const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  vaccum[0] += s[0]*v[0] + s[1]*v[1];
  vaccum[1] += s[1]*v[0] + s[2]*v[1];
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22_vout_scaled(const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  vout[0] = scale * (s[0]*v[0] + s[1]*v[1]);
  vout[1] = scale * (s[1]*v[0] + s[2]*v[1]);
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22_scaled(double* restrict v, const double* restrict s, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (s[0]*t[0] + s[1]*v[1]);
  v[1] = scale * (s[1]*t[0] + s[2]*v[1]);
}
// 2-vector by symmetric 2x2
static inline void mul_vec2_sym22_vaccum_scaled(const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (s[0]*v[0] + s[1]*v[1]);
  vaccum[1] += scale * (s[1]*v[0] + s[2]*v[1]);
}

// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[2]*v[1];
  vout[1] = m[1]*v[0] + m[3]*v[1];
}
// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22(double* restrict v, const double* restrict m)
{
  double t[1] = {v[0]};
  v[0] = m[0]*t[0] + m[2]*v[1];
  v[1] = m[1]*t[0] + m[3]*v[1];
}
// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[2]*v[1];
  vaccum[1] += m[1]*v[0] + m[3]*v[1];
}
// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[2]*v[1]);
  vout[1] = scale * (m[1]*v[0] + m[3]*v[1]);
}
// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (m[0]*t[0] + m[2]*v[1]);
  v[1] = scale * (m[1]*t[0] + m[3]*v[1]);
}
// 2-vector by 2x2 matrix multiplication
static inline void mul_vec2_gen22_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[2]*v[1]);
  vaccum[1] += scale * (m[1]*v[0] + m[3]*v[1]);
}

// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1];
  vout[1] = mt[2]*v[0] + mt[3]*v[1];
}
// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t(double* restrict v, const double* restrict mt)
{
  double t[1] = {v[0]};
  v[0] = mt[0]*t[0] + mt[1]*v[1];
  v[1] = mt[2]*t[0] + mt[3]*v[1];
}
// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1];
  vaccum[1] += mt[2]*v[0] + mt[3]*v[1];
}
// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1]);
  vout[1] = scale * (mt[2]*v[0] + mt[3]*v[1]);
}
// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*v[1]);
  v[1] = scale * (mt[2]*t[0] + mt[3]*v[1]);
}
// 2-vector by 2x2-transposed matrix multiplication
static inline void mul_vec2_gen22t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1]);
  vaccum[1] += scale * (mt[2]*v[0] + mt[3]*v[1]);
}

// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[3]*v[1];
  vout[1] = m[1]*v[0] + m[4]*v[1];
  vout[2] = m[2]*v[0] + m[5]*v[1];
}
// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[3]*t[1];
  v[1] = m[1]*t[0] + m[4]*t[1];
  v[2] = m[2]*t[0] + m[5]*t[1];
}
// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[3]*v[1];
  vaccum[1] += m[1]*v[0] + m[4]*v[1];
  vaccum[2] += m[2]*v[0] + m[5]*v[1];
}
// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[3]*v[1]);
  vout[1] = scale * (m[1]*v[0] + m[4]*v[1]);
  vout[2] = scale * (m[2]*v[0] + m[5]*v[1]);
}
// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[3]*t[1]);
  v[1] = scale * (m[1]*t[0] + m[4]*t[1]);
  v[2] = scale * (m[2]*t[0] + m[5]*t[1]);
}
// 2-vector by 2x3 matrix multiplication
static inline void mul_vec2_gen23_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[3]*v[1]);
  vaccum[1] += scale * (m[1]*v[0] + m[4]*v[1]);
  vaccum[2] += scale * (m[2]*v[0] + m[5]*v[1]);
}

// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1];
  vout[1] = mt[2]*v[0] + mt[3]*v[1];
  vout[2] = mt[4]*v[0] + mt[5]*v[1];
}
// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1];
  v[1] = mt[2]*t[0] + mt[3]*t[1];
  v[2] = mt[4]*t[0] + mt[5]*t[1];
}
// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1];
  vaccum[1] += mt[2]*v[0] + mt[3]*v[1];
  vaccum[2] += mt[4]*v[0] + mt[5]*v[1];
}
// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1]);
  vout[1] = scale * (mt[2]*v[0] + mt[3]*v[1]);
  vout[2] = scale * (mt[4]*v[0] + mt[5]*v[1]);
}
// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1]);
  v[1] = scale * (mt[2]*t[0] + mt[3]*t[1]);
  v[2] = scale * (mt[4]*t[0] + mt[5]*t[1]);
}
// 2-vector by 3x2-transposed matrix multiplication
static inline void mul_vec2_gen32t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1]);
  vaccum[1] += scale * (mt[2]*v[0] + mt[3]*v[1]);
  vaccum[2] += scale * (mt[4]*v[0] + mt[5]*v[1]);
}

// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[4]*v[1];
  vout[1] = m[1]*v[0] + m[5]*v[1];
  vout[2] = m[2]*v[0] + m[6]*v[1];
  vout[3] = m[3]*v[0] + m[7]*v[1];
}
// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[4]*t[1];
  v[1] = m[1]*t[0] + m[5]*t[1];
  v[2] = m[2]*t[0] + m[6]*t[1];
  v[3] = m[3]*t[0] + m[7]*t[1];
}
// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[4]*v[1];
  vaccum[1] += m[1]*v[0] + m[5]*v[1];
  vaccum[2] += m[2]*v[0] + m[6]*v[1];
  vaccum[3] += m[3]*v[0] + m[7]*v[1];
}
// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[4]*v[1]);
  vout[1] = scale * (m[1]*v[0] + m[5]*v[1]);
  vout[2] = scale * (m[2]*v[0] + m[6]*v[1]);
  vout[3] = scale * (m[3]*v[0] + m[7]*v[1]);
}
// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[4]*t[1]);
  v[1] = scale * (m[1]*t[0] + m[5]*t[1]);
  v[2] = scale * (m[2]*t[0] + m[6]*t[1]);
  v[3] = scale * (m[3]*t[0] + m[7]*t[1]);
}
// 2-vector by 2x4 matrix multiplication
static inline void mul_vec2_gen24_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[4]*v[1]);
  vaccum[1] += scale * (m[1]*v[0] + m[5]*v[1]);
  vaccum[2] += scale * (m[2]*v[0] + m[6]*v[1]);
  vaccum[3] += scale * (m[3]*v[0] + m[7]*v[1]);
}

// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1];
  vout[1] = mt[2]*v[0] + mt[3]*v[1];
  vout[2] = mt[4]*v[0] + mt[5]*v[1];
  vout[3] = mt[6]*v[0] + mt[7]*v[1];
}
// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1];
  v[1] = mt[2]*t[0] + mt[3]*t[1];
  v[2] = mt[4]*t[0] + mt[5]*t[1];
  v[3] = mt[6]*t[0] + mt[7]*t[1];
}
// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1];
  vaccum[1] += mt[2]*v[0] + mt[3]*v[1];
  vaccum[2] += mt[4]*v[0] + mt[5]*v[1];
  vaccum[3] += mt[6]*v[0] + mt[7]*v[1];
}
// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1]);
  vout[1] = scale * (mt[2]*v[0] + mt[3]*v[1]);
  vout[2] = scale * (mt[4]*v[0] + mt[5]*v[1]);
  vout[3] = scale * (mt[6]*v[0] + mt[7]*v[1]);
}
// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1]);
  v[1] = scale * (mt[2]*t[0] + mt[3]*t[1]);
  v[2] = scale * (mt[4]*t[0] + mt[5]*t[1]);
  v[3] = scale * (mt[6]*t[0] + mt[7]*t[1]);
}
// 2-vector by 4x2-transposed matrix multiplication
static inline void mul_vec2_gen42t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1]);
  vaccum[1] += scale * (mt[2]*v[0] + mt[3]*v[1]);
  vaccum[2] += scale * (mt[4]*v[0] + mt[5]*v[1]);
  vaccum[3] += scale * (mt[6]*v[0] + mt[7]*v[1]);
}

// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[5]*v[1];
  vout[1] = m[1]*v[0] + m[6]*v[1];
  vout[2] = m[2]*v[0] + m[7]*v[1];
  vout[3] = m[3]*v[0] + m[8]*v[1];
  vout[4] = m[4]*v[0] + m[9]*v[1];
}
// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[5]*t[1];
  v[1] = m[1]*t[0] + m[6]*t[1];
  v[2] = m[2]*t[0] + m[7]*t[1];
  v[3] = m[3]*t[0] + m[8]*t[1];
  v[4] = m[4]*t[0] + m[9]*t[1];
}
// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[5]*v[1];
  vaccum[1] += m[1]*v[0] + m[6]*v[1];
  vaccum[2] += m[2]*v[0] + m[7]*v[1];
  vaccum[3] += m[3]*v[0] + m[8]*v[1];
  vaccum[4] += m[4]*v[0] + m[9]*v[1];
}
// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[5]*v[1]);
  vout[1] = scale * (m[1]*v[0] + m[6]*v[1]);
  vout[2] = scale * (m[2]*v[0] + m[7]*v[1]);
  vout[3] = scale * (m[3]*v[0] + m[8]*v[1]);
  vout[4] = scale * (m[4]*v[0] + m[9]*v[1]);
}
// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[5]*t[1]);
  v[1] = scale * (m[1]*t[0] + m[6]*t[1]);
  v[2] = scale * (m[2]*t[0] + m[7]*t[1]);
  v[3] = scale * (m[3]*t[0] + m[8]*t[1]);
  v[4] = scale * (m[4]*t[0] + m[9]*t[1]);
}
// 2-vector by 2x5 matrix multiplication
static inline void mul_vec2_gen25_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[5]*v[1]);
  vaccum[1] += scale * (m[1]*v[0] + m[6]*v[1]);
  vaccum[2] += scale * (m[2]*v[0] + m[7]*v[1]);
  vaccum[3] += scale * (m[3]*v[0] + m[8]*v[1]);
  vaccum[4] += scale * (m[4]*v[0] + m[9]*v[1]);
}

// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1];
  vout[1] = mt[2]*v[0] + mt[3]*v[1];
  vout[2] = mt[4]*v[0] + mt[5]*v[1];
  vout[3] = mt[6]*v[0] + mt[7]*v[1];
  vout[4] = mt[8]*v[0] + mt[9]*v[1];
}
// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1];
  v[1] = mt[2]*t[0] + mt[3]*t[1];
  v[2] = mt[4]*t[0] + mt[5]*t[1];
  v[3] = mt[6]*t[0] + mt[7]*t[1];
  v[4] = mt[8]*t[0] + mt[9]*t[1];
}
// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1];
  vaccum[1] += mt[2]*v[0] + mt[3]*v[1];
  vaccum[2] += mt[4]*v[0] + mt[5]*v[1];
  vaccum[3] += mt[6]*v[0] + mt[7]*v[1];
  vaccum[4] += mt[8]*v[0] + mt[9]*v[1];
}
// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1]);
  vout[1] = scale * (mt[2]*v[0] + mt[3]*v[1]);
  vout[2] = scale * (mt[4]*v[0] + mt[5]*v[1]);
  vout[3] = scale * (mt[6]*v[0] + mt[7]*v[1]);
  vout[4] = scale * (mt[8]*v[0] + mt[9]*v[1]);
}
// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1]);
  v[1] = scale * (mt[2]*t[0] + mt[3]*t[1]);
  v[2] = scale * (mt[4]*t[0] + mt[5]*t[1]);
  v[3] = scale * (mt[6]*t[0] + mt[7]*t[1]);
  v[4] = scale * (mt[8]*t[0] + mt[9]*t[1]);
}
// 2-vector by 5x2-transposed matrix multiplication
static inline void mul_vec2_gen52t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1]);
  vaccum[1] += scale * (mt[2]*v[0] + mt[3]*v[1]);
  vaccum[2] += scale * (mt[4]*v[0] + mt[5]*v[1]);
  vaccum[3] += scale * (mt[6]*v[0] + mt[7]*v[1]);
  vaccum[4] += scale * (mt[8]*v[0] + mt[9]*v[1]);
}

// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[6]*v[1];
  vout[1] = m[1]*v[0] + m[7]*v[1];
  vout[2] = m[2]*v[0] + m[8]*v[1];
  vout[3] = m[3]*v[0] + m[9]*v[1];
  vout[4] = m[4]*v[0] + m[10]*v[1];
  vout[5] = m[5]*v[0] + m[11]*v[1];
}
// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[6]*t[1];
  v[1] = m[1]*t[0] + m[7]*t[1];
  v[2] = m[2]*t[0] + m[8]*t[1];
  v[3] = m[3]*t[0] + m[9]*t[1];
  v[4] = m[4]*t[0] + m[10]*t[1];
  v[5] = m[5]*t[0] + m[11]*t[1];
}
// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[6]*v[1];
  vaccum[1] += m[1]*v[0] + m[7]*v[1];
  vaccum[2] += m[2]*v[0] + m[8]*v[1];
  vaccum[3] += m[3]*v[0] + m[9]*v[1];
  vaccum[4] += m[4]*v[0] + m[10]*v[1];
  vaccum[5] += m[5]*v[0] + m[11]*v[1];
}
// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[6]*v[1]);
  vout[1] = scale * (m[1]*v[0] + m[7]*v[1]);
  vout[2] = scale * (m[2]*v[0] + m[8]*v[1]);
  vout[3] = scale * (m[3]*v[0] + m[9]*v[1]);
  vout[4] = scale * (m[4]*v[0] + m[10]*v[1]);
  vout[5] = scale * (m[5]*v[0] + m[11]*v[1]);
}
// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[6]*t[1]);
  v[1] = scale * (m[1]*t[0] + m[7]*t[1]);
  v[2] = scale * (m[2]*t[0] + m[8]*t[1]);
  v[3] = scale * (m[3]*t[0] + m[9]*t[1]);
  v[4] = scale * (m[4]*t[0] + m[10]*t[1]);
  v[5] = scale * (m[5]*t[0] + m[11]*t[1]);
}
// 2-vector by 2x6 matrix multiplication
static inline void mul_vec2_gen26_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[6]*v[1]);
  vaccum[1] += scale * (m[1]*v[0] + m[7]*v[1]);
  vaccum[2] += scale * (m[2]*v[0] + m[8]*v[1]);
  vaccum[3] += scale * (m[3]*v[0] + m[9]*v[1]);
  vaccum[4] += scale * (m[4]*v[0] + m[10]*v[1]);
  vaccum[5] += scale * (m[5]*v[0] + m[11]*v[1]);
}

// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1];
  vout[1] = mt[2]*v[0] + mt[3]*v[1];
  vout[2] = mt[4]*v[0] + mt[5]*v[1];
  vout[3] = mt[6]*v[0] + mt[7]*v[1];
  vout[4] = mt[8]*v[0] + mt[9]*v[1];
  vout[5] = mt[10]*v[0] + mt[11]*v[1];
}
// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1];
  v[1] = mt[2]*t[0] + mt[3]*t[1];
  v[2] = mt[4]*t[0] + mt[5]*t[1];
  v[3] = mt[6]*t[0] + mt[7]*t[1];
  v[4] = mt[8]*t[0] + mt[9]*t[1];
  v[5] = mt[10]*t[0] + mt[11]*t[1];
}
// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1];
  vaccum[1] += mt[2]*v[0] + mt[3]*v[1];
  vaccum[2] += mt[4]*v[0] + mt[5]*v[1];
  vaccum[3] += mt[6]*v[0] + mt[7]*v[1];
  vaccum[4] += mt[8]*v[0] + mt[9]*v[1];
  vaccum[5] += mt[10]*v[0] + mt[11]*v[1];
}
// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1]);
  vout[1] = scale * (mt[2]*v[0] + mt[3]*v[1]);
  vout[2] = scale * (mt[4]*v[0] + mt[5]*v[1]);
  vout[3] = scale * (mt[6]*v[0] + mt[7]*v[1]);
  vout[4] = scale * (mt[8]*v[0] + mt[9]*v[1]);
  vout[5] = scale * (mt[10]*v[0] + mt[11]*v[1]);
}
// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1]);
  v[1] = scale * (mt[2]*t[0] + mt[3]*t[1]);
  v[2] = scale * (mt[4]*t[0] + mt[5]*t[1]);
  v[3] = scale * (mt[6]*t[0] + mt[7]*t[1]);
  v[4] = scale * (mt[8]*t[0] + mt[9]*t[1]);
  v[5] = scale * (mt[10]*t[0] + mt[11]*t[1]);
}
// 2-vector by 6x2-transposed matrix multiplication
static inline void mul_vec2_gen62t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1]);
  vaccum[1] += scale * (mt[2]*v[0] + mt[3]*v[1]);
  vaccum[2] += scale * (mt[4]*v[0] + mt[5]*v[1]);
  vaccum[3] += scale * (mt[6]*v[0] + mt[7]*v[1]);
  vaccum[4] += scale * (mt[8]*v[0] + mt[9]*v[1]);
  vaccum[5] += scale * (mt[10]*v[0] + mt[11]*v[1]);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22_vout(int n, const double* restrict v, const double* restrict s, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22_vout(v + 2*i, s, vout + 2*i);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22(int n, double* restrict v, const double* restrict s)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22(v + 2*i, s);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22_vaccum(int n, const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22_vaccum(v + 2*i, s, vaccum + 2*i);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22_vout_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22_vout_scaled(v + 2*i, s, vout + 2*i, scale);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22_scaled(int n, double* restrict v, const double* restrict s, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22_scaled(v + 2*i, s, scale);
}

// general Nx2 matrix by symmetric 2x2
static inline void mul_genN2_sym22_vaccum_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_sym22_vaccum_scaled(v + 2*i, s, vaccum + 2*i, scale);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22_vout(int n, const double* restrict v, const double* restrict m, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22_vout(v + 2*i, m, vout + 2*i);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t_vout(int n, const double* restrict v, const double* restrict mt, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t_vout(v + 2*i, mt, vout + 2*i);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22(int n, double* restrict v, const double* restrict m)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22(v + 2*i, m);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t(int n, double* restrict v, const double* restrict mt)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t(v + 2*i, mt);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22_vaccum(int n, const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22_vaccum(v + 2*i, m, vaccum + 2*i);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t_vaccum(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t_vaccum(v + 2*i, mt, vaccum + 2*i);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22_vout_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22_vout_scaled(v + 2*i, m, vout + 2*i, scale);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t_vout_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t_vout_scaled(v + 2*i, mt, vout + 2*i, scale);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22_scaled(int n, double* restrict v, const double* restrict m, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22_scaled(v + 2*i, m, scale);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t_scaled(int n, double* restrict v, const double* restrict mt, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t_scaled(v + 2*i, mt, scale);
}


// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22_vaccum_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22_vaccum_scaled(v + 2*i, m, vaccum + 2*i, scale);
}

// general Nx2 matrix by general 2x2
static inline void mul_genN2_gen22t_vaccum_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec2_gen22t_vaccum_scaled(v + 2*i, mt, vaccum + 2*i, scale);
}



// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33_vout(const double* restrict v, const double* restrict s, double* restrict vout)
{
  vout[0] = s[0]*v[0] + s[1]*v[1] + s[2]*v[2];
  vout[1] = s[1]*v[0] + s[3]*v[1] + s[4]*v[2];
  vout[2] = s[2]*v[0] + s[4]*v[1] + s[5]*v[2];
}
// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33(double* restrict v, const double* restrict s)
{
  double t[2] = {v[0], v[1]};
  v[0] = s[0]*t[0] + s[1]*t[1] + s[2]*v[2];
  v[1] = s[1]*t[0] + s[3]*t[1] + s[4]*v[2];
  v[2] = s[2]*t[0] + s[4]*t[1] + s[5]*v[2];
}
// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33_vaccum(const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  vaccum[0] += s[0]*v[0] + s[1]*v[1] + s[2]*v[2];
  vaccum[1] += s[1]*v[0] + s[3]*v[1] + s[4]*v[2];
  vaccum[2] += s[2]*v[0] + s[4]*v[1] + s[5]*v[2];
}
// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33_vout_scaled(const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  vout[0] = scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2]);
  vout[1] = scale * (s[1]*v[0] + s[3]*v[1] + s[4]*v[2]);
  vout[2] = scale * (s[2]*v[0] + s[4]*v[1] + s[5]*v[2]);
}
// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33_scaled(double* restrict v, const double* restrict s, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (s[0]*t[0] + s[1]*t[1] + s[2]*v[2]);
  v[1] = scale * (s[1]*t[0] + s[3]*t[1] + s[4]*v[2]);
  v[2] = scale * (s[2]*t[0] + s[4]*t[1] + s[5]*v[2]);
}
// 3-vector by symmetric 3x3
static inline void mul_vec3_sym33_vaccum_scaled(const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2]);
  vaccum[1] += scale * (s[1]*v[0] + s[3]*v[1] + s[4]*v[2]);
  vaccum[2] += scale * (s[2]*v[0] + s[4]*v[1] + s[5]*v[2]);
}

// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[2]*v[1] + m[4]*v[2];
  vout[1] = m[1]*v[0] + m[3]*v[1] + m[5]*v[2];
}
// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32(double* restrict v, const double* restrict m)
{
  double t[1] = {v[0]};
  v[0] = m[0]*t[0] + m[2]*v[1] + m[4]*v[2];
  v[1] = m[1]*t[0] + m[3]*v[1] + m[5]*v[2];
}
// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[2]*v[1] + m[4]*v[2];
  vaccum[1] += m[1]*v[0] + m[3]*v[1] + m[5]*v[2];
}
// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2]);
  vout[1] = scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2]);
}
// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (m[0]*t[0] + m[2]*v[1] + m[4]*v[2]);
  v[1] = scale * (m[1]*t[0] + m[3]*v[1] + m[5]*v[2]);
}
// 3-vector by 3x2 matrix multiplication
static inline void mul_vec3_gen32_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2]);
  vaccum[1] += scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2]);
}

// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vout[1] = mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
}
// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t(double* restrict v, const double* restrict mt)
{
  double t[1] = {v[0]};
  v[0] = mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2];
  v[1] = mt[3]*t[0] + mt[4]*v[1] + mt[5]*v[2];
}
// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vaccum[1] += mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
}
// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vout[1] = scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
}
// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2]);
  v[1] = scale * (mt[3]*t[0] + mt[4]*v[1] + mt[5]*v[2]);
}
// 3-vector by 2x3-transposed matrix multiplication
static inline void mul_vec3_gen23t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vaccum[1] += scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
}

// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[3]*v[1] + m[6]*v[2];
  vout[1] = m[1]*v[0] + m[4]*v[1] + m[7]*v[2];
  vout[2] = m[2]*v[0] + m[5]*v[1] + m[8]*v[2];
}
// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[3]*t[1] + m[6]*v[2];
  v[1] = m[1]*t[0] + m[4]*t[1] + m[7]*v[2];
  v[2] = m[2]*t[0] + m[5]*t[1] + m[8]*v[2];
}
// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[3]*v[1] + m[6]*v[2];
  vaccum[1] += m[1]*v[0] + m[4]*v[1] + m[7]*v[2];
  vaccum[2] += m[2]*v[0] + m[5]*v[1] + m[8]*v[2];
}
// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2]);
  vout[1] = scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2]);
  vout[2] = scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2]);
}
// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[3]*t[1] + m[6]*v[2]);
  v[1] = scale * (m[1]*t[0] + m[4]*t[1] + m[7]*v[2]);
  v[2] = scale * (m[2]*t[0] + m[5]*t[1] + m[8]*v[2]);
}
// 3-vector by 3x3 matrix multiplication
static inline void mul_vec3_gen33_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2]);
  vaccum[1] += scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2]);
  vaccum[2] += scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2]);
}

// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vout[1] = mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vout[2] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
}
// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2];
  v[1] = mt[3]*t[0] + mt[4]*t[1] + mt[5]*v[2];
  v[2] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*v[2];
}
// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vaccum[1] += mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vaccum[2] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
}
// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vout[1] = scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vout[2] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
}
// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2]);
  v[1] = scale * (mt[3]*t[0] + mt[4]*t[1] + mt[5]*v[2]);
  v[2] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*v[2]);
}
// 3-vector by 3x3-transposed matrix multiplication
static inline void mul_vec3_gen33t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vaccum[1] += scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vaccum[2] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
}

// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2];
  vout[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2];
  vout[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2];
  vout[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2];
}
// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[4]*t[1] + m[8]*t[2];
  v[1] = m[1]*t[0] + m[5]*t[1] + m[9]*t[2];
  v[2] = m[2]*t[0] + m[6]*t[1] + m[10]*t[2];
  v[3] = m[3]*t[0] + m[7]*t[1] + m[11]*t[2];
}
// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[4]*v[1] + m[8]*v[2];
  vaccum[1] += m[1]*v[0] + m[5]*v[1] + m[9]*v[2];
  vaccum[2] += m[2]*v[0] + m[6]*v[1] + m[10]*v[2];
  vaccum[3] += m[3]*v[0] + m[7]*v[1] + m[11]*v[2];
}
// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2]);
  vout[1] = scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2]);
  vout[2] = scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2]);
  vout[3] = scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2]);
}
// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[4]*t[1] + m[8]*t[2]);
  v[1] = scale * (m[1]*t[0] + m[5]*t[1] + m[9]*t[2]);
  v[2] = scale * (m[2]*t[0] + m[6]*t[1] + m[10]*t[2]);
  v[3] = scale * (m[3]*t[0] + m[7]*t[1] + m[11]*t[2]);
}
// 3-vector by 3x4 matrix multiplication
static inline void mul_vec3_gen34_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2]);
  vaccum[1] += scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2]);
  vaccum[2] += scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2]);
  vaccum[3] += scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2]);
}

// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vout[1] = mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vout[2] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vout[3] = mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
}
// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2];
  v[1] = mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2];
  v[2] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2];
  v[3] = mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2];
}
// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vaccum[1] += mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vaccum[2] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vaccum[3] += mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
}
// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vout[1] = scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vout[2] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vout[3] = scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
}
// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2]);
  v[1] = scale * (mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2]);
  v[2] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2]);
  v[3] = scale * (mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2]);
}
// 3-vector by 4x3-transposed matrix multiplication
static inline void mul_vec3_gen43t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vaccum[1] += scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vaccum[2] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vaccum[3] += scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
}

// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[5]*v[1] + m[10]*v[2];
  vout[1] = m[1]*v[0] + m[6]*v[1] + m[11]*v[2];
  vout[2] = m[2]*v[0] + m[7]*v[1] + m[12]*v[2];
  vout[3] = m[3]*v[0] + m[8]*v[1] + m[13]*v[2];
  vout[4] = m[4]*v[0] + m[9]*v[1] + m[14]*v[2];
}
// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[5]*t[1] + m[10]*t[2];
  v[1] = m[1]*t[0] + m[6]*t[1] + m[11]*t[2];
  v[2] = m[2]*t[0] + m[7]*t[1] + m[12]*t[2];
  v[3] = m[3]*t[0] + m[8]*t[1] + m[13]*t[2];
  v[4] = m[4]*t[0] + m[9]*t[1] + m[14]*t[2];
}
// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[5]*v[1] + m[10]*v[2];
  vaccum[1] += m[1]*v[0] + m[6]*v[1] + m[11]*v[2];
  vaccum[2] += m[2]*v[0] + m[7]*v[1] + m[12]*v[2];
  vaccum[3] += m[3]*v[0] + m[8]*v[1] + m[13]*v[2];
  vaccum[4] += m[4]*v[0] + m[9]*v[1] + m[14]*v[2];
}
// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2]);
  vout[1] = scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2]);
  vout[2] = scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2]);
  vout[3] = scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2]);
  vout[4] = scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2]);
}
// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[5]*t[1] + m[10]*t[2]);
  v[1] = scale * (m[1]*t[0] + m[6]*t[1] + m[11]*t[2]);
  v[2] = scale * (m[2]*t[0] + m[7]*t[1] + m[12]*t[2]);
  v[3] = scale * (m[3]*t[0] + m[8]*t[1] + m[13]*t[2]);
  v[4] = scale * (m[4]*t[0] + m[9]*t[1] + m[14]*t[2]);
}
// 3-vector by 3x5 matrix multiplication
static inline void mul_vec3_gen35_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2]);
  vaccum[1] += scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2]);
  vaccum[2] += scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2]);
  vaccum[3] += scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2]);
  vaccum[4] += scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2]);
}

// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vout[1] = mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vout[2] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vout[3] = mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
  vout[4] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2];
}
// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2];
  v[1] = mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2];
  v[2] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2];
  v[3] = mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2];
  v[4] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2];
}
// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vaccum[1] += mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vaccum[2] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vaccum[3] += mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
  vaccum[4] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2];
}
// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vout[1] = scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vout[2] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vout[3] = scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
  vout[4] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2]);
}
// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2]);
  v[1] = scale * (mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2]);
  v[2] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2]);
  v[3] = scale * (mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2]);
  v[4] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2]);
}
// 3-vector by 5x3-transposed matrix multiplication
static inline void mul_vec3_gen53t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vaccum[1] += scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vaccum[2] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vaccum[3] += scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
  vaccum[4] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2]);
}

// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[6]*v[1] + m[12]*v[2];
  vout[1] = m[1]*v[0] + m[7]*v[1] + m[13]*v[2];
  vout[2] = m[2]*v[0] + m[8]*v[1] + m[14]*v[2];
  vout[3] = m[3]*v[0] + m[9]*v[1] + m[15]*v[2];
  vout[4] = m[4]*v[0] + m[10]*v[1] + m[16]*v[2];
  vout[5] = m[5]*v[0] + m[11]*v[1] + m[17]*v[2];
}
// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[6]*t[1] + m[12]*t[2];
  v[1] = m[1]*t[0] + m[7]*t[1] + m[13]*t[2];
  v[2] = m[2]*t[0] + m[8]*t[1] + m[14]*t[2];
  v[3] = m[3]*t[0] + m[9]*t[1] + m[15]*t[2];
  v[4] = m[4]*t[0] + m[10]*t[1] + m[16]*t[2];
  v[5] = m[5]*t[0] + m[11]*t[1] + m[17]*t[2];
}
// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[6]*v[1] + m[12]*v[2];
  vaccum[1] += m[1]*v[0] + m[7]*v[1] + m[13]*v[2];
  vaccum[2] += m[2]*v[0] + m[8]*v[1] + m[14]*v[2];
  vaccum[3] += m[3]*v[0] + m[9]*v[1] + m[15]*v[2];
  vaccum[4] += m[4]*v[0] + m[10]*v[1] + m[16]*v[2];
  vaccum[5] += m[5]*v[0] + m[11]*v[1] + m[17]*v[2];
}
// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2]);
  vout[1] = scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2]);
  vout[2] = scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2]);
  vout[3] = scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2]);
  vout[4] = scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2]);
  vout[5] = scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2]);
}
// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[6]*t[1] + m[12]*t[2]);
  v[1] = scale * (m[1]*t[0] + m[7]*t[1] + m[13]*t[2]);
  v[2] = scale * (m[2]*t[0] + m[8]*t[1] + m[14]*t[2]);
  v[3] = scale * (m[3]*t[0] + m[9]*t[1] + m[15]*t[2]);
  v[4] = scale * (m[4]*t[0] + m[10]*t[1] + m[16]*t[2]);
  v[5] = scale * (m[5]*t[0] + m[11]*t[1] + m[17]*t[2]);
}
// 3-vector by 3x6 matrix multiplication
static inline void mul_vec3_gen36_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2]);
  vaccum[1] += scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2]);
  vaccum[2] += scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2]);
  vaccum[3] += scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2]);
  vaccum[4] += scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2]);
  vaccum[5] += scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2]);
}

// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vout[1] = mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vout[2] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vout[3] = mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
  vout[4] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2];
  vout[5] = mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2];
}
// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2];
  v[1] = mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2];
  v[2] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2];
  v[3] = mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2];
  v[4] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2];
  v[5] = mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2];
}
// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2];
  vaccum[1] += mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2];
  vaccum[2] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2];
  vaccum[3] += mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2];
  vaccum[4] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2];
  vaccum[5] += mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2];
}
// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vout[1] = scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vout[2] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vout[3] = scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
  vout[4] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2]);
  vout[5] = scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2]);
}
// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2]);
  v[1] = scale * (mt[3]*t[0] + mt[4]*t[1] + mt[5]*t[2]);
  v[2] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2]);
  v[3] = scale * (mt[9]*t[0] + mt[10]*t[1] + mt[11]*t[2]);
  v[4] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2]);
  v[5] = scale * (mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2]);
}
// 3-vector by 6x3-transposed matrix multiplication
static inline void mul_vec3_gen63t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2]);
  vaccum[1] += scale * (mt[3]*v[0] + mt[4]*v[1] + mt[5]*v[2]);
  vaccum[2] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2]);
  vaccum[3] += scale * (mt[9]*v[0] + mt[10]*v[1] + mt[11]*v[2]);
  vaccum[4] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2]);
  vaccum[5] += scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2]);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33_vout(int n, const double* restrict v, const double* restrict s, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33_vout(v + 3*i, s, vout + 3*i);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33(int n, double* restrict v, const double* restrict s)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33(v + 3*i, s);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33_vaccum(int n, const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33_vaccum(v + 3*i, s, vaccum + 3*i);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33_vout_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33_vout_scaled(v + 3*i, s, vout + 3*i, scale);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33_scaled(int n, double* restrict v, const double* restrict s, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33_scaled(v + 3*i, s, scale);
}

// general Nx3 matrix by symmetric 3x3
static inline void mul_genN3_sym33_vaccum_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_sym33_vaccum_scaled(v + 3*i, s, vaccum + 3*i, scale);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33_vout(int n, const double* restrict v, const double* restrict m, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33_vout(v + 3*i, m, vout + 3*i);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t_vout(int n, const double* restrict v, const double* restrict mt, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t_vout(v + 3*i, mt, vout + 3*i);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33(int n, double* restrict v, const double* restrict m)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33(v + 3*i, m);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t(int n, double* restrict v, const double* restrict mt)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t(v + 3*i, mt);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33_vaccum(int n, const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33_vaccum(v + 3*i, m, vaccum + 3*i);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t_vaccum(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t_vaccum(v + 3*i, mt, vaccum + 3*i);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33_vout_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33_vout_scaled(v + 3*i, m, vout + 3*i, scale);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t_vout_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t_vout_scaled(v + 3*i, mt, vout + 3*i, scale);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33_scaled(int n, double* restrict v, const double* restrict m, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33_scaled(v + 3*i, m, scale);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t_scaled(int n, double* restrict v, const double* restrict mt, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t_scaled(v + 3*i, mt, scale);
}


// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33_vaccum_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33_vaccum_scaled(v + 3*i, m, vaccum + 3*i, scale);
}

// general Nx3 matrix by general 3x3
static inline void mul_genN3_gen33t_vaccum_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec3_gen33t_vaccum_scaled(v + 3*i, mt, vaccum + 3*i, scale);
}



// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44_vout(const double* restrict v, const double* restrict s, double* restrict vout)
{
  vout[0] = s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3];
  vout[1] = s[1]*v[0] + s[4]*v[1] + s[5]*v[2] + s[6]*v[3];
  vout[2] = s[2]*v[0] + s[5]*v[1] + s[7]*v[2] + s[8]*v[3];
  vout[3] = s[3]*v[0] + s[6]*v[1] + s[8]*v[2] + s[9]*v[3];
}
// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44(double* restrict v, const double* restrict s)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*v[3];
  v[1] = s[1]*t[0] + s[4]*t[1] + s[5]*t[2] + s[6]*v[3];
  v[2] = s[2]*t[0] + s[5]*t[1] + s[7]*t[2] + s[8]*v[3];
  v[3] = s[3]*t[0] + s[6]*t[1] + s[8]*t[2] + s[9]*v[3];
}
// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44_vaccum(const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  vaccum[0] += s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3];
  vaccum[1] += s[1]*v[0] + s[4]*v[1] + s[5]*v[2] + s[6]*v[3];
  vaccum[2] += s[2]*v[0] + s[5]*v[1] + s[7]*v[2] + s[8]*v[3];
  vaccum[3] += s[3]*v[0] + s[6]*v[1] + s[8]*v[2] + s[9]*v[3];
}
// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44_vout_scaled(const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  vout[0] = scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3]);
  vout[1] = scale * (s[1]*v[0] + s[4]*v[1] + s[5]*v[2] + s[6]*v[3]);
  vout[2] = scale * (s[2]*v[0] + s[5]*v[1] + s[7]*v[2] + s[8]*v[3]);
  vout[3] = scale * (s[3]*v[0] + s[6]*v[1] + s[8]*v[2] + s[9]*v[3]);
}
// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44_scaled(double* restrict v, const double* restrict s, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*v[3]);
  v[1] = scale * (s[1]*t[0] + s[4]*t[1] + s[5]*t[2] + s[6]*v[3]);
  v[2] = scale * (s[2]*t[0] + s[5]*t[1] + s[7]*t[2] + s[8]*v[3]);
  v[3] = scale * (s[3]*t[0] + s[6]*t[1] + s[8]*t[2] + s[9]*v[3]);
}
// 4-vector by symmetric 4x4
static inline void mul_vec4_sym44_vaccum_scaled(const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3]);
  vaccum[1] += scale * (s[1]*v[0] + s[4]*v[1] + s[5]*v[2] + s[6]*v[3]);
  vaccum[2] += scale * (s[2]*v[0] + s[5]*v[1] + s[7]*v[2] + s[8]*v[3]);
  vaccum[3] += scale * (s[3]*v[0] + s[6]*v[1] + s[8]*v[2] + s[9]*v[3]);
}

// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3];
  vout[1] = m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3];
}
// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42(double* restrict v, const double* restrict m)
{
  double t[1] = {v[0]};
  v[0] = m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3];
  v[1] = m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3];
}
// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3];
  vaccum[1] += m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3];
}
// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3]);
  vout[1] = scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3]);
}
// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3]);
  v[1] = scale * (m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3]);
}
// 4-vector by 4x2 matrix multiplication
static inline void mul_vec4_gen42_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3]);
  vaccum[1] += scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3]);
}

// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vout[1] = mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
}
// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t(double* restrict v, const double* restrict mt)
{
  double t[1] = {v[0]};
  v[0] = mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  v[1] = mt[4]*t[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
}
// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vaccum[1] += mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
}
// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vout[1] = scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
}
// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  v[1] = scale * (mt[4]*t[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
}
// 4-vector by 2x4-transposed matrix multiplication
static inline void mul_vec4_gen24t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vaccum[1] += scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
}

// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3];
  vout[1] = m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3];
  vout[2] = m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3];
}
// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3];
  v[1] = m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3];
  v[2] = m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3];
}
// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3];
  vaccum[1] += m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3];
  vaccum[2] += m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3];
}
// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3]);
  vout[1] = scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3]);
  vout[2] = scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3]);
}
// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3]);
  v[1] = scale * (m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3]);
  v[2] = scale * (m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3]);
}
// 4-vector by 4x3 matrix multiplication
static inline void mul_vec4_gen43_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3]);
  vaccum[1] += scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3]);
  vaccum[2] += scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3]);
}

// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vout[1] = mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vout[2] = mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
}
// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3];
  v[1] = mt[4]*t[0] + mt[5]*t[1] + mt[6]*v[2] + mt[7]*v[3];
  v[2] = mt[8]*t[0] + mt[9]*t[1] + mt[10]*v[2] + mt[11]*v[3];
}
// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vaccum[1] += mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vaccum[2] += mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
}
// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vout[1] = scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vout[2] = scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
}
// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3]);
  v[1] = scale * (mt[4]*t[0] + mt[5]*t[1] + mt[6]*v[2] + mt[7]*v[3]);
  v[2] = scale * (mt[8]*t[0] + mt[9]*t[1] + mt[10]*v[2] + mt[11]*v[3]);
}
// 4-vector by 3x4-transposed matrix multiplication
static inline void mul_vec4_gen34t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vaccum[1] += scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vaccum[2] += scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
}

// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3];
  vout[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3];
  vout[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3];
  vout[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3];
}
// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3];
  v[1] = m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3];
  v[2] = m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3];
  v[3] = m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3];
}
// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3];
  vaccum[1] += m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3];
  vaccum[2] += m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3];
  vaccum[3] += m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3];
}
// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]);
  vout[1] = scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]);
  vout[2] = scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]);
  vout[3] = scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]);
}
// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3]);
  v[1] = scale * (m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3]);
  v[2] = scale * (m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3]);
  v[3] = scale * (m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3]);
}
// 4-vector by 4x4 matrix multiplication
static inline void mul_vec4_gen44_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]);
  vaccum[1] += scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]);
  vaccum[2] += scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]);
  vaccum[3] += scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]);
}

// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vout[1] = mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vout[2] = mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vout[3] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
}
// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3];
  v[1] = mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*v[3];
  v[2] = mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*v[3];
  v[3] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*v[3];
}
// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vaccum[1] += mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vaccum[2] += mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vaccum[3] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
}
// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vout[1] = scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vout[2] = scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vout[3] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
}
// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3]);
  v[1] = scale * (mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*v[3]);
  v[2] = scale * (mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*v[3]);
  v[3] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*v[3]);
}
// 4-vector by 4x4-transposed matrix multiplication
static inline void mul_vec4_gen44t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vaccum[1] += scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vaccum[2] += scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vaccum[3] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
}

// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3];
  vout[1] = m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3];
  vout[2] = m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3];
  vout[3] = m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3];
  vout[4] = m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3];
}
// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45(double* restrict v, const double* restrict m)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3];
  v[1] = m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3];
  v[2] = m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3];
  v[3] = m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3];
  v[4] = m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3];
}
// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3];
  vaccum[1] += m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3];
  vaccum[2] += m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3];
  vaccum[3] += m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3];
  vaccum[4] += m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3];
}
// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3]);
  vout[1] = scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3]);
  vout[2] = scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3]);
  vout[3] = scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3]);
  vout[4] = scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3]);
}
// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3]);
  v[1] = scale * (m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3]);
  v[2] = scale * (m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3]);
  v[3] = scale * (m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3]);
  v[4] = scale * (m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3]);
}
// 4-vector by 4x5 matrix multiplication
static inline void mul_vec4_gen45_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3]);
  vaccum[1] += scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3]);
  vaccum[2] += scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3]);
  vaccum[3] += scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3]);
  vaccum[4] += scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3]);
}

// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vout[1] = mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vout[2] = mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vout[3] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
  vout[4] = mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3];
}
// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t(double* restrict v, const double* restrict mt)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3];
  v[1] = mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*t[3];
  v[2] = mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*t[3];
  v[3] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3];
  v[4] = mt[16]*t[0] + mt[17]*t[1] + mt[18]*t[2] + mt[19]*t[3];
}
// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vaccum[1] += mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vaccum[2] += mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vaccum[3] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
  vaccum[4] += mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3];
}
// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vout[1] = scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vout[2] = scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vout[3] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
  vout[4] = scale * (mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3]);
}
// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3]);
  v[1] = scale * (mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*t[3]);
  v[2] = scale * (mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*t[3]);
  v[3] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3]);
  v[4] = scale * (mt[16]*t[0] + mt[17]*t[1] + mt[18]*t[2] + mt[19]*t[3]);
}
// 4-vector by 5x4-transposed matrix multiplication
static inline void mul_vec4_gen54t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vaccum[1] += scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vaccum[2] += scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vaccum[3] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
  vaccum[4] += scale * (mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3]);
}

// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3];
  vout[1] = m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3];
  vout[2] = m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3];
  vout[3] = m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3];
  vout[4] = m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3];
  vout[5] = m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3];
}
// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46(double* restrict v, const double* restrict m)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3];
  v[1] = m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3];
  v[2] = m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3];
  v[3] = m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3];
  v[4] = m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3];
  v[5] = m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3];
}
// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3];
  vaccum[1] += m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3];
  vaccum[2] += m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3];
  vaccum[3] += m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3];
  vaccum[4] += m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3];
  vaccum[5] += m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3];
}
// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3]);
  vout[1] = scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3]);
  vout[2] = scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3]);
  vout[3] = scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3]);
  vout[4] = scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3]);
  vout[5] = scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3]);
}
// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3]);
  v[1] = scale * (m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3]);
  v[2] = scale * (m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3]);
  v[3] = scale * (m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3]);
  v[4] = scale * (m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3]);
  v[5] = scale * (m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3]);
}
// 4-vector by 4x6 matrix multiplication
static inline void mul_vec4_gen46_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3]);
  vaccum[1] += scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3]);
  vaccum[2] += scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3]);
  vaccum[3] += scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3]);
  vaccum[4] += scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3]);
  vaccum[5] += scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3]);
}

// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vout[1] = mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vout[2] = mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vout[3] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
  vout[4] = mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3];
  vout[5] = mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3];
}
// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t(double* restrict v, const double* restrict mt)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3];
  v[1] = mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*t[3];
  v[2] = mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*t[3];
  v[3] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3];
  v[4] = mt[16]*t[0] + mt[17]*t[1] + mt[18]*t[2] + mt[19]*t[3];
  v[5] = mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3];
}
// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3];
  vaccum[1] += mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3];
  vaccum[2] += mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3];
  vaccum[3] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3];
  vaccum[4] += mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3];
  vaccum[5] += mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3];
}
// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vout[1] = scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vout[2] = scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vout[3] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
  vout[4] = scale * (mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3]);
  vout[5] = scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3]);
}
// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3]);
  v[1] = scale * (mt[4]*t[0] + mt[5]*t[1] + mt[6]*t[2] + mt[7]*t[3]);
  v[2] = scale * (mt[8]*t[0] + mt[9]*t[1] + mt[10]*t[2] + mt[11]*t[3]);
  v[3] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3]);
  v[4] = scale * (mt[16]*t[0] + mt[17]*t[1] + mt[18]*t[2] + mt[19]*t[3]);
  v[5] = scale * (mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3]);
}
// 4-vector by 6x4-transposed matrix multiplication
static inline void mul_vec4_gen64t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3]);
  vaccum[1] += scale * (mt[4]*v[0] + mt[5]*v[1] + mt[6]*v[2] + mt[7]*v[3]);
  vaccum[2] += scale * (mt[8]*v[0] + mt[9]*v[1] + mt[10]*v[2] + mt[11]*v[3]);
  vaccum[3] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3]);
  vaccum[4] += scale * (mt[16]*v[0] + mt[17]*v[1] + mt[18]*v[2] + mt[19]*v[3]);
  vaccum[5] += scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3]);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44_vout(int n, const double* restrict v, const double* restrict s, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44_vout(v + 4*i, s, vout + 4*i);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44(int n, double* restrict v, const double* restrict s)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44(v + 4*i, s);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44_vaccum(int n, const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44_vaccum(v + 4*i, s, vaccum + 4*i);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44_vout_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44_vout_scaled(v + 4*i, s, vout + 4*i, scale);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44_scaled(int n, double* restrict v, const double* restrict s, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44_scaled(v + 4*i, s, scale);
}

// general Nx4 matrix by symmetric 4x4
static inline void mul_genN4_sym44_vaccum_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_sym44_vaccum_scaled(v + 4*i, s, vaccum + 4*i, scale);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44_vout(int n, const double* restrict v, const double* restrict m, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44_vout(v + 4*i, m, vout + 4*i);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t_vout(int n, const double* restrict v, const double* restrict mt, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t_vout(v + 4*i, mt, vout + 4*i);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44(int n, double* restrict v, const double* restrict m)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44(v + 4*i, m);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t(int n, double* restrict v, const double* restrict mt)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t(v + 4*i, mt);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44_vaccum(int n, const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44_vaccum(v + 4*i, m, vaccum + 4*i);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t_vaccum(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t_vaccum(v + 4*i, mt, vaccum + 4*i);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44_vout_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44_vout_scaled(v + 4*i, m, vout + 4*i, scale);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t_vout_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t_vout_scaled(v + 4*i, mt, vout + 4*i, scale);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44_scaled(int n, double* restrict v, const double* restrict m, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44_scaled(v + 4*i, m, scale);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t_scaled(int n, double* restrict v, const double* restrict mt, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t_scaled(v + 4*i, mt, scale);
}


// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44_vaccum_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44_vaccum_scaled(v + 4*i, m, vaccum + 4*i, scale);
}

// general Nx4 matrix by general 4x4
static inline void mul_genN4_gen44t_vaccum_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec4_gen44t_vaccum_scaled(v + 4*i, mt, vaccum + 4*i, scale);
}



// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55_vout(const double* restrict v, const double* restrict s, double* restrict vout)
{
  vout[0] = s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4];
  vout[1] = s[1]*v[0] + s[5]*v[1] + s[6]*v[2] + s[7]*v[3] + s[8]*v[4];
  vout[2] = s[2]*v[0] + s[6]*v[1] + s[9]*v[2] + s[10]*v[3] + s[11]*v[4];
  vout[3] = s[3]*v[0] + s[7]*v[1] + s[10]*v[2] + s[12]*v[3] + s[13]*v[4];
  vout[4] = s[4]*v[0] + s[8]*v[1] + s[11]*v[2] + s[13]*v[3] + s[14]*v[4];
}
// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55(double* restrict v, const double* restrict s)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*t[3] + s[4]*v[4];
  v[1] = s[1]*t[0] + s[5]*t[1] + s[6]*t[2] + s[7]*t[3] + s[8]*v[4];
  v[2] = s[2]*t[0] + s[6]*t[1] + s[9]*t[2] + s[10]*t[3] + s[11]*v[4];
  v[3] = s[3]*t[0] + s[7]*t[1] + s[10]*t[2] + s[12]*t[3] + s[13]*v[4];
  v[4] = s[4]*t[0] + s[8]*t[1] + s[11]*t[2] + s[13]*t[3] + s[14]*v[4];
}
// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55_vaccum(const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  vaccum[0] += s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4];
  vaccum[1] += s[1]*v[0] + s[5]*v[1] + s[6]*v[2] + s[7]*v[3] + s[8]*v[4];
  vaccum[2] += s[2]*v[0] + s[6]*v[1] + s[9]*v[2] + s[10]*v[3] + s[11]*v[4];
  vaccum[3] += s[3]*v[0] + s[7]*v[1] + s[10]*v[2] + s[12]*v[3] + s[13]*v[4];
  vaccum[4] += s[4]*v[0] + s[8]*v[1] + s[11]*v[2] + s[13]*v[3] + s[14]*v[4];
}
// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55_vout_scaled(const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  vout[0] = scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4]);
  vout[1] = scale * (s[1]*v[0] + s[5]*v[1] + s[6]*v[2] + s[7]*v[3] + s[8]*v[4]);
  vout[2] = scale * (s[2]*v[0] + s[6]*v[1] + s[9]*v[2] + s[10]*v[3] + s[11]*v[4]);
  vout[3] = scale * (s[3]*v[0] + s[7]*v[1] + s[10]*v[2] + s[12]*v[3] + s[13]*v[4]);
  vout[4] = scale * (s[4]*v[0] + s[8]*v[1] + s[11]*v[2] + s[13]*v[3] + s[14]*v[4]);
}
// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55_scaled(double* restrict v, const double* restrict s, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*t[3] + s[4]*v[4]);
  v[1] = scale * (s[1]*t[0] + s[5]*t[1] + s[6]*t[2] + s[7]*t[3] + s[8]*v[4]);
  v[2] = scale * (s[2]*t[0] + s[6]*t[1] + s[9]*t[2] + s[10]*t[3] + s[11]*v[4]);
  v[3] = scale * (s[3]*t[0] + s[7]*t[1] + s[10]*t[2] + s[12]*t[3] + s[13]*v[4]);
  v[4] = scale * (s[4]*t[0] + s[8]*t[1] + s[11]*t[2] + s[13]*t[3] + s[14]*v[4]);
}
// 5-vector by symmetric 5x5
static inline void mul_vec5_sym55_vaccum_scaled(const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4]);
  vaccum[1] += scale * (s[1]*v[0] + s[5]*v[1] + s[6]*v[2] + s[7]*v[3] + s[8]*v[4]);
  vaccum[2] += scale * (s[2]*v[0] + s[6]*v[1] + s[9]*v[2] + s[10]*v[3] + s[11]*v[4]);
  vaccum[3] += scale * (s[3]*v[0] + s[7]*v[1] + s[10]*v[2] + s[12]*v[3] + s[13]*v[4]);
  vaccum[4] += scale * (s[4]*v[0] + s[8]*v[1] + s[11]*v[2] + s[13]*v[3] + s[14]*v[4]);
}

// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4];
  vout[1] = m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4];
}
// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52(double* restrict v, const double* restrict m)
{
  double t[1] = {v[0]};
  v[0] = m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4];
  v[1] = m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4];
}
// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4];
  vaccum[1] += m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4];
}
// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4]);
  vout[1] = scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4]);
}
// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4]);
  v[1] = scale * (m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4]);
}
// 5-vector by 5x2 matrix multiplication
static inline void mul_vec5_gen52_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4]);
  vaccum[1] += scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4]);
}

// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vout[1] = mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
}
// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t(double* restrict v, const double* restrict mt)
{
  double t[1] = {v[0]};
  v[0] = mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  v[1] = mt[5]*t[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
}
// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vaccum[1] += mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
}
// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vout[1] = scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
}
// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  v[1] = scale * (mt[5]*t[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
}
// 5-vector by 2x5-transposed matrix multiplication
static inline void mul_vec5_gen25t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vaccum[1] += scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
}

// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4];
  vout[1] = m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4];
  vout[2] = m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4];
}
// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4];
  v[1] = m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4];
  v[2] = m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4];
}
// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4];
  vaccum[1] += m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4];
  vaccum[2] += m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4];
}
// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4]);
  vout[1] = scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4]);
  vout[2] = scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4]);
}
// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4]);
  v[1] = scale * (m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4]);
  v[2] = scale * (m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4]);
}
// 5-vector by 5x3 matrix multiplication
static inline void mul_vec5_gen53_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4]);
  vaccum[1] += scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4]);
  vaccum[2] += scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4]);
}

// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vout[1] = mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vout[2] = mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
}
// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  v[1] = mt[5]*t[0] + mt[6]*t[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  v[2] = mt[10]*t[0] + mt[11]*t[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
}
// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vaccum[1] += mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vaccum[2] += mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
}
// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vout[1] = scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vout[2] = scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
}
// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  v[1] = scale * (mt[5]*t[0] + mt[6]*t[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  v[2] = scale * (mt[10]*t[0] + mt[11]*t[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
}
// 5-vector by 3x5-transposed matrix multiplication
static inline void mul_vec5_gen35t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vaccum[1] += scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vaccum[2] += scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
}

// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4];
  vout[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4];
  vout[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4];
  vout[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4];
}
// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3] + m[16]*v[4];
  v[1] = m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3] + m[17]*v[4];
  v[2] = m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3] + m[18]*v[4];
  v[3] = m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3] + m[19]*v[4];
}
// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4];
  vaccum[1] += m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4];
  vaccum[2] += m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4];
  vaccum[3] += m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4];
}
// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4]);
  vout[1] = scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4]);
  vout[2] = scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4]);
  vout[3] = scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4]);
}
// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3] + m[16]*v[4]);
  v[1] = scale * (m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3] + m[17]*v[4]);
  v[2] = scale * (m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3] + m[18]*v[4]);
  v[3] = scale * (m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3] + m[19]*v[4]);
}
// 5-vector by 5x4 matrix multiplication
static inline void mul_vec5_gen54_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4]);
  vaccum[1] += scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4]);
  vaccum[2] += scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4]);
  vaccum[3] += scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4]);
}

// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vout[1] = mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vout[2] = mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vout[3] = mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
}
// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3] + mt[4]*v[4];
  v[1] = mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*v[3] + mt[9]*v[4];
  v[2] = mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*v[3] + mt[14]*v[4];
  v[3] = mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*v[3] + mt[19]*v[4];
}
// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vaccum[1] += mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vaccum[2] += mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vaccum[3] += mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
}
// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vout[1] = scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vout[2] = scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vout[3] = scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
}
// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3] + mt[4]*v[4]);
  v[1] = scale * (mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*v[3] + mt[9]*v[4]);
  v[2] = scale * (mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*v[3] + mt[14]*v[4]);
  v[3] = scale * (mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*v[3] + mt[19]*v[4]);
}
// 5-vector by 4x5-transposed matrix multiplication
static inline void mul_vec5_gen45t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vaccum[1] += scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vaccum[2] += scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vaccum[3] += scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
}

// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4];
  vout[1] = m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4];
  vout[2] = m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4];
  vout[3] = m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4];
  vout[4] = m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4];
}
// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55(double* restrict v, const double* restrict m)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3] + m[20]*v[4];
  v[1] = m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3] + m[21]*v[4];
  v[2] = m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3] + m[22]*v[4];
  v[3] = m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3] + m[23]*v[4];
  v[4] = m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3] + m[24]*v[4];
}
// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4];
  vaccum[1] += m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4];
  vaccum[2] += m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4];
  vaccum[3] += m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4];
  vaccum[4] += m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4];
}
// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4]);
  vout[1] = scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4]);
  vout[2] = scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4]);
  vout[3] = scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4]);
  vout[4] = scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4]);
}
// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3] + m[20]*v[4]);
  v[1] = scale * (m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3] + m[21]*v[4]);
  v[2] = scale * (m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3] + m[22]*v[4]);
  v[3] = scale * (m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3] + m[23]*v[4]);
  v[4] = scale * (m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3] + m[24]*v[4]);
}
// 5-vector by 5x5 matrix multiplication
static inline void mul_vec5_gen55_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4]);
  vaccum[1] += scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4]);
  vaccum[2] += scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4]);
  vaccum[3] += scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4]);
  vaccum[4] += scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4]);
}

// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vout[1] = mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vout[2] = mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vout[3] = mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
  vout[4] = mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4];
}
// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t(double* restrict v, const double* restrict mt)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*v[4];
  v[1] = mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*t[3] + mt[9]*v[4];
  v[2] = mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*t[3] + mt[14]*v[4];
  v[3] = mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*t[3] + mt[19]*v[4];
  v[4] = mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3] + mt[24]*v[4];
}
// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vaccum[1] += mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vaccum[2] += mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vaccum[3] += mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
  vaccum[4] += mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4];
}
// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vout[1] = scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vout[2] = scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vout[3] = scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
  vout[4] = scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4]);
}
// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*v[4]);
  v[1] = scale * (mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*t[3] + mt[9]*v[4]);
  v[2] = scale * (mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*t[3] + mt[14]*v[4]);
  v[3] = scale * (mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*t[3] + mt[19]*v[4]);
  v[4] = scale * (mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3] + mt[24]*v[4]);
}
// 5-vector by 5x5-transposed matrix multiplication
static inline void mul_vec5_gen55t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vaccum[1] += scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vaccum[2] += scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vaccum[3] += scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
  vaccum[4] += scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4]);
}

// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4];
  vout[1] = m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4];
  vout[2] = m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4];
  vout[3] = m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4];
  vout[4] = m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4];
  vout[5] = m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4];
}
// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56(double* restrict v, const double* restrict m)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3] + m[24]*t[4];
  v[1] = m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3] + m[25]*t[4];
  v[2] = m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3] + m[26]*t[4];
  v[3] = m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3] + m[27]*t[4];
  v[4] = m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3] + m[28]*t[4];
  v[5] = m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3] + m[29]*t[4];
}
// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4];
  vaccum[1] += m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4];
  vaccum[2] += m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4];
  vaccum[3] += m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4];
  vaccum[4] += m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4];
  vaccum[5] += m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4];
}
// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4]);
  vout[1] = scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4]);
  vout[2] = scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4]);
  vout[3] = scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4]);
  vout[4] = scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4]);
  vout[5] = scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4]);
}
// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = scale * (m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3] + m[24]*t[4]);
  v[1] = scale * (m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3] + m[25]*t[4]);
  v[2] = scale * (m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3] + m[26]*t[4]);
  v[3] = scale * (m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3] + m[27]*t[4]);
  v[4] = scale * (m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3] + m[28]*t[4]);
  v[5] = scale * (m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3] + m[29]*t[4]);
}
// 5-vector by 5x6 matrix multiplication
static inline void mul_vec5_gen56_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4]);
  vaccum[1] += scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4]);
  vaccum[2] += scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4]);
  vaccum[3] += scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4]);
  vaccum[4] += scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4]);
  vaccum[5] += scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4]);
}

// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vout[1] = mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vout[2] = mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vout[3] = mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
  vout[4] = mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4];
  vout[5] = mt[25]*v[0] + mt[26]*v[1] + mt[27]*v[2] + mt[28]*v[3] + mt[29]*v[4];
}
// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t(double* restrict v, const double* restrict mt)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*t[4];
  v[1] = mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*t[3] + mt[9]*t[4];
  v[2] = mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*t[3] + mt[14]*t[4];
  v[3] = mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*t[3] + mt[19]*t[4];
  v[4] = mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3] + mt[24]*t[4];
  v[5] = mt[25]*t[0] + mt[26]*t[1] + mt[27]*t[2] + mt[28]*t[3] + mt[29]*t[4];
}
// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4];
  vaccum[1] += mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4];
  vaccum[2] += mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4];
  vaccum[3] += mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4];
  vaccum[4] += mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4];
  vaccum[5] += mt[25]*v[0] + mt[26]*v[1] + mt[27]*v[2] + mt[28]*v[3] + mt[29]*v[4];
}
// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vout[1] = scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vout[2] = scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vout[3] = scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
  vout[4] = scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4]);
  vout[5] = scale * (mt[25]*v[0] + mt[26]*v[1] + mt[27]*v[2] + mt[28]*v[3] + mt[29]*v[4]);
}
// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*t[4]);
  v[1] = scale * (mt[5]*t[0] + mt[6]*t[1] + mt[7]*t[2] + mt[8]*t[3] + mt[9]*t[4]);
  v[2] = scale * (mt[10]*t[0] + mt[11]*t[1] + mt[12]*t[2] + mt[13]*t[3] + mt[14]*t[4]);
  v[3] = scale * (mt[15]*t[0] + mt[16]*t[1] + mt[17]*t[2] + mt[18]*t[3] + mt[19]*t[4]);
  v[4] = scale * (mt[20]*t[0] + mt[21]*t[1] + mt[22]*t[2] + mt[23]*t[3] + mt[24]*t[4]);
  v[5] = scale * (mt[25]*t[0] + mt[26]*t[1] + mt[27]*t[2] + mt[28]*t[3] + mt[29]*t[4]);
}
// 5-vector by 6x5-transposed matrix multiplication
static inline void mul_vec5_gen65t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4]);
  vaccum[1] += scale * (mt[5]*v[0] + mt[6]*v[1] + mt[7]*v[2] + mt[8]*v[3] + mt[9]*v[4]);
  vaccum[2] += scale * (mt[10]*v[0] + mt[11]*v[1] + mt[12]*v[2] + mt[13]*v[3] + mt[14]*v[4]);
  vaccum[3] += scale * (mt[15]*v[0] + mt[16]*v[1] + mt[17]*v[2] + mt[18]*v[3] + mt[19]*v[4]);
  vaccum[4] += scale * (mt[20]*v[0] + mt[21]*v[1] + mt[22]*v[2] + mt[23]*v[3] + mt[24]*v[4]);
  vaccum[5] += scale * (mt[25]*v[0] + mt[26]*v[1] + mt[27]*v[2] + mt[28]*v[3] + mt[29]*v[4]);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55_vout(int n, const double* restrict v, const double* restrict s, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55_vout(v + 5*i, s, vout + 5*i);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55(int n, double* restrict v, const double* restrict s)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55(v + 5*i, s);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55_vaccum(int n, const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55_vaccum(v + 5*i, s, vaccum + 5*i);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55_vout_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55_vout_scaled(v + 5*i, s, vout + 5*i, scale);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55_scaled(int n, double* restrict v, const double* restrict s, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55_scaled(v + 5*i, s, scale);
}

// general Nx5 matrix by symmetric 5x5
static inline void mul_genN5_sym55_vaccum_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_sym55_vaccum_scaled(v + 5*i, s, vaccum + 5*i, scale);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55_vout(int n, const double* restrict v, const double* restrict m, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55_vout(v + 5*i, m, vout + 5*i);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t_vout(int n, const double* restrict v, const double* restrict mt, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t_vout(v + 5*i, mt, vout + 5*i);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55(int n, double* restrict v, const double* restrict m)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55(v + 5*i, m);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t(int n, double* restrict v, const double* restrict mt)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t(v + 5*i, mt);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55_vaccum(int n, const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55_vaccum(v + 5*i, m, vaccum + 5*i);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t_vaccum(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t_vaccum(v + 5*i, mt, vaccum + 5*i);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55_vout_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55_vout_scaled(v + 5*i, m, vout + 5*i, scale);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t_vout_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t_vout_scaled(v + 5*i, mt, vout + 5*i, scale);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55_scaled(int n, double* restrict v, const double* restrict m, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55_scaled(v + 5*i, m, scale);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t_scaled(int n, double* restrict v, const double* restrict mt, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t_scaled(v + 5*i, mt, scale);
}


// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55_vaccum_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55_vaccum_scaled(v + 5*i, m, vaccum + 5*i, scale);
}

// general Nx5 matrix by general 5x5
static inline void mul_genN5_gen55t_vaccum_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec5_gen55t_vaccum_scaled(v + 5*i, mt, vaccum + 5*i, scale);
}



// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66_vout(const double* restrict v, const double* restrict s, double* restrict vout)
{
  vout[0] = s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4] + s[5]*v[5];
  vout[1] = s[1]*v[0] + s[6]*v[1] + s[7]*v[2] + s[8]*v[3] + s[9]*v[4] + s[10]*v[5];
  vout[2] = s[2]*v[0] + s[7]*v[1] + s[11]*v[2] + s[12]*v[3] + s[13]*v[4] + s[14]*v[5];
  vout[3] = s[3]*v[0] + s[8]*v[1] + s[12]*v[2] + s[15]*v[3] + s[16]*v[4] + s[17]*v[5];
  vout[4] = s[4]*v[0] + s[9]*v[1] + s[13]*v[2] + s[16]*v[3] + s[18]*v[4] + s[19]*v[5];
  vout[5] = s[5]*v[0] + s[10]*v[1] + s[14]*v[2] + s[17]*v[3] + s[19]*v[4] + s[20]*v[5];
}
// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66(double* restrict v, const double* restrict s)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*t[3] + s[4]*t[4] + s[5]*v[5];
  v[1] = s[1]*t[0] + s[6]*t[1] + s[7]*t[2] + s[8]*t[3] + s[9]*t[4] + s[10]*v[5];
  v[2] = s[2]*t[0] + s[7]*t[1] + s[11]*t[2] + s[12]*t[3] + s[13]*t[4] + s[14]*v[5];
  v[3] = s[3]*t[0] + s[8]*t[1] + s[12]*t[2] + s[15]*t[3] + s[16]*t[4] + s[17]*v[5];
  v[4] = s[4]*t[0] + s[9]*t[1] + s[13]*t[2] + s[16]*t[3] + s[18]*t[4] + s[19]*v[5];
  v[5] = s[5]*t[0] + s[10]*t[1] + s[14]*t[2] + s[17]*t[3] + s[19]*t[4] + s[20]*v[5];
}
// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66_vaccum(const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  vaccum[0] += s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4] + s[5]*v[5];
  vaccum[1] += s[1]*v[0] + s[6]*v[1] + s[7]*v[2] + s[8]*v[3] + s[9]*v[4] + s[10]*v[5];
  vaccum[2] += s[2]*v[0] + s[7]*v[1] + s[11]*v[2] + s[12]*v[3] + s[13]*v[4] + s[14]*v[5];
  vaccum[3] += s[3]*v[0] + s[8]*v[1] + s[12]*v[2] + s[15]*v[3] + s[16]*v[4] + s[17]*v[5];
  vaccum[4] += s[4]*v[0] + s[9]*v[1] + s[13]*v[2] + s[16]*v[3] + s[18]*v[4] + s[19]*v[5];
  vaccum[5] += s[5]*v[0] + s[10]*v[1] + s[14]*v[2] + s[17]*v[3] + s[19]*v[4] + s[20]*v[5];
}
// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66_vout_scaled(const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  vout[0] = scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4] + s[5]*v[5]);
  vout[1] = scale * (s[1]*v[0] + s[6]*v[1] + s[7]*v[2] + s[8]*v[3] + s[9]*v[4] + s[10]*v[5]);
  vout[2] = scale * (s[2]*v[0] + s[7]*v[1] + s[11]*v[2] + s[12]*v[3] + s[13]*v[4] + s[14]*v[5]);
  vout[3] = scale * (s[3]*v[0] + s[8]*v[1] + s[12]*v[2] + s[15]*v[3] + s[16]*v[4] + s[17]*v[5]);
  vout[4] = scale * (s[4]*v[0] + s[9]*v[1] + s[13]*v[2] + s[16]*v[3] + s[18]*v[4] + s[19]*v[5]);
  vout[5] = scale * (s[5]*v[0] + s[10]*v[1] + s[14]*v[2] + s[17]*v[3] + s[19]*v[4] + s[20]*v[5]);
}
// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66_scaled(double* restrict v, const double* restrict s, double scale)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = scale * (s[0]*t[0] + s[1]*t[1] + s[2]*t[2] + s[3]*t[3] + s[4]*t[4] + s[5]*v[5]);
  v[1] = scale * (s[1]*t[0] + s[6]*t[1] + s[7]*t[2] + s[8]*t[3] + s[9]*t[4] + s[10]*v[5]);
  v[2] = scale * (s[2]*t[0] + s[7]*t[1] + s[11]*t[2] + s[12]*t[3] + s[13]*t[4] + s[14]*v[5]);
  v[3] = scale * (s[3]*t[0] + s[8]*t[1] + s[12]*t[2] + s[15]*t[3] + s[16]*t[4] + s[17]*v[5]);
  v[4] = scale * (s[4]*t[0] + s[9]*t[1] + s[13]*t[2] + s[16]*t[3] + s[18]*t[4] + s[19]*v[5]);
  v[5] = scale * (s[5]*t[0] + s[10]*t[1] + s[14]*t[2] + s[17]*t[3] + s[19]*t[4] + s[20]*v[5]);
}
// 6-vector by symmetric 6x6
static inline void mul_vec6_sym66_vaccum_scaled(const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (s[0]*v[0] + s[1]*v[1] + s[2]*v[2] + s[3]*v[3] + s[4]*v[4] + s[5]*v[5]);
  vaccum[1] += scale * (s[1]*v[0] + s[6]*v[1] + s[7]*v[2] + s[8]*v[3] + s[9]*v[4] + s[10]*v[5]);
  vaccum[2] += scale * (s[2]*v[0] + s[7]*v[1] + s[11]*v[2] + s[12]*v[3] + s[13]*v[4] + s[14]*v[5]);
  vaccum[3] += scale * (s[3]*v[0] + s[8]*v[1] + s[12]*v[2] + s[15]*v[3] + s[16]*v[4] + s[17]*v[5]);
  vaccum[4] += scale * (s[4]*v[0] + s[9]*v[1] + s[13]*v[2] + s[16]*v[3] + s[18]*v[4] + s[19]*v[5]);
  vaccum[5] += scale * (s[5]*v[0] + s[10]*v[1] + s[14]*v[2] + s[17]*v[3] + s[19]*v[4] + s[20]*v[5]);
}

// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5];
  vout[1] = m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5];
}
// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62(double* restrict v, const double* restrict m)
{
  double t[1] = {v[0]};
  v[0] = m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5];
  v[1] = m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5];
}
// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5];
  vaccum[1] += m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5];
}
// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5]);
  vout[1] = scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5]);
}
// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (m[0]*t[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5]);
  v[1] = scale * (m[1]*t[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5]);
}
// 6-vector by 6x2 matrix multiplication
static inline void mul_vec6_gen62_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[2]*v[1] + m[4]*v[2] + m[6]*v[3] + m[8]*v[4] + m[10]*v[5]);
  vaccum[1] += scale * (m[1]*v[0] + m[3]*v[1] + m[5]*v[2] + m[7]*v[3] + m[9]*v[4] + m[11]*v[5]);
}

// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vout[1] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
}
// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t(double* restrict v, const double* restrict mt)
{
  double t[1] = {v[0]};
  v[0] = mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  v[1] = mt[6]*t[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
}
// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vaccum[1] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
}
// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vout[1] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
}
// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[1] = {v[0]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  v[1] = scale * (mt[6]*t[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
}
// 6-vector by 2x6-transposed matrix multiplication
static inline void mul_vec6_gen26t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vaccum[1] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
}

// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5];
  vout[1] = m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5];
  vout[2] = m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5];
}
// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63(double* restrict v, const double* restrict m)
{
  double t[2] = {v[0], v[1]};
  v[0] = m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5];
  v[1] = m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5];
  v[2] = m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5];
}
// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5];
  vaccum[1] += m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5];
  vaccum[2] += m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5];
}
// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5]);
  vout[1] = scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5]);
  vout[2] = scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5]);
}
// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (m[0]*t[0] + m[3]*t[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5]);
  v[1] = scale * (m[1]*t[0] + m[4]*t[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5]);
  v[2] = scale * (m[2]*t[0] + m[5]*t[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5]);
}
// 6-vector by 6x3 matrix multiplication
static inline void mul_vec6_gen63_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[3]*v[1] + m[6]*v[2] + m[9]*v[3] + m[12]*v[4] + m[15]*v[5]);
  vaccum[1] += scale * (m[1]*v[0] + m[4]*v[1] + m[7]*v[2] + m[10]*v[3] + m[13]*v[4] + m[16]*v[5]);
  vaccum[2] += scale * (m[2]*v[0] + m[5]*v[1] + m[8]*v[2] + m[11]*v[3] + m[14]*v[4] + m[17]*v[5]);
}

// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vout[1] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vout[2] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
}
// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t(double* restrict v, const double* restrict mt)
{
  double t[2] = {v[0], v[1]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  v[1] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  v[2] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
}
// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vaccum[1] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vaccum[2] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
}
// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vout[1] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vout[2] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
}
// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[2] = {v[0], v[1]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  v[1] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  v[2] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
}
// 6-vector by 3x6-transposed matrix multiplication
static inline void mul_vec6_gen36t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vaccum[1] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vaccum[2] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
}

// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5];
  vout[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5];
  vout[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5];
  vout[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5];
}
// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64(double* restrict v, const double* restrict m)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5];
  v[1] = m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5];
  v[2] = m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5];
  v[3] = m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5];
}
// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5];
  vaccum[1] += m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5];
  vaccum[2] += m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5];
  vaccum[3] += m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5];
}
// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5]);
  vout[1] = scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5]);
  vout[2] = scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5]);
  vout[3] = scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5]);
}
// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (m[0]*t[0] + m[4]*t[1] + m[8]*t[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5]);
  v[1] = scale * (m[1]*t[0] + m[5]*t[1] + m[9]*t[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5]);
  v[2] = scale * (m[2]*t[0] + m[6]*t[1] + m[10]*t[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5]);
  v[3] = scale * (m[3]*t[0] + m[7]*t[1] + m[11]*t[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5]);
}
// 6-vector by 6x4 matrix multiplication
static inline void mul_vec6_gen64_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3] + m[16]*v[4] + m[20]*v[5]);
  vaccum[1] += scale * (m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3] + m[17]*v[4] + m[21]*v[5]);
  vaccum[2] += scale * (m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3] + m[18]*v[4] + m[22]*v[5]);
  vaccum[3] += scale * (m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3] + m[19]*v[4] + m[23]*v[5]);
}

// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vout[1] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vout[2] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vout[3] = mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
}
// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t(double* restrict v, const double* restrict mt)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  v[1] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  v[2] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  v[3] = mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
}
// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vaccum[1] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vaccum[2] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vaccum[3] += mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
}
// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vout[1] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vout[2] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vout[3] = scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
}
// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[3] = {v[0], v[1], v[2]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  v[1] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  v[2] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  v[3] = scale * (mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
}
// 6-vector by 4x6-transposed matrix multiplication
static inline void mul_vec6_gen46t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vaccum[1] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vaccum[2] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vaccum[3] += scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
}

// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4] + m[25]*v[5];
  vout[1] = m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4] + m[26]*v[5];
  vout[2] = m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4] + m[27]*v[5];
  vout[3] = m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4] + m[28]*v[5];
  vout[4] = m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4] + m[29]*v[5];
}
// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65(double* restrict v, const double* restrict m)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3] + m[20]*v[4] + m[25]*v[5];
  v[1] = m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3] + m[21]*v[4] + m[26]*v[5];
  v[2] = m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3] + m[22]*v[4] + m[27]*v[5];
  v[3] = m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3] + m[23]*v[4] + m[28]*v[5];
  v[4] = m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3] + m[24]*v[4] + m[29]*v[5];
}
// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4] + m[25]*v[5];
  vaccum[1] += m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4] + m[26]*v[5];
  vaccum[2] += m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4] + m[27]*v[5];
  vaccum[3] += m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4] + m[28]*v[5];
  vaccum[4] += m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4] + m[29]*v[5];
}
// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4] + m[25]*v[5]);
  vout[1] = scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4] + m[26]*v[5]);
  vout[2] = scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4] + m[27]*v[5]);
  vout[3] = scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4] + m[28]*v[5]);
  vout[4] = scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4] + m[29]*v[5]);
}
// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (m[0]*t[0] + m[5]*t[1] + m[10]*t[2] + m[15]*t[3] + m[20]*v[4] + m[25]*v[5]);
  v[1] = scale * (m[1]*t[0] + m[6]*t[1] + m[11]*t[2] + m[16]*t[3] + m[21]*v[4] + m[26]*v[5]);
  v[2] = scale * (m[2]*t[0] + m[7]*t[1] + m[12]*t[2] + m[17]*t[3] + m[22]*v[4] + m[27]*v[5]);
  v[3] = scale * (m[3]*t[0] + m[8]*t[1] + m[13]*t[2] + m[18]*t[3] + m[23]*v[4] + m[28]*v[5]);
  v[4] = scale * (m[4]*t[0] + m[9]*t[1] + m[14]*t[2] + m[19]*t[3] + m[24]*v[4] + m[29]*v[5]);
}
// 6-vector by 6x5 matrix multiplication
static inline void mul_vec6_gen65_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[5]*v[1] + m[10]*v[2] + m[15]*v[3] + m[20]*v[4] + m[25]*v[5]);
  vaccum[1] += scale * (m[1]*v[0] + m[6]*v[1] + m[11]*v[2] + m[16]*v[3] + m[21]*v[4] + m[26]*v[5]);
  vaccum[2] += scale * (m[2]*v[0] + m[7]*v[1] + m[12]*v[2] + m[17]*v[3] + m[22]*v[4] + m[27]*v[5]);
  vaccum[3] += scale * (m[3]*v[0] + m[8]*v[1] + m[13]*v[2] + m[18]*v[3] + m[23]*v[4] + m[28]*v[5]);
  vaccum[4] += scale * (m[4]*v[0] + m[9]*v[1] + m[14]*v[2] + m[19]*v[3] + m[24]*v[4] + m[29]*v[5]);
}

// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vout[1] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vout[2] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vout[3] = mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
  vout[4] = mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5];
}
// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t(double* restrict v, const double* restrict mt)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*v[4] + mt[5]*v[5];
  v[1] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*t[3] + mt[10]*v[4] + mt[11]*v[5];
  v[2] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3] + mt[16]*v[4] + mt[17]*v[5];
  v[3] = mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*t[3] + mt[22]*v[4] + mt[23]*v[5];
  v[4] = mt[24]*t[0] + mt[25]*t[1] + mt[26]*t[2] + mt[27]*t[3] + mt[28]*v[4] + mt[29]*v[5];
}
// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vaccum[1] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vaccum[2] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vaccum[3] += mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
  vaccum[4] += mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5];
}
// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vout[1] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vout[2] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vout[3] = scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
  vout[4] = scale * (mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5]);
}
// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[4] = {v[0], v[1], v[2], v[3]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*v[4] + mt[5]*v[5]);
  v[1] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*t[3] + mt[10]*v[4] + mt[11]*v[5]);
  v[2] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3] + mt[16]*v[4] + mt[17]*v[5]);
  v[3] = scale * (mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*t[3] + mt[22]*v[4] + mt[23]*v[5]);
  v[4] = scale * (mt[24]*t[0] + mt[25]*t[1] + mt[26]*t[2] + mt[27]*t[3] + mt[28]*v[4] + mt[29]*v[5]);
}
// 6-vector by 5x6-transposed matrix multiplication
static inline void mul_vec6_gen56t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vaccum[1] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vaccum[2] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vaccum[3] += scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
  vaccum[4] += scale * (mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5]);
}

// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66_vout(const double* restrict v, const double* restrict m, double* restrict vout)
{
  vout[0] = m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4] + m[30]*v[5];
  vout[1] = m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4] + m[31]*v[5];
  vout[2] = m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4] + m[32]*v[5];
  vout[3] = m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4] + m[33]*v[5];
  vout[4] = m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4] + m[34]*v[5];
  vout[5] = m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4] + m[35]*v[5];
}
// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66(double* restrict v, const double* restrict m)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3] + m[24]*t[4] + m[30]*v[5];
  v[1] = m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3] + m[25]*t[4] + m[31]*v[5];
  v[2] = m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3] + m[26]*t[4] + m[32]*v[5];
  v[3] = m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3] + m[27]*t[4] + m[33]*v[5];
  v[4] = m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3] + m[28]*t[4] + m[34]*v[5];
  v[5] = m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3] + m[29]*t[4] + m[35]*v[5];
}
// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66_vaccum(const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  vaccum[0] += m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4] + m[30]*v[5];
  vaccum[1] += m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4] + m[31]*v[5];
  vaccum[2] += m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4] + m[32]*v[5];
  vaccum[3] += m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4] + m[33]*v[5];
  vaccum[4] += m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4] + m[34]*v[5];
  vaccum[5] += m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4] + m[35]*v[5];
}
// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66_vout_scaled(const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  vout[0] = scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4] + m[30]*v[5]);
  vout[1] = scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4] + m[31]*v[5]);
  vout[2] = scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4] + m[32]*v[5]);
  vout[3] = scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4] + m[33]*v[5]);
  vout[4] = scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4] + m[34]*v[5]);
  vout[5] = scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4] + m[35]*v[5]);
}
// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66_scaled(double* restrict v, const double* restrict m, double scale)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = scale * (m[0]*t[0] + m[6]*t[1] + m[12]*t[2] + m[18]*t[3] + m[24]*t[4] + m[30]*v[5]);
  v[1] = scale * (m[1]*t[0] + m[7]*t[1] + m[13]*t[2] + m[19]*t[3] + m[25]*t[4] + m[31]*v[5]);
  v[2] = scale * (m[2]*t[0] + m[8]*t[1] + m[14]*t[2] + m[20]*t[3] + m[26]*t[4] + m[32]*v[5]);
  v[3] = scale * (m[3]*t[0] + m[9]*t[1] + m[15]*t[2] + m[21]*t[3] + m[27]*t[4] + m[33]*v[5]);
  v[4] = scale * (m[4]*t[0] + m[10]*t[1] + m[16]*t[2] + m[22]*t[3] + m[28]*t[4] + m[34]*v[5]);
  v[5] = scale * (m[5]*t[0] + m[11]*t[1] + m[17]*t[2] + m[23]*t[3] + m[29]*t[4] + m[35]*v[5]);
}
// 6-vector by 6x6 matrix multiplication
static inline void mul_vec6_gen66_vaccum_scaled(const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (m[0]*v[0] + m[6]*v[1] + m[12]*v[2] + m[18]*v[3] + m[24]*v[4] + m[30]*v[5]);
  vaccum[1] += scale * (m[1]*v[0] + m[7]*v[1] + m[13]*v[2] + m[19]*v[3] + m[25]*v[4] + m[31]*v[5]);
  vaccum[2] += scale * (m[2]*v[0] + m[8]*v[1] + m[14]*v[2] + m[20]*v[3] + m[26]*v[4] + m[32]*v[5]);
  vaccum[3] += scale * (m[3]*v[0] + m[9]*v[1] + m[15]*v[2] + m[21]*v[3] + m[27]*v[4] + m[33]*v[5]);
  vaccum[4] += scale * (m[4]*v[0] + m[10]*v[1] + m[16]*v[2] + m[22]*v[3] + m[28]*v[4] + m[34]*v[5]);
  vaccum[5] += scale * (m[5]*v[0] + m[11]*v[1] + m[17]*v[2] + m[23]*v[3] + m[29]*v[4] + m[35]*v[5]);
}

// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t_vout(const double* restrict v, const double* restrict mt, double* restrict vout)
{
  vout[0] = mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vout[1] = mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vout[2] = mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vout[3] = mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
  vout[4] = mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5];
  vout[5] = mt[30]*v[0] + mt[31]*v[1] + mt[32]*v[2] + mt[33]*v[3] + mt[34]*v[4] + mt[35]*v[5];
}
// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t(double* restrict v, const double* restrict mt)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*t[4] + mt[5]*v[5];
  v[1] = mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*t[3] + mt[10]*t[4] + mt[11]*v[5];
  v[2] = mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3] + mt[16]*t[4] + mt[17]*v[5];
  v[3] = mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*t[3] + mt[22]*t[4] + mt[23]*v[5];
  v[4] = mt[24]*t[0] + mt[25]*t[1] + mt[26]*t[2] + mt[27]*t[3] + mt[28]*t[4] + mt[29]*v[5];
  v[5] = mt[30]*t[0] + mt[31]*t[1] + mt[32]*t[2] + mt[33]*t[3] + mt[34]*t[4] + mt[35]*v[5];
}
// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t_vaccum(const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  vaccum[0] += mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5];
  vaccum[1] += mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5];
  vaccum[2] += mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5];
  vaccum[3] += mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5];
  vaccum[4] += mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5];
  vaccum[5] += mt[30]*v[0] + mt[31]*v[1] + mt[32]*v[2] + mt[33]*v[3] + mt[34]*v[4] + mt[35]*v[5];
}
// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t_vout_scaled(const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  vout[0] = scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vout[1] = scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vout[2] = scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vout[3] = scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
  vout[4] = scale * (mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5]);
  vout[5] = scale * (mt[30]*v[0] + mt[31]*v[1] + mt[32]*v[2] + mt[33]*v[3] + mt[34]*v[4] + mt[35]*v[5]);
}
// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t_scaled(double* restrict v, const double* restrict mt, double scale)
{
  double t[5] = {v[0], v[1], v[2], v[3], v[4]};
  v[0] = scale * (mt[0]*t[0] + mt[1]*t[1] + mt[2]*t[2] + mt[3]*t[3] + mt[4]*t[4] + mt[5]*v[5]);
  v[1] = scale * (mt[6]*t[0] + mt[7]*t[1] + mt[8]*t[2] + mt[9]*t[3] + mt[10]*t[4] + mt[11]*v[5]);
  v[2] = scale * (mt[12]*t[0] + mt[13]*t[1] + mt[14]*t[2] + mt[15]*t[3] + mt[16]*t[4] + mt[17]*v[5]);
  v[3] = scale * (mt[18]*t[0] + mt[19]*t[1] + mt[20]*t[2] + mt[21]*t[3] + mt[22]*t[4] + mt[23]*v[5]);
  v[4] = scale * (mt[24]*t[0] + mt[25]*t[1] + mt[26]*t[2] + mt[27]*t[3] + mt[28]*t[4] + mt[29]*v[5]);
  v[5] = scale * (mt[30]*t[0] + mt[31]*t[1] + mt[32]*t[2] + mt[33]*t[3] + mt[34]*t[4] + mt[35]*v[5]);
}
// 6-vector by 6x6-transposed matrix multiplication
static inline void mul_vec6_gen66t_vaccum_scaled(const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  vaccum[0] += scale * (mt[0]*v[0] + mt[1]*v[1] + mt[2]*v[2] + mt[3]*v[3] + mt[4]*v[4] + mt[5]*v[5]);
  vaccum[1] += scale * (mt[6]*v[0] + mt[7]*v[1] + mt[8]*v[2] + mt[9]*v[3] + mt[10]*v[4] + mt[11]*v[5]);
  vaccum[2] += scale * (mt[12]*v[0] + mt[13]*v[1] + mt[14]*v[2] + mt[15]*v[3] + mt[16]*v[4] + mt[17]*v[5]);
  vaccum[3] += scale * (mt[18]*v[0] + mt[19]*v[1] + mt[20]*v[2] + mt[21]*v[3] + mt[22]*v[4] + mt[23]*v[5]);
  vaccum[4] += scale * (mt[24]*v[0] + mt[25]*v[1] + mt[26]*v[2] + mt[27]*v[3] + mt[28]*v[4] + mt[29]*v[5]);
  vaccum[5] += scale * (mt[30]*v[0] + mt[31]*v[1] + mt[32]*v[2] + mt[33]*v[3] + mt[34]*v[4] + mt[35]*v[5]);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66_vout(int n, const double* restrict v, const double* restrict s, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66_vout(v + 6*i, s, vout + 6*i);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66(int n, double* restrict v, const double* restrict s)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66(v + 6*i, s);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66_vaccum(int n, const double* restrict v, const double* restrict s, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66_vaccum(v + 6*i, s, vaccum + 6*i);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66_vout_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66_vout_scaled(v + 6*i, s, vout + 6*i, scale);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66_scaled(int n, double* restrict v, const double* restrict s, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66_scaled(v + 6*i, s, scale);
}

// general Nx6 matrix by symmetric 6x6
static inline void mul_genN6_sym66_vaccum_scaled(int n, const double* restrict v, const double* restrict s, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_sym66_vaccum_scaled(v + 6*i, s, vaccum + 6*i, scale);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66_vout(int n, const double* restrict v, const double* restrict m, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66_vout(v + 6*i, m, vout + 6*i);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t_vout(int n, const double* restrict v, const double* restrict mt, double* restrict vout)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t_vout(v + 6*i, mt, vout + 6*i);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66(int n, double* restrict v, const double* restrict m)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66(v + 6*i, m);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t(int n, double* restrict v, const double* restrict mt)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t(v + 6*i, mt);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66_vaccum(int n, const double* restrict v, const double* restrict m, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66_vaccum(v + 6*i, m, vaccum + 6*i);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t_vaccum(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t_vaccum(v + 6*i, mt, vaccum + 6*i);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66_vout_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66_vout_scaled(v + 6*i, m, vout + 6*i, scale);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t_vout_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vout, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t_vout_scaled(v + 6*i, mt, vout + 6*i, scale);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66_scaled(int n, double* restrict v, const double* restrict m, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66_scaled(v + 6*i, m, scale);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t_scaled(int n, double* restrict v, const double* restrict mt, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t_scaled(v + 6*i, mt, scale);
}


// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66_vaccum_scaled(int n, const double* restrict v, const double* restrict m, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66_vaccum_scaled(v + 6*i, m, vaccum + 6*i, scale);
}

// general Nx6 matrix by general 6x6
static inline void mul_genN6_gen66t_vaccum_scaled(int n, const double* restrict v, const double* restrict mt, double* restrict vaccum, double scale)
{
  for(int i=0; i<n; i++)
    mul_vec6_gen66t_vaccum_scaled(v + 6*i, mt, vaccum + 6*i, scale);
}



// (%i2) sym3 : matrix([m0,m1,m2],
//                      [m1,m3,m4],
//                      [m2,m4,m5]);

// (%o2) matrix([m0,m1,m2],[m1,m3,m4],[m2,m4,m5])
// (%i3) sym3_a : matrix([a0,a1,a2],
//                       [a1,a3,a4],
//                       [a2,a4,a5]);

// (%o3) matrix([a0,a1,a2],[a1,a3,a4],[a2,a4,a5])
// (%i4) sym3_b : matrix([b0,b1,b2],
//                       [b1,b3,b4],
//                       [b2,b4,b5]);

// (%o4) matrix([b0,b1,b2],[b1,b3,b4],[b2,b4,b5])
// (%i5) sym3_a . sym3_b . sym3_a;

// (%o5) matrix([a2*(a2*b5+a1*b4+a0*b2)+a1*(a2*b4+a1*b3+a0*b1) + a0*(a2*b2+a1*b1+a0*b0), a2*(a4*b5+a3*b4+a1*b2)+a1*(a4*b4+a3*b3+a1*b1) + a0*(a4*b2+a3*b1+a1*b0), a2*(a5*b5+a4*b4+a2*b2)+a1*(a5*b4+a4*b3+a2*b1) + a0*(a5*b2+a4*b1+a2*b0)],
//              [a4*(a2*b5+a1*b4+a0*b2)+a3*(a2*b4+a1*b3+a0*b1) + a1*(a2*b2+a1*b1+a0*b0), a4*(a4*b5+a3*b4+a1*b2)+a3*(a4*b4+a3*b3+a1*b1) + a1*(a4*b2+a3*b1+a1*b0), a4*(a5*b5+a4*b4+a2*b2)+a3*(a5*b4+a4*b3+a2*b1) + a1*(a5*b2+a4*b1+a2*b0)],
//              [a5*(a2*b5+a1*b4+a0*b2)+a4*(a2*b4+a1*b3+a0*b1) + a2*(a2*b2+a1*b1+a0*b0), a5*(a4*b5+a3*b4+a1*b2)+a4*(a4*b4+a3*b3+a1*b1) + a2*(a4*b2+a3*b1+a1*b0), a5*(a5*b5+a4*b4+a2*b2)+a4*(a5*b4+a4*b3+a2*b1) + a2*(a5*b2+a4*b1+a2*b0)])
// symmetric A * B * A
static inline void mul_sym33_sym33_sym33_vout(const double* restrict a, const double* restrict b, double* restrict vout)
{
  double t0 = a[2]*b[5]+a[1]*b[4]+a[0]*b[2];
  double t1 = a[2]*b[4]+a[1]*b[3]+a[0]*b[1];
  double t2 = a[2]*b[2]+a[1]*b[1]+a[0]*b[0];
  double t3 = a[4]*b[2]+a[3]*b[1]+a[1]*b[0];
  double t4 = a[4]*b[5]+a[3]*b[4]+a[1]*b[2];
  double t5 = a[4]*b[4]+a[3]*b[3]+a[1]*b[1];

  vout[0] = a[2]*t0+a[1]*t1+a[0]*t2;
  vout[1] = a[4]*t0+a[3]*t1+a[1]*t2;
  vout[2] = a[5]*t0+a[4]*t1+a[2]*t2;
  vout[3] = a[4]*t4+a[3]*t5+a[1]*t3;
  vout[4] = a[5]*t4+a[4]*t5+a[2]*t3;
  vout[5] = a[5]*(a[5]*b[5]+a[4]*b[4]+a[2]*b[2])+a[4]*(a[5]*b[4]+a[4]*b[3]+a[2]*b[1]) + a[2]*(a[5]*b[2]+a[4]*b[1]+a[2]*b[0]);
}
