diff --git a/UMFPACK/MATLAB/umfpack_make.m b/UMFPACK/MATLAB/umfpack_make.m index 5cdbdc508..79215568a 100644 --- a/UMFPACK/MATLAB/umfpack_make.m +++ b/UMFPACK/MATLAB/umfpack_make.m @@ -18,6 +18,8 @@ % UMFPACK, Copyright (c) 2005-2022, Timothy A. Davis, All Rights Reserved. % SPDX-License-Identifier: GPL-2.0+ +have_octave = (exist ('OCTAVE_VERSION', 'builtin') == 5) ; + metis_path = '../../CHOLMOD/SuiteSparse_metis' ; with_cholmod = exist (metis_path, 'dir') ; @@ -25,12 +27,14 @@ flags = '' ; is64 = ~isempty (strfind (computer, '64')) ; -if (is64) +if (is64 && ~have_octave) flags = ' -largeArrayDims' ; end -% MATLAB 8.3.0 now has a -silent option to keep 'mex' from burbling too much -if (~verLessThan ('matlab', '8.3.0')) +if (have_octave) + flags = ['--silent', flags] ; +elseif (~verLessThan ('matlab', '8.3.0')) + % MATLAB 8.3.0 now has a -silent option to keep 'mex' from burbling too much flags = ['-silent ' flags] ; end @@ -41,7 +45,11 @@ v = version ; -fprintf ('Compiling UMFPACK for MATLAB Version %s\n', v) ; +if (have_octave) + fprintf ('Compiling UMFPACK for Octave Version %s\n', v) ; +else + fprintf ('Compiling UMFPACK for MATLAB Version %s\n', v) ; +end if (ispc) obj = 'obj' ; @@ -57,41 +65,63 @@ % This is exceedingly ugly. The MATLAB mex command needs to be told where to % find the LAPACK and BLAS libraries, which is a real portability nightmare. - if (ispc) % BLAS/LAPACK functions have no underscore on Windows flags = [flags ' -DBLAS_NO_UNDERSCORE'] ; - if (verLessThan ('matlab', '7.5')) - lapack = 'libmwlapack.lib' ; - elseif (verLessThan ('matlab', '9.5')) - lapack = 'libmwlapack.lib libmwblas.lib' ; + + if (have_octave) + lapack = '-llapack -lblas' ; else - lapack = '-lmwlapack -lmwblas' ; + if (verLessThan ('matlab', '7.5')) + lapack = 'libmwlapack.lib' ; + elseif (verLessThan ('matlab', '9.5')) + lapack = 'libmwlapack.lib libmwblas.lib' ; + else + lapack = '-lmwlapack -lmwblas' ; + end end + else % BLAS/LAPACK functions have an underscore suffix flags = [flags ' -DBLAS_UNDERSCORE'] ; - if (verLessThan ('matlab', '7.5')) - lapack = '-lmwlapack' ; + + if (have_octave) + lapack = '-llapack -lblas' ; else - lapack = '-lmwlapack -lmwblas' ; + if (verLessThan ('matlab', '7.5')) + lapack = '-lmwlapack' ; + else + lapack = '-lmwlapack -lmwblas' ; + end end end -if (is64 && ~verLessThan ('matlab', '7.8')) - % versions 7.8 and later on 64-bit platforms use a 64-bit BLAS - fprintf ('with 64-bit BLAS\n') ; - flags = [flags ' -DBLAS64'] ; +if (is64) + + if (have_octave) + fprintf ('with 64-bit BLAS\n') ; + flags = [flags ' -DBLAS64'] ; + elseif (~verLessThan ('matlab', '7.8')) + % versions 7.8 and later on 64-bit platforms use a 64-bit BLAS + fprintf ('with 64-bit BLAS\n') ; + flags = [flags ' -DBLAS64'] ; + else + % other versions of MATLAB use a 32-bit BLAS + flags = [flags ' -DBLAS32'] ; + end else % other versions of MATLAB use a 32-bit BLAS flags = [flags ' -DBLAS32'] ; end +if (have_octave) + flags = [flags ' -DOCTAVE -DNRECIPROCAL'] +end + if (~(ispc || ismac)) % for POSIX timing routine lapack = [lapack ' -lrt'] ; end - %------------------------------------------------------------------------------- % Source and include directories %------------------------------------------------------------------------------- diff --git a/UMFPACK/MATLAB/umfpack_test.m b/UMFPACK/MATLAB/umfpack_test.m index c15aa5698..79d954f25 100644 --- a/UMFPACK/MATLAB/umfpack_test.m +++ b/UMFPACK/MATLAB/umfpack_test.m @@ -9,7 +9,9 @@ function umfpack_test (nmat) % UMFPACK, Copyright (c) 2005-2022, Timothy A. Davis, All Rights Reserved. % SPDX-License-Identifier: GPL-2.0+ -index = ssget ; +have_octave = (exist ('OCTAVE_VERSION', 'builtin') == 5) ; + +index = ssget('refresh') ; f = find (index.nrows == index.ncols) ; [ignore, i] = sort (index.nrows (f)) ; @@ -42,6 +44,12 @@ function umfpack_test (nmat) Prob = ssget (i) ; A = Prob.A ; + + % Octave cannot process matrices whose version is 7.3 + if (have_octave && ~issparse(A)) + continue ; + end + n = size (A,1) ; b = rand (1,n) ; @@ -57,7 +65,19 @@ function umfpack_test (nmat) title ('A') subplot (2,2,2) - treeplot (Fr (1:end-1,2)') ; + + Fr_slice = Fr(1:end-1, 2)' + if (~have_octave) + treeplot(Fr_slice) + else + % Octave don't support treeplot with empty vector + if (~isempty(Fr_slice)) + treeplot(Fr_slice) + else + plot([]) + end + end + title ('supercolumn etree') %----------------------------------------------------------------------- diff --git a/UMFPACK/MATLAB/umfpackmex.c b/UMFPACK/MATLAB/umfpackmex.c index cf041242e..55d163a21 100644 --- a/UMFPACK/MATLAB/umfpackmex.c +++ b/UMFPACK/MATLAB/umfpackmex.c @@ -53,10 +53,14 @@ #include "umfpack.h" #include "mex.h" -#include "matrix.h" #include #include #include +#include + +#ifndef OCTAVE +#include "matrix.h" +#endif #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b))