NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
hat.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <string>
31
34#include "NumCpp/NdArray.hpp"
36
37namespace nc::linalg
38{
39 //============================================================================
40 // Method Description:
48 template<typename dtype>
49 NdArray<dtype> hat(dtype inX, dtype inY, dtype inZ)
50 {
52
53 NdArray<dtype> returnArray(3);
54 returnArray(0, 0) = 0.;
55 returnArray(0, 1) = -inZ;
56 returnArray(0, 2) = inY;
57 returnArray(1, 0) = inZ;
58 returnArray(1, 1) = 0.;
59 returnArray(1, 2) = -inX;
60 returnArray(2, 0) = -inY;
61 returnArray(2, 1) = inX;
62 returnArray(2, 2) = 0.;
63
64 return returnArray;
65 }
66
67 //============================================================================
68 // Method Description:
74 template<typename dtype>
76 {
78
79 if (inVec.size() != 3)
80 {
81 THROW_INVALID_ARGUMENT_ERROR("input vector must be a length 3 cartesian vector.");
82 }
83
84 return hat(inVec[0], inVec[1], inVec[2]);
85 }
86
87 //============================================================================
88 // Method Description:
94 inline NdArray<double> hat(const Vec3& inVec)
95 {
96 return hat(inVec.x, inVec.y, inVec.z);
97 }
98} // namespace nc::linalg
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
Holds a 3D vector.
Definition: Vec3.hpp:51
double z
Definition: Vec3.hpp:56
double x
Definition: Vec3.hpp:54
double y
Definition: Vec3.hpp:55
Definition: cholesky.hpp:41
NdArray< dtype > hat(dtype inX, dtype inY, dtype inZ)
Definition: hat.hpp:49