GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-fcs-fcs.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "errwarn.h"
28 #include "ovl.h"
29 #include "ov.h"
30 #include "ov-complex.h"
31 #include "ov-flt-complex.h"
32 #include "ov-flt-cx-mat.h"
33 #include "ov-typeinfo.h"
34 #include "ov-null-mat.h"
35 #include "ops.h"
36 #include "xdiv.h"
37 #include "xpow.h"
38 
39 // unary complex scalar ops.
40 
41 DEFUNOP (not, float_complex)
42 {
43  const octave_float_complex& v = dynamic_cast<const octave_float_complex&> (a);
45  if (octave::math::isnan (x))
47 
48  return octave_value (x == 0.0f);
49 }
50 
51 DEFUNOP_OP (uplus, float_complex, /* no-op */)
52 DEFUNOP_OP (uminus, float_complex, -)
53 DEFUNOP_OP (transpose, float_complex, /* no-op */)
54 
55 DEFUNOP (hermitian, float_complex)
56 {
57  const octave_float_complex& v = dynamic_cast<const octave_float_complex&> (a);
58 
59  return octave_value (conj (v.float_complex_value ()));
60 }
61 
62 DEFNCUNOP_METHOD (incr, float_complex, increment)
63 DEFNCUNOP_METHOD (decr, float_complex, decrement)
64 
65 // complex scalar by complex scalar ops.
66 
67 DEFBINOP_OP (add, float_complex, float_complex, +)
68 DEFBINOP_OP (sub, float_complex, float_complex, -)
69 DEFBINOP_OP (mul, float_complex, float_complex, *)
70 
71 DEFBINOP (div, float_complex, float_complex)
72 {
73  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
74  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
75 
77 
78  if (d == 0.0f)
80 
81  return octave_value (v1.float_complex_value () / d);
82 }
83 
84 DEFBINOP_FN (pow, float_complex, float_complex, xpow)
85 
86 DEFBINOP (ldiv, float_complex, float_complex)
87 {
88  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
89  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
90 
92 
93  if (d == 0.0f)
95 
96  return octave_value (v2.float_complex_value () / d);
97 }
98 
99 DEFCMPLXCMPOP_OP (lt, float_complex, float_complex, <)
100 DEFCMPLXCMPOP_OP (le, float_complex, float_complex, <=)
101 DEFCMPLXCMPOP_OP (eq, float_complex, float_complex, ==)
102 DEFCMPLXCMPOP_OP (ge, float_complex, float_complex, >=)
103 DEFCMPLXCMPOP_OP (gt, float_complex, float_complex, >)
104 DEFCMPLXCMPOP_OP (ne, float_complex, float_complex, !=)
105 
106 DEFBINOP_OP (el_mul, float_complex, float_complex, *)
107 
108 DEFBINOP (el_div, float_complex, float_complex)
109 {
110  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
111  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
112 
114 
115  if (d == 0.0f)
117 
118  return octave_value (v1.float_complex_value () / d);
119 }
120 
121 DEFBINOP_FN (el_pow, float_complex, float_complex, xpow)
122 
123 DEFBINOP (el_ldiv, float_complex, float_complex)
124 {
125  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
126  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
127 
129 
130  if (d == 0.0f)
132 
133  return octave_value (v2.float_complex_value () / d);
134 }
135 
136 DEFBINOP (el_and, float_complex, float_complex)
137 {
138  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
139  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
140 
141  return (v1.float_complex_value () != 0.0f
142  && v2.float_complex_value () != 0.0f);
143 }
144 
145 DEFBINOP (el_or, float_complex, float_complex)
146 {
147  const octave_float_complex& v1 = dynamic_cast<const octave_float_complex&> (a1);
148  const octave_float_complex& v2 = dynamic_cast<const octave_float_complex&> (a2);
149 
150  return (v1.float_complex_value () != 0.0f
151  || v2.float_complex_value () != 0.0f);
152 }
153 
154 DEFNDCATOP_FN (fcs_fcs, float_complex, float_complex, float_complex_array,
155  float_complex_array, concat)
156 
157 DEFNDCATOP_FN (cs_fcs, complex, float_complex, float_complex_array,
158  float_complex_array, concat)
159 
160 DEFNDCATOP_FN (fcs_cs, float_complex, complex, float_complex_array,
161  float_complex_array, concat)
162 
163 void
165 {
171 
172  INSTALL_NCUNOP_TI (ti, op_incr, octave_float_complex, incr);
173  INSTALL_NCUNOP_TI (ti, op_decr, octave_float_complex, decr);
174 
181  ldiv);
189  el_mul);
191  el_div);
193  el_pow);
195  el_ldiv);
197  el_and);
199  el_or);
200 
204 
207 
210 
217 }
octave_value xpow(const SparseMatrix &a, double b)
Definition: sparse-xpow.cc:58
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1574
#define DEFBINOP(name, t1, t2)
Definition: ops.h:264
#define DEFUNOP(name, t)
Definition: ops.h:213
octave_value op_el_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1620
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:53
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1613
void install_fcs_fcs_ops(octave::type_info &ti)
Definition: op-fcs-fcs.cc:164
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
octave_value op_el_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1621
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)
Definition: symrcm.cc:386
bool isnan(bool)
Definition: lo-mappers.h:187
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1608
#define INSTALL_NCUNOP_TI(ti, op, t, f)
Definition: ops.h:49
#define DEFUNOP_OP(name, t, op)
Definition: ops.h:217
void err_nan_to_logical_conversion(void)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
#define DEFBINOP_OP(name, t1, t2, op)
Definition: ops.h:269
const octave_base_value & a2
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition: ops.h:45
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1606
FloatComplex float_complex_value(bool=false) const
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1623
ComplexColumnVector conj(const ComplexColumnVector &a)
Definition: CColVector.cc:215
FloatComplex float_complex_value(bool=false) const
Definition: ov-ch-mat.cc:134
octave_value op_not(const octave_value &a)
Definition: ov.h:1573
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition: ops.h:58
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1577
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1622
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
void warn_divide_by_zero(void)
Definition: errwarn.cc:326
octave_value op_le(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1612
octave_value op_lt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1611
octave_value op_el_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1619
#define INSTALL_ASSIGNCONV_TI(ti, t1, t2, tr)
Definition: ops.h:71
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
const octave_char_matrix & v2
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1616
#define DEFCMPLXCMPOP_OP(name, t1, t2, op)
Definition: ops.h:281
octave_value op_add(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1603
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1609
octave_value op_sub(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1604
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
octave_value op_el_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1618
#define DEFBINOP_FN(name, t1, t2, f)
Definition: ops.h:324
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1578
octave_value op_ge(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1614
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:382
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1575
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1605
octave_value op_gt(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1615
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:251