Peano
Loading...
Searching...
No Matches
VectorOperations.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <cmath>
6#include <sstream>
7#include <vector>
8
10
14template <int Size, typename Scalar>
15std::string toString(const tarch::la::Vector<Size, Scalar>& vector);
16
17namespace tarch {
18 namespace la {
19
23 template <int Size, typename Scalar>
24 Scalar norm1(const Vector<Size, Scalar>& vector);
25
30 template <int Size>
31 double norm1(const Vector<Size, std::complex<double>>& vector);
32
37 template <int Size, typename Scalar>
38 Scalar norm2(const Vector<Size, Scalar>& vector);
39
40 template <int Size, typename Scalar>
41 Scalar norm2Squared(const Vector<Size, Scalar>& vector);
42
47 template <int Size>
48 double norm2(const Vector<Size, std::complex<double>>& vector);
49
50 template <int Size>
51 double norm2Squared(const Vector<Size, std::complex<double>>& vector);
52
56 template <int Size, typename Scalar>
57 Scalar normMax(const Vector<Size, Scalar>& vector);
58
63 template <int Size>
64 double normMax(const Vector<Size, std::complex<double>>& vector);
65
72 template <int Size, typename Scalar>
74
79 template <int Size>
80 Vector<Size, double> abs(const Vector<Size, std::complex<double>>& vector);
81
85 template <int Size, typename Scalar>
86 Scalar sum(const Vector<Size, Scalar>& vector);
87
92 template <int Size, typename Scalar>
93 Scalar volume(const Vector<Size, Scalar>& vector);
94
95 template <int Size, typename Scalar>
97
102 template <int Size, typename Scalar>
103 Scalar average(const Vector<Size, Scalar>& vector);
104
108 template <int Size, typename Scalar>
109 int indexMax(const Vector<Size, Scalar>& vector);
110
114 template <int Size, typename Scalar>
115 int indexMin(const Vector<Size, Scalar>& vector);
116
120 template <int Size, typename Scalar>
121 Scalar max(const Vector<Size, Scalar>& vector);
122
126 template <int Size, typename Scalar>
127 Scalar maxAbs(const Vector<Size, Scalar>& vector);
128
132 template <int Size, typename Scalar>
133 Scalar min(const Vector<Size, Scalar>& vector);
134
135 template <int Size, typename Scalar>
137
138 template <int Size>
139 Vector<Size, double> real(const Vector<Size, std::complex<double>>& vector);
140
141 template <int Size>
142 Vector<Size, double> imag(const Vector<Size, std::complex<double>>& vector);
143
144 template <int Size>
145 double maxReal(const Vector<Size, std::complex<double>>& vector);
146
147 template <int Size>
148 double maxImag(const Vector<Size, std::complex<double>>& vector);
149
150 template <int Size, typename Scalar>
151 bool contains(const Vector<Size, Scalar>& vector, const Scalar& value);
152
153 template <int Size, typename Scalar>
154 int count(const Vector<Size, Scalar>& vector, const Scalar& value);
155
156 template <int Size, typename Scalar>
158
159 template <int Size, typename Scalar>
161
162 template <int Size, typename Scalar>
163 std::vector<Scalar> toSTLVector(const Vector<Size, Scalar>& vector);
164 } // namespace la
165} // namespace tarch
166
170template <int Size, typename Scalar>
171std::ostream& operator<<(std::ostream& os, const tarch::la::Vector<Size, Scalar>& vector);
172
173#include "VectorOperations.cpph"
std::ostream & operator<<(std::ostream &os, const tarch::la::Vector< Size, Scalar > &vector)
Streams the component values into a comma separated representation.
std::string toString(const tarch::la::Vector< Size, Scalar > &vector)
Forward declaration.
Scalar average(const Vector< Size, Scalar > &vector)
Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the correspond...
int count(const Vector< Size, Scalar > &vector, const Scalar &value)
Scalar volume(const Vector< Size, Scalar > &vector)
Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the correspond...
Vector< Size, double > real(const Vector< Size, std::complex< double > > &vector)
Scalar sum(const Matrix< Rows, Cols, Scalar > &matrix)
Computes the sum of all entries of the matrix.
double maxImag(const Vector< Size, std::complex< double > > &vector)
int indexMin(const Vector< Size, Scalar > &vector)
Returns the index of the element with minimal value (NOT absolute value).
bool allEntriesAreTheSame(const Vector< Size, Scalar > &vector)
std::vector< Scalar > toSTLVector(const Vector< Size, Scalar > &vector)
double abs(double value)
Returns the absolute value of a type by redirecting to std::abs.
int indexMax(const Vector< Size, Scalar > &vector)
Returns the index of the element with maximal value (NOT absolute value).
double max(double a, double b, double c)
I need the maximum of three values all the time, to I decided to write a function for this.
Matrix< Rows, Cols, Scalar > invertEntries(const Matrix< Rows, Cols, Scalar > &matrix)
Inverts each individual entry.
int isEntryFinite(const Vector< Size, Scalar > &vector)
Scalar norm2Squared(const Vector< Size, Scalar > &vector)
int isEntryNan(const Vector< Size, Scalar > &vector)
Scalar maxAbs(const Vector< Size, Scalar > &vector)
Returns the element with maximal absolute value.
Vector< Size, double > imag(const Vector< Size, std::complex< double > > &vector)
Scalar norm1(const Vector< Size, Scalar > &vector)
Computes the 1-norm of the vector, i.e.
bool contains(const Vector< Size, Scalar > &vector, const Scalar &value)
Scalar normMax(const Vector< Size, Scalar > &vector)
Computes the max-norm of the vector.
Scalar min(const Vector< Size, Scalar > &vector)
Returns the element with minimal value (NOT absolute value).
Scalar norm2(const Vector< Size, Scalar > &vector)
Computes the 2-norm of the vector, i.e.
double maxReal(const Vector< Size, std::complex< double > > &vector)
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19
Simple vector class.
Definition Vector.h:159