NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
hat.hpp
Go to the documentation of this file.
1
28#pragma once
29
32#include "NumCpp/NdArray.hpp"
34
35namespace nc::linalg
36{
37 //============================================================================
38 // Method Description:
46 template<typename dtype>
47 NdArray<dtype> hat(dtype inX, dtype inY, dtype inZ)
48 {
50
51 NdArray<dtype> returnArray(3);
52 returnArray(0, 0) = 0.;
53 returnArray(0, 1) = -inZ;
54 returnArray(0, 2) = inY;
55 returnArray(1, 0) = inZ;
56 returnArray(1, 1) = 0.;
57 returnArray(1, 2) = -inX;
58 returnArray(2, 0) = -inY;
59 returnArray(2, 1) = inX;
60 returnArray(2, 2) = 0.;
61
62 return returnArray;
63 }
64
65 //============================================================================
66 // Method Description:
72 template<typename dtype>
74 {
76
77 if (inVec.size() != 3)
78 {
79 THROW_INVALID_ARGUMENT_ERROR("input vector must be a length 3 cartesian vector.");
80 }
81
82 return hat(inVec[0], inVec[1], inVec[2]);
83 }
84
85 //============================================================================
86 // Method Description:
92 inline NdArray<double> hat(const Vec3& inVec)
93 {
94 return hat(inVec.x, inVec.y, inVec.z);
95 }
96} // 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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
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:47