Mercurial > hg > octave-nkf
annotate src/OPERATORS/op-m-cs.cc @ 10454:79a56d0a6a0d ss-3-3-51
version is now 3.3.51
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 24 Mar 2010 16:27:05 -0400 |
parents | ac4b97c6bf8b |
children | fd0a3ac60b0e |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 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 "mx-m-cs.h" | |
29 #include "mx-cs-m.h" | |
4544 | 30 #include "mx-nda-cs.h" |
31 #include "mx-cs-nda.h" | |
2928 | 32 |
33 #include "gripes.h" | |
4055 | 34 #include "oct-obj.h" |
2928 | 35 #include "ov.h" |
36 #include "ov-re-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
37 #include "ov-flt-re-mat.h" |
2928 | 38 #include "ov-cx-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
39 #include "ov-flt-cx-mat.h" |
2928 | 40 #include "ov-complex.h" |
41 #include "ov-typeinfo.h" | |
42 #include "ops.h" | |
43 #include "xdiv.h" | |
44 #include "xpow.h" | |
45 | |
46 // matrix by complex scalar ops. | |
47 | |
4543 | 48 DEFNDBINOP_OP (add, matrix, complex, array, complex, +) |
49 DEFNDBINOP_OP (sub, matrix, complex, array, complex, -) | |
50 DEFNDBINOP_OP (mul, matrix, complex, array, complex, *) | |
2928 | 51 |
52 DEFBINOP (div, matrix, complex) | |
53 { | |
54 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); | |
55 | |
56 Complex d = v2.complex_value (); | |
57 | |
58 if (d == 0.0) | |
59 gripe_divide_by_zero (); | |
60 | |
4543 | 61 return octave_value (v1.array_value () / d); |
2928 | 62 } |
63 | |
64 DEFBINOP_FN (pow, matrix, complex, xpow) | |
65 | |
66 DEFBINOP (ldiv, matrix, complex) | |
67 { | |
3766 | 68 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
69 | |
70 Matrix m1 = v1.matrix_value (); | |
71 ComplexMatrix m2 = v2.complex_matrix_value (); | |
5785 | 72 MatrixType typ = v1.matrix_type (); |
3766 | 73 |
5785 | 74 ComplexMatrix ret = xleftdiv (m1, m2, typ); |
75 | |
76 v1.matrix_type (typ); | |
77 return ret; | |
2928 | 78 } |
79 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
80 DEFNDCMPLXCMPOP_FN (lt, matrix, complex, array, complex, mx_el_lt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
81 DEFNDCMPLXCMPOP_FN (le, matrix, complex, array, complex, mx_el_le) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
82 DEFNDCMPLXCMPOP_FN (eq, matrix, complex, array, complex, mx_el_eq) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
83 DEFNDCMPLXCMPOP_FN (ge, matrix, complex, array, complex, mx_el_ge) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
84 DEFNDCMPLXCMPOP_FN (gt, matrix, complex, array, complex, mx_el_gt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
85 DEFNDCMPLXCMPOP_FN (ne, matrix, complex, array, complex, mx_el_ne) |
2928 | 86 |
4543 | 87 DEFNDBINOP_OP (el_mul, matrix, complex, array, complex, *) |
2928 | 88 |
89 DEFBINOP (el_div, matrix, complex) | |
90 { | |
91 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); | |
92 | |
93 Complex d = v2.complex_value (); | |
94 | |
95 if (d == 0.0) | |
96 gripe_divide_by_zero (); | |
97 | |
4543 | 98 return octave_value (v1.array_value () / d); |
2928 | 99 } |
100 | |
4543 | 101 DEFNDBINOP_FN (el_pow, matrix, complex, array, complex, elem_xpow) |
2928 | 102 |
103 DEFBINOP (el_ldiv, matrix, complex) | |
104 { | |
105 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); | |
106 | |
4543 | 107 return x_el_div (v2.complex_value (), v1.array_value ()); |
2928 | 108 } |
109 | |
4543 | 110 DEFNDBINOP_FN (el_and, matrix, complex, array, complex, mx_el_and) |
111 DEFNDBINOP_FN (el_or, matrix, complex, array, complex, mx_el_or) | |
2928 | 112 |
4915 | 113 DEFNDCATOP_FN (m_cs, matrix, complex, array, complex_array, concat) |
114 | |
2928 | 115 void |
116 install_m_cs_ops (void) | |
117 { | |
3538 | 118 INSTALL_BINOP (op_add, octave_matrix, octave_complex, add); |
119 INSTALL_BINOP (op_sub, octave_matrix, octave_complex, sub); | |
120 INSTALL_BINOP (op_mul, octave_matrix, octave_complex, mul); | |
121 INSTALL_BINOP (op_div, octave_matrix, octave_complex, div); | |
122 INSTALL_BINOP (op_pow, octave_matrix, octave_complex, pow); | |
123 INSTALL_BINOP (op_ldiv, octave_matrix, octave_complex, ldiv); | |
124 INSTALL_BINOP (op_lt, octave_matrix, octave_complex, lt); | |
125 INSTALL_BINOP (op_le, octave_matrix, octave_complex, le); | |
126 INSTALL_BINOP (op_eq, octave_matrix, octave_complex, eq); | |
127 INSTALL_BINOP (op_ge, octave_matrix, octave_complex, ge); | |
128 INSTALL_BINOP (op_gt, octave_matrix, octave_complex, gt); | |
129 INSTALL_BINOP (op_ne, octave_matrix, octave_complex, ne); | |
130 INSTALL_BINOP (op_el_mul, octave_matrix, octave_complex, el_mul); | |
131 INSTALL_BINOP (op_el_div, octave_matrix, octave_complex, el_div); | |
132 INSTALL_BINOP (op_el_pow, octave_matrix, octave_complex, el_pow); | |
133 INSTALL_BINOP (op_el_ldiv, octave_matrix, octave_complex, el_ldiv); | |
134 INSTALL_BINOP (op_el_and, octave_matrix, octave_complex, el_and); | |
135 INSTALL_BINOP (op_el_or, octave_matrix, octave_complex, el_or); | |
2928 | 136 |
4915 | 137 INSTALL_CATOP (octave_matrix, octave_complex, m_cs); |
138 | |
2928 | 139 INSTALL_ASSIGNCONV (octave_matrix, octave_complex, octave_complex_matrix); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
140 INSTALL_ASSIGNCONV (octave_float_matrix, octave_complex, octave_float_complex_matrix); |
2928 | 141 } |