Skip to content

Commit

Permalink
Merge pull request #167 from wermos/fix-det
Browse files Browse the repository at this point in the history
Fix determinant bug
  • Loading branch information
romeric authored Mar 7, 2023
2 parents 6d7216f + d9b4d4d commit e96e63f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Fastor/expressions/linalg_ops/unary_det_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ template<DetCompType DetType = DetCompType::Simple, typename T, size_t M,
enable_if_t_<is_greater_v_<M,4UL> && DetType == DetCompType::Simple,bool> = false>
FASTOR_INLINE T determinant(const Tensor<T,M,M> &a) {
// Dispatch to LU
determinant<DetCompType::LU>(a);
return determinant<DetCompType::LU>(a);
}

// For high order tensors
Expand Down
13 changes: 13 additions & 0 deletions tests/test_linalg/test_linalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ void test_linalg() {
FASTOR_EXIT_ASSERT(std::abs(det<DetCompType::LU>(A) - det(A) ) < HugeTol);
}

// big determinant
{
Tensor<T, 6, 6> M = {{1, 0, 3, 0, 0, 0},
{0, -2, 4, 0, 5, 0},
{0, 0, 3, 0, 0, 0},
{0, 0, 0, 4, 0, 0},
{0, 0, 0, 0, 9, 0},
{-1, -1, -1, -1, -1, -1}
};

FASTOR_EXIT_ASSERT(std::abs(determinant(M) - 216) < Tol);
}

print(FGRN(BOLD("All tests passed successfully")));

}
Expand Down

0 comments on commit e96e63f

Please sign in to comment.