53 template<
typename dtype>
64 if (inShape.
rows == 1)
66 return inArray.
front();
69 if (inShape.
rows == 2)
71 return inArray(0, 0) * inArray(1, 1) - inArray(0, 1) * inArray(1, 0);
74 if (inShape.
rows == 3)
76 dtype aei = inArray(0, 0) * inArray(1, 1) * inArray(2, 2);
77 dtype bfg = inArray(0, 1) * inArray(1, 2) * inArray(2, 0);
78 dtype cdh = inArray(0, 2) * inArray(1, 0) * inArray(2, 1);
79 dtype ceg = inArray(0, 2) * inArray(1, 1) * inArray(2, 0);
80 dtype bdi = inArray(0, 1) * inArray(1, 0) * inArray(2, 2);
81 dtype afh = inArray(0, 0) * inArray(1, 2) * inArray(2, 1);
83 return aei + bfg + cdh - ceg - bdi - afh;
86 dtype determinant = 0;
102 submat(subi, subj++) = inArray(i,
j);
106 determinant += (
static_cast<dtype
>(std::pow(-1,
c)) * inArray(0,
c) *
det(submat));
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2772
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
constexpr auto j
Definition: Constants.hpp:45
constexpr double c
speed of light
Definition: Constants.hpp:40
dtype det(const NdArray< dtype > &inArray)
Definition: det.hpp:54
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40