From 2d9afc3909569455bfc23375404f927784766bb6 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Wed, 15 May 2024 14:07:53 -0400 Subject: [PATCH] Don't call LAPACK when LU-decomposing empty real/complex matrices Otherwise, Macaulay2 crashes Fixes bug reported by Joel Louwsma in Zulip --- M2/Macaulay2/e/dmat-lu-inplace.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/M2/Macaulay2/e/dmat-lu-inplace.hpp b/M2/Macaulay2/e/dmat-lu-inplace.hpp index 0d2905beefc..1e9f2ef1f6f 100644 --- a/M2/Macaulay2/e/dmat-lu-inplace.hpp +++ b/M2/Macaulay2/e/dmat-lu-inplace.hpp @@ -284,6 +284,9 @@ inline void DMatLUinPlace::computeLU() int info; int min = (rows <= cols) ? rows : cols; + if (min == 0) + return; + // printf("entering DMatLUinPlace::computeLUNaive for RR\n"); int* perm = newarray_atomic(int, min); @@ -345,6 +348,9 @@ inline void DMatLUinPlace::computeLU() int info; int min = (rows <= cols) ? rows : cols; + if (min == 0) + return; + // printf("entering DMatLUtemplate::computeLUNaive for RR\n"); int* perm = newarray_atomic(int, min);