Table 1 List of functions implemented for each type of vector.
From: A new advance on dimensional-aware scalar, vector and matrix operations in C++
Operation | Method | Note | |
|---|---|---|---|
\({{\textbf {v}}} \cdot {{\textbf {u}}}\) | v.dot() | Dot product | |
\({{\textbf {v}}} \times {{\textbf {u}}}\) | v.cross(u) | Cross product | |
\(\sphericalangle ({{\textbf {v}}}, {{\textbf {u}}})\) | v.angle(u) | Angle between two vectors | |
\(\hat{{{\textbf {v}}}}\) | v.versor() | Versor associated | \(*\) |
\(\hat{{{\textbf {v}}}}\) | v.versorDl() | Versor associated (dimensionless) | |
\(\pm |{{\textbf {v}}}|/|{{\textbf {u}}}| \text { if } {{\textbf {v}}}\parallel {{\textbf {u}}}\) | v.scale(u) | Ratio between parallel vectors | |
v.rotate(a,ax) | Rotate around z-axis (2D) or an arbitrary axis (3D) | \(*\) | |
\({{\textbf {v}}} \oplus {{\textbf {u}}}\) | v.directSum(u) | Direct sum | |
\({{\textbf {v}}} \odot {{\textbf {u}}}\) | v.elementwiseProduct() | Element-wise product | |
\({{\textbf {v}}} \oslash {{\textbf {u}}}\) | v.elementwiseDivision() | Element-wise division | |
\(|{{\textbf {v}}}|\) | v.norm() | Euclidean norm | |
\(|{{\textbf {v}}}|_{1}\) | v.normL1() | \(L_1\) norm | |
\(|{{\textbf {v}}}|_{p}\) | v.normL(p) | p norm | |
\(|{{\textbf {v}}}|_{\infty }\) | v.normLInf() | Infinity norm | |
\(|{{\textbf {v}}}|^2\) | v.normSquared() | Euclidean norm squared | |
\({{\textbf {v}}} \parallel {{\textbf {u}}}\) | v.isParallel(u) | Are parallel | |
\({{\textbf {v}}} \perp {{\textbf {u}}}\) | v.isPerpendicular(u) | Are perpendicular | |
\({{\textbf {v}}} \uparrow \uparrow {{\textbf {u}}}\) | v.isSameDirection(u) | Are parallel and have same directions | |
\({{\textbf {v}}} \uparrow \downarrow {{\textbf {u}}}\) | v.isOppositeDirection(u) | Are parallel and have opposite directions | |
\( {{\textbf {v}}} = {{\textbf {u}}}\) | v.isNear(u) | Are the same | |
\( {{\textbf {v}}} = 0\) | v.isNull() | Is zero | |
v.isNan() | Has any NaN component | ||
v.isNormal() | Are all components neither infinity, NaN, zero or subnormal | ||
\( {{\textbf {v}}} \ne \pm \infty \) | v.isFinite() | Are all components finite | |
\( {{\textbf {v}}} = \pm \infty \) | v.isInfinite() | Has any infinite component |