Mercurial > hg > octave-thorsten
annotate src/OPERATORS/op-cs-cm.cc @ 9933:ac4b97c6bf8b
eliminate Emacs local variables from some files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 07 Dec 2009 16:18:28 -0500 |
parents | 319e2ab9b8ae |
children | fd0a3ac60b0e |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
4 2007 John W. Eaton | |
2928 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2928 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2928 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "gripes.h" | |
4055 | 29 #include "oct-obj.h" |
2928 | 30 #include "ov.h" |
31 #include "ov-complex.h" | |
32 #include "ov-cx-mat.h" | |
33 #include "ov-typeinfo.h" | |
34 #include "ops.h" | |
35 #include "xdiv.h" | |
36 #include "xpow.h" | |
37 | |
38 // complex scalar by complex matrix ops. | |
39 | |
4550 | 40 DEFNDBINOP_OP (add, complex, complex_matrix, complex, complex_array, +) |
41 DEFNDBINOP_OP (sub, complex, complex_matrix, complex, complex_array, -) | |
42 DEFNDBINOP_OP (mul, complex, complex_matrix, complex, complex_array, *) | |
2928 | 43 |
44 DEFBINOP (div, complex, complex_matrix) | |
45 { | |
3766 | 46 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); |
47 | |
48 ComplexMatrix m1 = v1.complex_matrix_value (); | |
49 ComplexMatrix m2 = v2.complex_matrix_value (); | |
5785 | 50 MatrixType typ = v2.matrix_type (); |
3766 | 51 |
5785 | 52 ComplexMatrix ret = xdiv (m1, m2, typ); |
53 | |
54 v2.matrix_type (typ); | |
55 return ret; | |
2928 | 56 } |
57 | |
58 DEFBINOP_FN (pow, complex, complex_matrix, xpow) | |
59 | |
60 DEFBINOP (ldiv, complex, complex_matrix) | |
61 { | |
62 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); | |
63 | |
64 Complex d = v1.complex_value (); | |
65 | |
66 if (d == 0.0) | |
67 gripe_divide_by_zero (); | |
68 | |
4550 | 69 return octave_value (v2.complex_array_value () / d); |
2928 | 70 } |
71 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
72 DEFNDCMPLXCMPOP_FN (lt, complex, complex_matrix, complex, complex_array, mx_el_lt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
73 DEFNDCMPLXCMPOP_FN (le, complex, complex_matrix, complex, complex_array, mx_el_le) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
74 DEFNDCMPLXCMPOP_FN (eq, complex, complex_matrix, complex, complex_array, mx_el_eq) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
75 DEFNDCMPLXCMPOP_FN (ge, complex, complex_matrix, complex, complex_array, mx_el_ge) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
76 DEFNDCMPLXCMPOP_FN (gt, complex, complex_matrix, complex, complex_array, mx_el_gt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
77 DEFNDCMPLXCMPOP_FN (ne, complex, complex_matrix, complex, complex_array, mx_el_ne) |
2928 | 78 |
4550 | 79 DEFNDBINOP_OP (el_mul, complex, complex_matrix, complex, complex_array, *) |
80 DEFNDBINOP_FN (el_div, complex, complex_matrix, complex, complex_array, x_el_div) | |
81 DEFNDBINOP_FN (el_pow, complex, complex_matrix, complex, complex_array, elem_xpow) | |
2928 | 82 |
83 DEFBINOP (el_ldiv, complex, complex_matrix) | |
84 { | |
85 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); | |
86 | |
87 Complex d = v1.complex_value (); | |
88 | |
89 if (d == 0.0) | |
90 gripe_divide_by_zero (); | |
91 | |
4550 | 92 return octave_value (v2.complex_array_value () / d); |
2928 | 93 } |
94 | |
4550 | 95 DEFNDBINOP_FN (el_and, complex, complex_matrix, complex, complex_array, mx_el_and) |
96 DEFNDBINOP_FN (el_or, complex, complex_matrix, complex, complex_array, mx_el_or) | |
2928 | 97 |
4915 | 98 DEFNDCATOP_FN (cs_cm, complex, complex_matrix, complex_array, complex_array, concat) |
99 | |
2928 | 100 DEFCONV (complex_matrix_conv, complex, complex_matrix) |
101 { | |
102 CAST_CONV_ARG (const octave_complex&); | |
103 | |
104 return new octave_complex_matrix (v.complex_matrix_value ()); | |
105 } | |
106 | |
107 void | |
108 install_cs_cm_ops (void) | |
109 { | |
3538 | 110 INSTALL_BINOP (op_add, octave_complex, octave_complex_matrix, add); |
111 INSTALL_BINOP (op_sub, octave_complex, octave_complex_matrix, sub); | |
112 INSTALL_BINOP (op_mul, octave_complex, octave_complex_matrix, mul); | |
113 INSTALL_BINOP (op_div, octave_complex, octave_complex_matrix, div); | |
114 INSTALL_BINOP (op_pow, octave_complex, octave_complex_matrix, pow); | |
115 INSTALL_BINOP (op_ldiv, octave_complex, octave_complex_matrix, ldiv); | |
116 INSTALL_BINOP (op_lt, octave_complex, octave_complex_matrix, lt); | |
117 INSTALL_BINOP (op_le, octave_complex, octave_complex_matrix, le); | |
118 INSTALL_BINOP (op_eq, octave_complex, octave_complex_matrix, eq); | |
119 INSTALL_BINOP (op_ge, octave_complex, octave_complex_matrix, ge); | |
120 INSTALL_BINOP (op_gt, octave_complex, octave_complex_matrix, gt); | |
121 INSTALL_BINOP (op_ne, octave_complex, octave_complex_matrix, ne); | |
122 INSTALL_BINOP (op_el_mul, octave_complex, octave_complex_matrix, el_mul); | |
123 INSTALL_BINOP (op_el_div, octave_complex, octave_complex_matrix, el_div); | |
124 INSTALL_BINOP (op_el_pow, octave_complex, octave_complex_matrix, el_pow); | |
125 INSTALL_BINOP (op_el_ldiv, octave_complex, octave_complex_matrix, el_ldiv); | |
126 INSTALL_BINOP (op_el_and, octave_complex, octave_complex_matrix, el_and); | |
127 INSTALL_BINOP (op_el_or, octave_complex, octave_complex_matrix, el_or); | |
2928 | 128 |
4915 | 129 INSTALL_CATOP (octave_complex, octave_complex_matrix, cs_cm); |
130 | |
2928 | 131 INSTALL_ASSIGNCONV (octave_complex, octave_complex_matrix, octave_complex_matrix); |
132 | |
3540 | 133 INSTALL_WIDENOP (octave_complex, octave_complex_matrix, complex_matrix_conv); |
2928 | 134 } |