Mercurial > octave-nkf
annotate examples/mypow2.c @ 18479:85d31344fb23 stable rc-3-8-1-2
3.8.1 release candidate 2
* configure.ac (OCTAVE_VERSION): Bump to 3.8.1-rc2.
(OCTAVE_MINOR_VERSION): Bump to 1-rc2.
(OCTAVE_RELEASE_DATE): Set to 2014-02-14.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 17 Feb 2014 02:20:39 -0500 |
parents | 224e76250443 |
children |
rev | line source |
---|---|
6593 | 1 #include "mex.h" |
2 | |
3 void | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
4 mexFunction (int nlhs, mxArray* plhs[], |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
5 int nrhs, const mxArray* prhs[]) |
6593 | 6 { |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
7 mwSize n; |
6686 | 8 mwIndex i; |
6593 | 9 double *vri, *vro; |
17791
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
10 |
6593 | 11 if (nrhs != 1 || ! mxIsNumeric (prhs[0])) |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
12 mexErrMsgTxt ("ARG1 must be a matrix"); |
6593 | 13 |
14 n = mxGetNumberOfElements (prhs[0]); | |
17791
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
15 plhs[0] = mxCreateNumericArray (mxGetNumberOfDimensions (prhs[0]), |
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
16 mxGetDimensions (prhs[0]), |
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
17 mxGetClassID (prhs[0]), |
224e76250443
Use GNU style coding conventions for code in examples/
Rik <rik@octave.org>
parents:
16867
diff
changeset
|
18 mxIsComplex (prhs[0])); |
6593 | 19 vri = mxGetPr (prhs[0]); |
20 vro = mxGetPr (plhs[0]); | |
21 | |
22 if (mxIsComplex (prhs[0])) | |
23 { | |
24 double *vii, *vio; | |
25 vii = mxGetPi (prhs[0]); | |
26 vio = mxGetPi (plhs[0]); | |
27 | |
28 for (i = 0; i < n; i++) | |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
29 { |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
30 vro[i] = vri[i] * vri[i] - vii[i] * vii[i]; |
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
31 vio[i] = 2 * vri[i] * vii[i]; |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
32 } |
6593 | 33 } |
34 else | |
35 { | |
36 for (i = 0; i < n; i++) | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
9932
diff
changeset
|
37 vro[i] = vri[i] * vri[i]; |
6593 | 38 } |
39 } |