Skip to content

Commit e96e63f

Browse files
authored
Merge pull request #167 from wermos/fix-det
Fix determinant bug
2 parents 6d7216f + d9b4d4d commit e96e63f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

Fastor/expressions/linalg_ops/unary_det_op.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ template<DetCompType DetType = DetCompType::Simple, typename T, size_t M,
2525
enable_if_t_<is_greater_v_<M,4UL> && DetType == DetCompType::Simple,bool> = false>
2626
FASTOR_INLINE T determinant(const Tensor<T,M,M> &a) {
2727
// Dispatch to LU
28-
determinant<DetCompType::LU>(a);
28+
return determinant<DetCompType::LU>(a);
2929
}
3030

3131
// For high order tensors

tests/test_linalg/test_linalg.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ void test_linalg() {
123123
FASTOR_EXIT_ASSERT(std::abs(det<DetCompType::LU>(A) - det(A) ) < HugeTol);
124124
}
125125

126+
// big determinant
127+
{
128+
Tensor<T, 6, 6> M = {{1, 0, 3, 0, 0, 0},
129+
{0, -2, 4, 0, 5, 0},
130+
{0, 0, 3, 0, 0, 0},
131+
{0, 0, 0, 4, 0, 0},
132+
{0, 0, 0, 0, 9, 0},
133+
{-1, -1, -1, -1, -1, -1}
134+
};
135+
136+
FASTOR_EXIT_ASSERT(std::abs(determinant(M) - 216) < Tol);
137+
}
138+
126139
print(FGRN(BOLD("All tests passed successfully")));
127140

128141
}

0 commit comments

Comments
 (0)