Skip to content

Commit b2620e3

Browse files
committed
CSparse: add octave support
1 parent 4454f5d commit b2620e3

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

CSparse/MATLAB/CSparse/cs_make.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
% CSparse, Copyright (c) 2006-2022, Timothy A. Davis. All Rights Reserved.
4343
% SPDX-License-Identifier: LGPL-2.1+
4444

45+
have_octave = (exist ('OCTAVE_VERSION', 'builtin') == 5) ;
46+
4547
try
4648
% ispc does not appear in MATLAB 5.3
4749
pc = ispc ;
@@ -50,17 +52,23 @@
5052
pc = ~isunix ;
5153
end
5254

55+
mexcmd = 'mex'
5356
if (~isempty (strfind (computer, '64')))
5457
fprintf ('Compiling CSparse (64-bit)\n') ;
55-
mexcmd = 'mex -largeArrayDims' ;
58+
59+
if (~have_octave)
60+
mexcmd = [mexcmd ' -largeArrayDims'] ;
61+
end
5662
else
5763
fprintf ('Compiling CSparse (32-bit)\n') ;
58-
mexcmd = 'mex' ;
5964
end
6065

6166
% MATLAB 8.3.0 now has a -silent option to keep 'mex' from burbling too much
62-
if (~verLessThan ('matlab', '8.3.0'))
63-
mexcmd = [mexcmd ' -silent'] ;
67+
if (have_octave)
68+
mexcmd = [mexcmd ' --silent '] ;
69+
warning("off", "Matlab-style short-circuit operation performed for operator |")
70+
elseif (~verLessThan ('matlab', '8.3.0'))
71+
mexcmd = [mexcmd ' -silent '] ;
6472
end
6573

6674
% CSparse source files, in ../../Source, such as ../../Source/cs_add.c.

CSparse/MATLAB/Demo/cs_demo.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ function cs_demo (do_pause, matrixpath)
3131
help cs_demo3
3232
cs_demo3 (do_pause, matrixpath) ;
3333

34+
addpath("./private")
35+
3436
fprintf ('\n\n-------------------------------------------------------\n') ;
35-
help private/ex_1
37+
help ex_1
3638
ex_1
3739

3840
fprintf ('\n\n-------------------------------------------------------\n') ;
39-
help private/ex2
41+
help ex2
4042
ex2
4143

4244
fprintf ('\n\n-------------------------------------------------------\n') ;
43-
help private/ex3
45+
help ex3
4446
ex3
4547

4648
fprintf ('\nAll CSparse demos finished.\n') ;

CSparse/MATLAB/Test/cs_test_make.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function cs_test_make (force)
99
% CSparse, Copyright (c) 2006-2022, Timothy A. Davis. All Rights Reserved.
1010
% SPDX-License-Identifier: LGPL-2.1+
1111

12+
have_octave = (exist ('OCTAVE_VERSION', 'builtin') == 5) ;
13+
1214
try
1315
% ispc does not appear in MATLAB 5.3
1416
pc = ispc ;
@@ -17,12 +19,18 @@ function cs_test_make (force)
1719
pc = ~isunix ;
1820
end
1921

22+
mexcmd = 'mex'
2023
if (~isempty (strfind (computer, '64')))
2124
fprintf ('Compiling CSparse (64-bit)\n') ;
22-
mexcmd = 'mex -largeArrayDims' ;
25+
if (~have_octave)
26+
mexcmd = [mexcmd ' -largeArrayDims'] ;
27+
end
2328
else
2429
fprintf ('Compiling CSparse (32-bit)\n') ;
25-
mexcmd = 'mex' ;
30+
end
31+
32+
if (have_octave)
33+
warning ("off", "Octave:possible-matlab-short-circuit-operator")
2634
end
2735

2836
if (pc)

CSparse/MATLAB/cs_install.m

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function cs_install (do_pause)
2626
% Copyright (c) 2006-2022, Timothy A. Davis. All Rights Reserved.
2727
% SPDX-License-Identifier: LGPL-2.1+
2828

29+
have_octave = (exist ('OCTAVE_VERSION', 'builtin') == 5) ;
30+
2931
fprintf ('Compiling and installing CSparse\n') ;
3032
if (nargin < 1)
3133
do_pause = 0 ;
@@ -37,9 +39,23 @@ function cs_install (do_pause)
3739
addpath ([pwd '/CSparse']) ;
3840
addpath ([pwd '/Demo']) ;
3941

40-
if (verLessThan ('matlab', '8.4'))
41-
fprintf ('ssget not installed (MATLAB 8.4 or later required)\n') ;
42+
if (have_octave)
43+
warning ("off", "Octave:possible-matlab-short-circuit-operator")
44+
install_ssget
4245
else
46+
if (verLessThan ('matlab', '8.4'))
47+
fprintf ('ssget not installed (MATLAB 8.4 or later required)\n') ;
48+
else
49+
install_ssget
50+
end
51+
end
52+
53+
cd ('CSparse') ;
54+
cs_make (1) ;
55+
cd ('../Demo') ;
56+
cs_demo (do_pause)
57+
58+
function install_ssget ()
4359
% install ssget, unless it's already in the path
4460
try
4561
% if this fails, then ssget is not yet installed
@@ -59,9 +75,3 @@ function cs_install (do_pause)
5975
fprintf ('ssget not installed\n') ;
6076
end
6177
end
62-
end
63-
64-
cd ('CSparse') ;
65-
cs_make (1) ;
66-
cd ('../Demo') ;
67-
cs_demo (do_pause)

0 commit comments

Comments
 (0)