xmatrix5.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "xmatrix4.h"
4 
5 namespace nmx::gsl::mat {
6 
11 template<class M, class V>
12 struct IMBlas {
22  inline friend void dgemv(CBLAS_TRANSPOSE_t t, //
23  double a,
24  const M &m,
25  const V &x,
26  double b,
27  V &yinout) {
28  gsl_blas_dgemv(t, a, m.gsl(), x.gsl(), b, yinout.gsl());
29  }
30 
40  inline friend V amxby(CBLAS_TRANSPOSE_t t, //
41  double a,
42  const M &m,
43  const V &x,
44  double b,
45  const V &y) {
46  Vector out(y);
47  gsl_blas_dgemv(t, a, m.gsl(), x.gsl(), b, out.gsl());
48  return out;
49  }
50 
59  inline friend V amx(CBLAS_TRANSPOSE_t t, double a, const M &m,
60  const V &x) { //
61  Vector out{ x };
62  gsl_blas_dgemv(t, a, m.gsl(), x.gsl(), 0, out.gsl());
63  return out;
64  }
65 
73  inline friend V dot(const M &m, const V &v,
74  CBLAS_TRANSPOSE_t type = CblasNoTrans) { //
75  return amx(type, 1, m, v);
76  }
77 
89  inline friend void dgemm(CBLAS_TRANSPOSE_t t1,
90  CBLAS_TRANSPOSE_t t2,
91  double a,
92  const M &m1,
93  const M &m2,
94  double b,
95  M &minout) {
96  gsl_blas_dgemm(t1, t2, a, m1.gsl(), m2.gsl(), b, minout.gsl());
97  }
98 
110  inline friend M dgemm(CBLAS_TRANSPOSE_t t1, //
111  CBLAS_TRANSPOSE_t t2,
112  double a,
113  const M &m1,
114  const M &m2,
115  double b,
116  const M &m3) {
117  M out{ m3 };
118  gsl_blas_dgemm(t1, t2, a, m1.gsl(), m2.gsl(), b, out.gsl());
119  return out;
120  }
121 
131  inline friend M dgemm(CBLAS_TRANSPOSE_t t1,
132  CBLAS_TRANSPOSE_t t2, //
133  double a,
134  const M &m1,
135  const M &m2) {
136  M out(m1.rows(), m2.columns());
137  gsl_blas_dgemm(t1, t2, a, m1.gsl(), m2.gsl(), 0, out.gsl());
138  return out;
139  }
140 
149  inline friend M dot(const M &m1, //
150  const M &m2,
151  CBLAS_TRANSPOSE_t t1 = CblasNoTrans,
152  CBLAS_TRANSPOSE_t t2 = CblasNoTrans) {
153  return dgemm(t1, t2, 1, m1, m2);
154  }
155 };
156 
157 } // namespace nmx::gsl::mat
friend M dgemm(CBLAS_TRANSPOSE_t t1, CBLAS_TRANSPOSE_t t2, double a, const M &m1, const M &m2, double b, const M &m3)
dgemm
Definition: xmatrix5.h:110
const gsl_vector * gsl() const
gsl ermöglicht direkten Zugriff auf gsl-Funktionen
Definition: xvector.h:192
friend M dgemm(CBLAS_TRANSPOSE_t t1, CBLAS_TRANSPOSE_t t2, double a, const M &m1, const M &m2)
dgemm
Definition: xmatrix5.h:131
friend void dgemm(CBLAS_TRANSPOSE_t t1, CBLAS_TRANSPOSE_t t2, double a, const M &m1, const M &m2, double b, M &minout)
dgemm
Definition: xmatrix5.h:89
friend void dgemv(CBLAS_TRANSPOSE_t t, double a, const M &m, const V &x, double b, V &yinout)
dgemv y = a*m + b*y
Definition: xmatrix5.h:22
The IMBlas class Schnittstelle zur BLAS mit Funktionen für Matrix-Vektor- und Matrix-Matrix-Multiplik...
Definition: xmatrix5.h:12
friend V amxby(CBLAS_TRANSPOSE_t t, double a, const M &m, const V &x, double b, const V &y)
dgemv
Definition: xmatrix5.h:40
The Vector class Klasse für gsl-Vektoren zussamengesetzt aus Komponenten.
Definition: xvector.h:76
friend V dot(const M &m, const V &v, CBLAS_TRANSPOSE_t type=CblasNoTrans)
dot Matrix- Vektor Multiplikation
Definition: xmatrix5.h:73
friend M dot(const M &m1, const M &m2, CBLAS_TRANSPOSE_t t1=CblasNoTrans, CBLAS_TRANSPOSE_t t2=CblasNoTrans)
dot Matrix-Matrix Multiplikation
Definition: xmatrix5.h:149
friend V amx(CBLAS_TRANSPOSE_t t, double a, const M &m, const V &x)
dgemv
Definition: xmatrix5.h:59