GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
op-m-cm.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
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
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include "mx-m-cm.h"
28 #include "mx-cm-m.h"
29 #include "mx-nda-cnda.h"
30 #include "mx-cnda-nda.h"
31 
32 #include "gripes.h"
33 #include "oct-obj.h"
34 #include "ov.h"
35 #include "ov-re-mat.h"
36 #include "ov-flt-re-mat.h"
37 #include "ov-cx-mat.h"
38 #include "ov-flt-cx-mat.h"
39 #include "ov-typeinfo.h"
40 #include "ops.h"
41 #include "xdiv.h"
42 #include "xpow.h"
43 
44 // matrix by complex matrix ops.
45 
46 DEFNDBINOP_OP (add, matrix, complex_matrix, array, complex_array, +)
47 DEFNDBINOP_OP (sub, matrix, complex_matrix, array, complex_array, -)
48 
49 DEFBINOP_OP (mul, matrix, complex_matrix, *)
50 
51 DEFBINOP (trans_mul, matrix, complex_matrix)
52 {
54 
55  Matrix m1 = v1.matrix_value ();
57 
58  return ComplexMatrix (xgemm (m1, real (m2), blas_trans, blas_no_trans),
59  xgemm (m1, imag (m2), blas_trans, blas_no_trans));
60 }
61 
62 DEFBINOP (div, matrix, complex_matrix)
63 {
65  MatrixType typ = v2.matrix_type ();
66 
68  v2.complex_matrix_value (), typ);
69 
70  v2.matrix_type (typ);
71  return ret;
72 }
73 
74 DEFBINOPX (pow, matrix, complex_matrix)
75 {
76  error ("can't do A ^ B for A and B both matrices");
77  return octave_value ();
78 }
79 
80 DEFBINOP (ldiv, matrix, complex_matrix)
81 {
83  MatrixType typ = v1.matrix_type ();
84 
86  v2.complex_matrix_value (), typ);
87 
88  v1.matrix_type (typ);
89  return ret;
90 }
91 
92 DEFBINOP (trans_ldiv, matrix, complex_matrix)
93 {
95  MatrixType typ = v1.matrix_type ();
96 
99 
100  v1.matrix_type (typ);
101  return ret;
102 }
103 
104 DEFNDCMPLXCMPOP_FN (lt, matrix, complex_matrix, array, complex_array, mx_el_lt)
105 DEFNDCMPLXCMPOP_FN (le, matrix, complex_matrix, array, complex_array, mx_el_le)
106 DEFNDCMPLXCMPOP_FN (eq, matrix, complex_matrix, array, complex_array, mx_el_eq)
107 DEFNDCMPLXCMPOP_FN (ge, matrix, complex_matrix, array, complex_array, mx_el_ge)
108 DEFNDCMPLXCMPOP_FN (gt, matrix, complex_matrix, array, complex_array, mx_el_gt)
109 DEFNDCMPLXCMPOP_FN (ne, matrix, complex_matrix, array, complex_array, mx_el_ne)
110 
111 DEFNDBINOP_FN (el_mul, matrix, complex_matrix, array, complex_array, product)
112 DEFNDBINOP_FN (el_div, matrix, complex_matrix, array, complex_array, quotient)
113 DEFNDBINOP_FN (el_pow, matrix, complex_matrix, array, complex_array, elem_xpow)
114 
115 DEFBINOP (el_ldiv, matrix, complex_matrix)
116 {
118 
119  return quotient (v2.complex_array_value (), v1.array_value ());
120 }
121 
122 DEFNDBINOP_FN (el_and, matrix, complex_matrix, array, complex_array, mx_el_and)
123 DEFNDBINOP_FN (el_or, matrix, complex_matrix, array, complex_array, mx_el_or)
124 
125 DEFNDCATOP_FN (m_cm, matrix, complex_matrix, array, complex_array, concat)
126 
127 DEFCONV (complex_matrix_conv, matrix, complex_matrix)
128 {
129  CAST_CONV_ARG (const octave_matrix&);
130 
131  return new octave_complex_matrix (ComplexNDArray (v.array_value ()));
132 }
133 
134 void
136 {
158  trans_ldiv);
160  trans_ldiv);
161 
163 
168 
169  INSTALL_WIDENOP (octave_matrix, octave_complex_matrix, complex_matrix_conv);
170 }