1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2008-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 #  include "config.h"
28 #endif
29 
30 #include "errwarn.h"
31 #include "ovl.h"
32 #include "ov.h"
33 #include "ov-flt-cx-mat.h"
34 #include "ov-flt-cx-diag.h"
35 #include "ov-cx-diag.h"
36 #include "ov-typeinfo.h"
37 #include "ops.h"
38 #include "xdiv.h"
39 #include "xpow.h"
40 
41 // matrix unary ops.
42 
43 DEFUNOP_OP (uplus, float_complex_diag_matrix, /* no-op */)
44 DEFUNOP_OP (uminus, float_complex_diag_matrix, -)
45 
DEFUNOP(transpose,float_complex_diag_matrix)46 DEFUNOP (transpose, float_complex_diag_matrix)
47 {
48   const octave_float_complex_diag_matrix& v
49     = dynamic_cast<const octave_float_complex_diag_matrix&> (a);
50   return octave_value (v.float_complex_diag_matrix_value ().transpose ());
51 }
52 
DEFUNOP(hermitian,float_complex_diag_matrix)53 DEFUNOP (hermitian, float_complex_diag_matrix)
54 {
55   const octave_float_complex_diag_matrix& v
56     = dynamic_cast<const octave_float_complex_diag_matrix&> (a);
57   return octave_value (v.float_complex_diag_matrix_value ().hermitian ());
58 }
59 
60 // matrix by matrix ops.
61 
62 DEFBINOP_OP (add, float_complex_diag_matrix, float_complex_diag_matrix, +)
63 DEFBINOP_OP (sub, float_complex_diag_matrix, float_complex_diag_matrix, -)
64 DEFBINOP_OP (mul, float_complex_diag_matrix, float_complex_diag_matrix, *)
65 
DEFBINOP(div,float_complex_diag_matrix,float_complex_diag_matrix)66 DEFBINOP (div, float_complex_diag_matrix, float_complex_diag_matrix)
67 {
68   const octave_float_complex_diag_matrix& v1
69     = dynamic_cast<const octave_float_complex_diag_matrix&> (a1);
70   const octave_float_complex_diag_matrix& v2
71     = dynamic_cast<const octave_float_complex_diag_matrix&> (a2);
72 
73   return xdiv (v1.float_complex_diag_matrix_value (),
74                v2.float_complex_diag_matrix_value ());
75 }
76 
DEFBINOP(ldiv,float_complex_diag_matrix,float_complex_diag_matrix)77 DEFBINOP (ldiv, float_complex_diag_matrix, float_complex_diag_matrix)
78 {
79   const octave_float_complex_diag_matrix& v1
80     = dynamic_cast<const octave_float_complex_diag_matrix&> (a1);
81   const octave_float_complex_diag_matrix& v2
82     = dynamic_cast<const octave_float_complex_diag_matrix&> (a2);
83 
84   return xleftdiv (v1.float_complex_diag_matrix_value (),
85                    v2.float_complex_diag_matrix_value ());
86 }
87 
CONVDECL(float_complex_diag_matrix_to_complex_diag_matrix)88 CONVDECL (float_complex_diag_matrix_to_complex_diag_matrix)
89 {
90   const octave_float_complex_diag_matrix& v
91     = dynamic_cast<const octave_float_complex_diag_matrix&> (a);
92 
93   return new octave_complex_diag_matrix (v.complex_diag_matrix_value ());
94 }
95 
96 void
install_fcdm_fcdm_ops(octave::type_info & ti)97 install_fcdm_fcdm_ops (octave::type_info& ti)
98 {
99   INSTALL_UNOP_TI (ti, op_uplus, octave_float_complex_diag_matrix, uplus);
100   INSTALL_UNOP_TI (ti, op_uminus, octave_float_complex_diag_matrix, uminus);
101   INSTALL_UNOP_TI (ti, op_transpose, octave_float_complex_diag_matrix, transpose);
102   INSTALL_UNOP_TI (ti, op_hermitian, octave_float_complex_diag_matrix, hermitian);
103 
104   INSTALL_BINOP_TI (ti, op_add, octave_float_complex_diag_matrix,
105                     octave_float_complex_diag_matrix, add);
106   INSTALL_BINOP_TI (ti, op_sub, octave_float_complex_diag_matrix,
107                     octave_float_complex_diag_matrix, sub);
108   INSTALL_BINOP_TI (ti, op_mul, octave_float_complex_diag_matrix,
109                     octave_float_complex_diag_matrix, mul);
110   INSTALL_BINOP_TI (ti, op_div, octave_float_complex_diag_matrix,
111                     octave_float_complex_diag_matrix, div);
112   INSTALL_BINOP_TI (ti, op_ldiv, octave_float_complex_diag_matrix,
113                     octave_float_complex_diag_matrix, ldiv);
114 
115   INSTALL_ASSIGNCONV_TI (ti, octave_float_complex_diag_matrix,
116                          octave_float_complex_matrix, octave_float_complex_matrix);
117   INSTALL_WIDENOP_TI (ti, octave_float_complex_diag_matrix,
118                       octave_complex_diag_matrix,
119                       float_complex_diag_matrix_to_complex_diag_matrix);
120 }
121