Mercurial > hg > octave-lyh
annotate examples/mypow2.c @ 16618:13728d41fb6a
use functions to handle colors in Windows GUI terminal
* QWinTerminalImpl.cpp (QConsolePrivate::backgroundColor,
QConsolePrivate::foregroundColor, QConsolePrivate::selectionColor,
QConsolePrivate::cursorColor, QConsolePrivate::setBackgroundColor,
QConsolePrivate::setForegroundColor,
QConsolePrivate::setSelectionColor, QConsolePrivate::setCursorColor):
New functions.
(QConsolePrivate::m_backgroundColor,
QConsolePrivate::m_foregroundColor): Delete member variables.
(QConsolePrivate::QConsolePrivate): Call setBackgroundColor and
setForegroundColor to set default colors.
(QWinTerminalImpl::viewPaintEvent): Use functions to access colors.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 May 2013 02:20:01 -0400 |
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 } |