Skip to content

Commit 750225c

Browse files
committed
doc MEX build [skip ci]
1 parent c9b31fb commit 750225c

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ test-results/
44
.buildtool/
55
*.asv
66
docs/
7+
78
*.mex*
9+
*.oct

Readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Matlab ≥ R2022a is required to run the self-test suite.
1414
Matlab R2019b is the minimum required due to use of
1515
[arguments](https://www.mathworks.com/help/matlab/ref/arguments.html)
1616
syntax.
17+
URLs (e.g. https://, s3:// and similar) are treated as not existing.
1718

1819
Self-tests can be run from that matlab-stdlib/ directory:
1920

@@ -24,6 +25,10 @@ buildtool test
2425
Functions requiring or optionally benefiting from MEX are indicated in the
2526
[API Documentation](https://geospace-code.github.io/matlab-stdlib).
2627

28+
To build the optional high-performance
29+
[MEX](https://www.mathworks.com/help/matlab/cpp-mex-file-applications.html)
30+
functions:
31+
2732
```matlab
2833
buildtool mex
2934
```
@@ -34,7 +39,7 @@ or for older Matlab:
3439
legacy_mex_build()
3540
```
3641

37-
URLs (e.g. https://, s3:// and similar) are treated as not existing.
42+
If just building MEX functions for the first time, to ensure the MEX functions are used instead of the plain Matlab script, one-time do a `clear all` in Matlab.
3843

3944

4045
## Java-based functions

Readme_octave.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GNU Octave with Matlab-stdlib
22

3-
If using GNU Octave instead of Matlab the minimum Octave version is 6.0.
3+
If using GNU Octave instead of Matlab the minimum Octave version is 7.0.
44

55
For HDF5 h5*() functions, install
66
[hdf5oct](https://gnu-octave.github.io/packages/hdf5oct/)
@@ -17,3 +17,9 @@ package from Octave prompt:
1717
```octave
1818
pkg install -forge netcdf
1919
```
20+
21+
## C++ Oct files
22+
23+
Optionally, to enable higher-performance (faster) C++-based .oct functions, run the
24+
[octave_build](./octave_build.m)
25+
script from GNU Octave.

octave_build.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
% Build C++-based .oct file for GNU Octave
2+
3+
assert(stdlib.isoctave(), "for GNU Octave only")
4+
5+
r = fileparts(mfilename("fullpath"));
6+
inc = fullfile(r, "src");
7+
d = fullfile(inc, "octave");
8+
t = fullfile(r, "+stdlib");
9+
10+
%% specific source
11+
srcs = {
12+
fullfile(d, "is_rosetta.cpp"), ...
13+
};
14+
15+
16+
%% build C+ Octave
17+
for s = srcs
18+
src = s{1};
19+
[~, n] = fileparts(src);
20+
21+
mkoctfile(src,"-v", ["-I", inc], "--output", fullfile(t, n))
22+
end

src/octave/is_rosetta.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <octave/oct.h>
2+
3+
#include "macos.cpp"
4+
5+
6+
DEFUN_DLD (is_rosetta, args, nargout,
7+
"Hello World Help String")
8+
{
9+
if (args.length() != 0){
10+
octave_stdout << "is_rosetta: No input required\n";
11+
return octave_value(false);
12+
}
13+
14+
bool y = fs_is_rosetta();
15+
16+
return octave_value(y);
17+
}

0 commit comments

Comments
 (0)