comparison src/OPERATORS/op-fcm-fcs.cc @ 7789:82be108cc558

First attempt at single precision tyeps * * * corrections to qrupdate single precision routines * * * prefer demotion to single over promotion to double * * * Add single precision support to log2 function * * * Trivial PROJECT file update * * * Cache optimized hermitian/transpose methods * * * Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author David Bateman <dbateman@free.fr>
date Sun, 27 Apr 2008 22:34:17 +0200
parents
children 87865ed7405f
comparison
equal deleted inserted replaced
7788:45f5faba05a2 7789:82be108cc558
1 /*
2
3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4 2007 John W. Eaton
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
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
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
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include "gripes.h"
29 #include "oct-obj.h"
30 #include "ov.h"
31 #include "ov-cx-mat.h"
32 #include "ov-flt-cx-mat.h"
33 #include "ov-flt-complex.h"
34 #include "ov-typeinfo.h"
35 #include "ops.h"
36 #include "xdiv.h"
37 #include "xpow.h"
38
39 // complex matrix by complex scalar ops.
40
41 DEFNDBINOP_OP (add, float_complex_matrix, float_complex,
42 float_complex_array, float_complex, +)
43 DEFNDBINOP_OP (sub, float_complex_matrix, float_complex,
44 float_complex_array, float_complex, -)
45 DEFNDBINOP_OP (mul, float_complex_matrix, float_complex,
46 float_complex_array, float_complex, *)
47
48 DEFBINOP (div, float_complex_matrix, float_complex)
49 {
50 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
51 const octave_float_complex&);
52
53 FloatComplex d = v2.float_complex_value ();
54
55 if (d == static_cast<float>(0.0))
56 gripe_divide_by_zero ();
57
58 return octave_value (v1.float_complex_array_value () / d);
59 }
60
61 DEFBINOP_FN (pow, float_complex_matrix, float_complex, xpow)
62
63 DEFBINOP (ldiv, float_complex_matrix, float_complex)
64 {
65 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
66 const octave_float_complex&);
67
68 FloatComplexMatrix m1 = v1.float_complex_matrix_value ();
69 FloatComplexMatrix m2 = v2.float_complex_matrix_value ();
70 MatrixType typ = v1.matrix_type ();
71
72 FloatComplexMatrix ret = xleftdiv (m1, m2, typ);
73 v1.matrix_type (typ);
74 return ret;
75 }
76
77 DEFNDBINOP_FN (lt, float_complex_matrix, float_complex,
78 float_complex_array, float_complex, mx_el_lt)
79 DEFNDBINOP_FN (le, float_complex_matrix, float_complex,
80 float_complex_array, float_complex, mx_el_le)
81 DEFNDBINOP_FN (eq, float_complex_matrix, float_complex,
82 float_complex_array, float_complex, mx_el_eq)
83 DEFNDBINOP_FN (ge, float_complex_matrix, float_complex,
84 float_complex_array, float_complex, mx_el_ge)
85 DEFNDBINOP_FN (gt, float_complex_matrix, float_complex,
86 float_complex_array, float_complex, mx_el_gt)
87 DEFNDBINOP_FN (ne, float_complex_matrix, float_complex,
88 float_complex_array, float_complex, mx_el_ne)
89
90 DEFNDBINOP_OP (el_mul, float_complex_matrix, float_complex,
91 float_complex_array, float_complex, *)
92
93 DEFBINOP (el_div, float_complex_matrix, float_complex)
94 {
95 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
96 const octave_float_complex&);
97
98 FloatComplex d = v2.float_complex_value ();
99
100 if (d == static_cast<float>(0.0))
101 gripe_divide_by_zero ();
102
103 return octave_value (v1.float_complex_array_value () / d);
104 }
105
106 DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex,
107 float_complex_array, float_complex, elem_xpow)
108
109 DEFBINOP (el_ldiv, float_complex_matrix, float_complex)
110 {
111 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
112 const octave_float_complex&);
113
114 return x_el_div (v2.float_complex_value (), v1.float_complex_array_value ());
115 }
116
117 DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex,
118 float_complex_array, float_complex, mx_el_and)
119 DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex,
120 float_complex_array, float_complex, mx_el_or)
121
122 DEFNDCATOP_FN (fcm_fcs, float_complex_matrix, float_complex,
123 float_complex_array, float_complex_array, concat)
124
125 DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex,
126 float_complex_array, assign)
127 DEFNDASSIGNOP_FN (dbl_assign, complex_matrix, float_complex,
128 complex_array, assign)
129
130 void
131 install_fcm_fcs_ops (void)
132 {
133 INSTALL_BINOP (op_add, octave_float_complex_matrix,
134 octave_float_complex, add);
135 INSTALL_BINOP (op_sub, octave_float_complex_matrix,
136 octave_float_complex, sub);
137 INSTALL_BINOP (op_mul, octave_float_complex_matrix,
138 octave_float_complex, mul);
139 INSTALL_BINOP (op_div, octave_float_complex_matrix,
140 octave_float_complex, div);
141 INSTALL_BINOP (op_pow, octave_float_complex_matrix,
142 octave_float_complex, pow);
143 INSTALL_BINOP (op_ldiv, octave_float_complex_matrix,
144 octave_float_complex, ldiv);
145 INSTALL_BINOP (op_lt, octave_float_complex_matrix, octave_float_complex, lt);
146 INSTALL_BINOP (op_le, octave_float_complex_matrix, octave_float_complex, le);
147 INSTALL_BINOP (op_eq, octave_float_complex_matrix, octave_float_complex, eq);
148 INSTALL_BINOP (op_ge, octave_float_complex_matrix, octave_float_complex, ge);
149 INSTALL_BINOP (op_gt, octave_float_complex_matrix, octave_float_complex, gt);
150 INSTALL_BINOP (op_ne, octave_float_complex_matrix, octave_float_complex, ne);
151 INSTALL_BINOP (op_el_mul, octave_float_complex_matrix,
152 octave_float_complex, el_mul);
153 INSTALL_BINOP (op_el_div, octave_float_complex_matrix,
154 octave_float_complex, el_div);
155 INSTALL_BINOP (op_el_pow, octave_float_complex_matrix,
156 octave_float_complex, el_pow);
157 INSTALL_BINOP (op_el_ldiv, octave_float_complex_matrix,
158 octave_float_complex, el_ldiv);
159 INSTALL_BINOP (op_el_and, octave_float_complex_matrix,
160 octave_float_complex, el_and);
161 INSTALL_BINOP (op_el_or, octave_float_complex_matrix,
162 octave_float_complex, el_or);
163
164 INSTALL_CATOP (octave_float_complex_matrix, octave_float_complex, fcm_fcs);
165
166 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
167 octave_float_complex, assign);
168 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix,
169 octave_float_complex, dbl_assign);
170 }
171
172 /*
173 ;;; Local Variables: ***
174 ;;; mode: C++ ***
175 ;;; End: ***
176 */