Mercurial > hg > octave-nkf
annotate examples/mypow2.c @ 14119:94e2a76f1e5a stable
doc: Final grammarcheck and spellcheck before 3.6.0 release.
* container.txi, aspell-octave.en.pws, expr.txi, vectorize.txi, accumarray.m,
accumdim.m, interpft.m, strread.m, parseparams.m, warning_ids.m, cellfun.cc,
help.cc: grammarcheck and spellcheck docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 29 Dec 2011 06:05:00 -0800 |
parents | 6cb30a539481 |
children | be41c30bcb44 |
rev | line source |
---|---|
6593 | 1 #include "mex.h" |
2 | |
3 void | |
7081 | 4 mexFunction (int nlhs, mxArray* plhs[], int nrhs, |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
5 const mxArray* prhs[]) |
6593 | 6 { |
6686 | 7 mwIndex i; |
8 mwSize n; | |
6593 | 9 double *vri, *vro; |
10 | |
11 if (nrhs != 1 || ! mxIsNumeric (prhs[0])) | |
12 mexErrMsgTxt ("expects matrix"); | |
13 | |
14 n = mxGetNumberOfElements (prhs[0]); | |
15 plhs[0] = (mxArray *) mxCreateNumericArray | |
16 (mxGetNumberOfDimensions (prhs[0]), | |
17 mxGetDimensions (prhs[0]), mxGetClassID (prhs[0]), | |
18 mxIsComplex (prhs[0])); | |
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 { |
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
30 vro [i] = vri [i] * vri [i] - vii [i] * vii [i]; |
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
31 vio [i] = 2 * vri [i] * vii [i]; |
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++) | |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
37 vro [i] = vri [i] * vri [i]; |
6593 | 38 } |
39 } |