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