xvector7.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "xvector6.h"
4 #include <gsl/gsl_cblas.h>
5 
6 namespace nmx::gsl::vec {
7 
13 template<typename T>
14 struct IVBlas {
21  inline friend double dot(const T &v1, const T &v2) {
22  double result;
23  gsl_blas_ddot(v1.gsl(), v2.gsl(), &result);
24  return result;
25  }
26 
32  inline friend double nrm2(const T &v) { //
33  return gsl_blas_dnrm2(v.gsl());
34  }
35 
41  inline friend T normalize(const T &v) {
42  //berechne Norm des Vektors
43  const double magn = nrm2(v);
44  Check::error_if(nmx_msg, magn == 0.0);
45  //Kopie eines Vektors
46  T vout(v);
47  //Kopie des Vektors wird normiert
48  vout /= magn;
49  return vout;
50  }
51 
57  inline friend double asum(const T &v) { //
58  return gsl_blas_dasum(v.gsl());
59  }
60 };
61 
62 } // namespace nmx::gsl::vec
friend double asum(const T &v)
asum Summe der Beträge der Elemente
Definition: xvector7.h:57
friend double dot(const T &v1, const T &v2)
dot Skalarprodukt
Definition: xvector7.h:21
static void error_if(const std::string &s, bool arg)
error_if Fehler wenn Bedingung erfüllt ist
Definition: xerror.h:51
The IVBlas struct Schnittstellen zur BLAS für das Rechnen mit Vektoren oder Views.
Definition: xvector7.h:14
friend double nrm2(const T &v)
nrm2 Norm eines Vektors
Definition: xvector7.h:32
#define nmx_msg
Definition: xerror.h:113
friend T normalize(const T &v)
normalize Vektor wird normiert
Definition: xvector7.h:41