51 template<
typename dtype>
53 -> std::conditional_t<std::is_integral_v<dtype>,
int64,
double>
57 using ReturnType = std::conditional_t<std::is_integral_v<dtype>,
int64,
double>;
61 return static_cast<ReturnType
>(inArray.front());
66 return static_cast<ReturnType
>(inArray(0, 0)) *
static_cast<ReturnType
>(inArray(1, 1)) -
67 static_cast<ReturnType
>(inArray(0, 1)) *
static_cast<ReturnType
>(inArray(1, 0));
72 const auto aei =
static_cast<ReturnType
>(inArray(0, 0)) *
static_cast<ReturnType
>(inArray(1, 1)) *
73 static_cast<ReturnType
>(inArray(2, 2));
74 const auto bfg =
static_cast<ReturnType
>(inArray(0, 1)) *
static_cast<ReturnType
>(inArray(1, 2)) *
75 static_cast<ReturnType
>(inArray(2, 0));
76 const auto cdh =
static_cast<ReturnType
>(inArray(0, 2)) *
static_cast<ReturnType
>(inArray(1, 0)) *
77 static_cast<ReturnType
>(inArray(2, 1));
78 const auto ceg =
static_cast<ReturnType
>(inArray(0, 2)) *
static_cast<ReturnType
>(inArray(1, 1)) *
79 static_cast<ReturnType
>(inArray(2, 0));
80 const auto bdi =
static_cast<ReturnType
>(inArray(0, 1)) *
static_cast<ReturnType
>(inArray(1, 0)) *
81 static_cast<ReturnType
>(inArray(2, 2));
82 const auto afh =
static_cast<ReturnType
>(inArray(0, 0)) *
static_cast<ReturnType
>(inArray(1, 2)) *
83 static_cast<ReturnType
>(inArray(2, 1));
85 return aei + bfg + cdh - ceg - bdi - afh;
88 ReturnType determinant = 0;
92 for (
uint32 c = 0; c < order; ++c)
95 for (
uint32 i = 1; i < order; ++i)
98 for (
uint32 j = 0; j < order; ++j)
105 submat(subi, subj++) = inArray(i, j);
110 determinant += (
sign *
static_cast<ReturnType
>(inArray(0, c)) *
det(submat, order - 1));
128 template<
typename dtype>
#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
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
uint32 rows
Definition Core/shape.hpp:44
bool issquare() const noexcept
Definition Core/shape.hpp:125
auto det(const NdArray< dtype > &inArray, uint32 order) -> std::conditional_t< std::is_integral_v< dtype >, int64, double >
Definition det.hpp:52
Definition cholesky.hpp:41
auto det(const NdArray< dtype > &inArray)
Definition det.hpp:129
int8 sign(dtype inValue) noexcept
Definition sign.hpp:49
std::int64_t int64
Definition Types.hpp:35
std::uint32_t uint32
Definition Types.hpp:40