Mercurial > octave
annotate src/OPERATORS/op-cm-cm.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 | a1dbe9d80eee |
children | 5861b95e9879 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 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-cx-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
32 #include "ov-flt-cx-mat.h" |
2928 | 33 #include "ov-typeinfo.h" |
34 #include "ops.h" | |
35 #include "xdiv.h" | |
36 #include "xpow.h" | |
37 | |
3203 | 38 // unary complex matrix ops. |
39 | |
4550 | 40 DEFNDUNOP_OP (not, complex_matrix, complex_array, !) |
4965 | 41 DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */) |
4550 | 42 DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -) |
3203 | 43 |
44 DEFUNOP (transpose, complex_matrix) | |
45 { | |
46 CAST_UNOP_ARG (const octave_complex_matrix&); | |
47 | |
4673 | 48 if (v.ndims () > 2) |
49 { | |
50 error ("transpose not defined for N-d objects"); | |
51 return octave_value (); | |
52 } | |
53 else | |
54 return octave_value (v.complex_matrix_value().transpose ()); | |
3203 | 55 } |
56 | |
57 DEFUNOP (hermitian, complex_matrix) | |
58 { | |
59 CAST_UNOP_ARG (const octave_complex_matrix&); | |
60 | |
4673 | 61 if (v.ndims () > 2) |
62 { | |
63 error ("complex-conjugate transpose not defined for N-d objects"); | |
64 return octave_value (); | |
65 } | |
66 else | |
67 return octave_value (v.complex_matrix_value().hermitian ()); | |
3203 | 68 } |
69 | |
70 DEFNCUNOP_METHOD (incr, complex_matrix, increment) | |
71 DEFNCUNOP_METHOD (decr, complex_matrix, decrement) | |
72 | |
2928 | 73 // complex matrix by complex matrix ops. |
74 | |
4550 | 75 DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array, complex_array, +) |
76 DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array, complex_array, -) | |
4543 | 77 |
2928 | 78 DEFBINOP_OP (mul, complex_matrix, complex_matrix, *) |
5785 | 79 |
80 DEFBINOP (div, complex_matrix, complex_matrix) | |
81 { | |
82 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); | |
83 MatrixType typ = v2.matrix_type (); | |
84 | |
85 ComplexMatrix ret = xdiv (v1.complex_matrix_value (), | |
86 v2.complex_matrix_value (), typ); | |
87 | |
88 v2.matrix_type (typ); | |
89 return ret; | |
90 } | |
2928 | 91 |
92 DEFBINOPX (pow, complex_matrix, complex_matrix) | |
93 { | |
94 error ("can't do A ^ B for A and B both matrices"); | |
95 return octave_value (); | |
96 } | |
97 | |
5785 | 98 DEFBINOP (ldiv, complex_matrix, complex_matrix) |
99 { | |
100 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); | |
101 MatrixType typ = v1.matrix_type (); | |
102 | |
103 ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (), | |
104 v2.complex_matrix_value (), typ); | |
105 | |
106 v1.matrix_type (typ); | |
107 return ret; | |
108 } | |
2928 | 109 |
4550 | 110 DEFNDBINOP_FN (lt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_lt) |
111 DEFNDBINOP_FN (le, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_le) | |
112 DEFNDBINOP_FN (eq, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_eq) | |
113 DEFNDBINOP_FN (ge, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ge) | |
114 DEFNDBINOP_FN (gt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_gt) | |
115 DEFNDBINOP_FN (ne, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ne) | |
2928 | 116 |
4550 | 117 DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array, complex_array, product) |
118 DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array, complex_array, quotient) | |
119 DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array, complex_array, elem_xpow) | |
2928 | 120 |
121 DEFBINOP (el_ldiv, complex_matrix, complex_matrix) | |
122 { | |
123 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); | |
124 | |
4550 | 125 return octave_value (quotient (v2.complex_array_value (), v1.complex_array_value ())); |
2928 | 126 } |
127 | |
4550 | 128 DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_and) |
129 DEFNDBINOP_FN (el_or, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_or) | |
2928 | 130 |
4915 | 131 DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array, complex_array, concat) |
132 | |
4686 | 133 DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign) |
2928 | 134 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
135 CONVDECL (complex_matrix_to_float_complex_matrix) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
136 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
137 CAST_CONV_ARG (const octave_complex_matrix&); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
138 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
139 return new octave_float_complex_matrix (FloatComplexNDArray (v.complex_array_value ())); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
140 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
141 |
2928 | 142 void |
143 install_cm_cm_ops (void) | |
144 { | |
3538 | 145 INSTALL_UNOP (op_not, octave_complex_matrix, not); |
4965 | 146 INSTALL_UNOP (op_uplus, octave_complex_matrix, uplus); |
3538 | 147 INSTALL_UNOP (op_uminus, octave_complex_matrix, uminus); |
148 INSTALL_UNOP (op_transpose, octave_complex_matrix, transpose); | |
149 INSTALL_UNOP (op_hermitian, octave_complex_matrix, hermitian); | |
3203 | 150 |
3538 | 151 INSTALL_NCUNOP (op_incr, octave_complex_matrix, incr); |
152 INSTALL_NCUNOP (op_decr, octave_complex_matrix, decr); | |
3203 | 153 |
3538 | 154 INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex_matrix, add); |
155 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex_matrix, sub); | |
156 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex_matrix, mul); | |
157 INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex_matrix, div); | |
158 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex_matrix, pow); | |
159 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex_matrix, ldiv); | |
160 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex_matrix, lt); | |
161 INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex_matrix, le); | |
162 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex_matrix, eq); | |
163 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex_matrix, ge); | |
164 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex_matrix, gt); | |
165 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex_matrix, ne); | |
166 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex_matrix, el_mul); | |
167 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex_matrix, el_div); | |
168 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex_matrix, el_pow); | |
169 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex_matrix, el_ldiv); | |
170 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex_matrix, el_and); | |
171 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex_matrix, el_or); | |
2928 | 172 |
4915 | 173 INSTALL_CATOP (octave_complex_matrix, octave_complex_matrix, cm_cm); |
174 | |
3538 | 175 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex_matrix, assign); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
176 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
177 INSTALL_CONVOP (octave_complex_matrix, octave_float_complex_matrix, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
178 complex_matrix_to_float_complex_matrix); |
2928 | 179 } |
180 | |
181 /* | |
182 ;;; Local Variables: *** | |
183 ;;; mode: C++ *** | |
184 ;;; End: *** | |
185 */ |