Mercurial > hg > octave-lyh
annotate examples/fortdemo.cc @ 14535:8150ccfffa22
Apply broadcasting to inputs of line().
* __line__.m: Use broadcasting the match the sizes of inputs.
* line.m: Add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 06 Apr 2012 19:21:16 -0400 |
parents | db1f49eaba6b |
children | 460a3c6d8bf1 |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/f77-fcn.h> | |
3 | |
12174 | 4 extern "C" |
6572 | 5 { |
12174 | 6 F77_RET_T |
7 F77_FUNC (fortsub, FORTSUB) | |
8 (const int&, double*, F77_CHAR_ARG_DECL | |
6572 | 9 F77_CHAR_ARG_LEN_DECL); |
10 } | |
11 | |
12 DEFUN_DLD (fortdemo , args , , "Fortran Demo.") | |
13 { | |
12174 | 14 octave_value_list retval; |
6572 | 15 int nargin = args.length(); |
16 if (nargin != 1) | |
17 print_usage (); | |
18 else | |
19 { | |
20 NDArray a = args(0).array_value (); | |
21 if (! error_state) | |
22 { | |
23 double *av = a.fortran_vec (); | |
24 octave_idx_type na = a.nelem (); | |
25 OCTAVE_LOCAL_BUFFER (char, ctmp, 128); | |
26 | |
12174 | 27 F77_XFCN (fortsub, FORTSUB, (na, av, ctmp |
7081 | 28 F77_CHAR_ARG_LEN (128))); |
6572 | 29 |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
30 retval(1) = std::string (ctmp); |
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
31 retval(0) = a; |
6572 | 32 } |
33 } | |
34 return retval; | |
35 } |