numerics
Loading...
Searching...
No Matches
vector.cpp File Reference

Backend dispatch for real-vector ops, and sequential complex-vector ops. More...

#include "core/vector.hpp"
#include <cmath>
#include "backends/seq/impl.hpp"
#include "backends/blas/impl.hpp"
#include "backends/omp/impl.hpp"
#include "backends/gpu/impl.hpp"

Go to the source code of this file.

Namespaces

namespace  num
 

Functions

void num::scale (Vector &v, real alpha, Backend b=default_backend)
 v *= alpha
 
void num::add (const Vector &x, const Vector &y, Vector &z, Backend b=default_backend)
 z = x + y
 
void num::axpy (real alpha, const Vector &x, Vector &y, Backend b=default_backend)
 y += alpha * x
 
real num::dot (const Vector &x, const Vector &y, Backend b=default_backend)
 dot product
 
real num::norm (const Vector &x, Backend b=default_backend)
 Euclidean norm.
 
void num::scale (CVector &v, cplx alpha)
 v *= alpha
 
void num::axpy (cplx alpha, const CVector &x, CVector &y)
 y += alpha * x
 
cplx num::dot (const CVector &x, const CVector &y)
 Conjugate inner product <x, y> = Sigma conj(x_i) * y_i.
 
real num::norm (const CVector &x)
 Euclidean norm sqrt(Sigma |v_i|^2)
 

Detailed Description

Backend dispatch for real-vector ops, and sequential complex-vector ops.

BasicVector<T> member functions are defined inline in vector.hpp (template). This file only provides:

  1. Backend-dispatched free functions for Vector (= BasicVector<real>)
  2. Sequential free functions for CVector (= BasicVector<cplx>)

Adding a new backend:

  1. Add the enumerator to enum class Backend in include/core/policy.hpp
  2. Create src/core/backends/<name>/ with impl.hpp and vector.cpp
  3. Add case Backend::<name>: to each switch below
  4. Register the .cpp in cmake/sources.cmake

Definition in file vector.cpp.