GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-pm-pm.cc
Go to the documentation of this file.
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-perm.h"
34 #include "ov-re-mat.h"
35 #include "ov-scalar.h"
36 #include "ov-typeinfo.h"
37 #include "ops.h"
38 #include "xpow.h"
39 
40 DEFUNOP (transpose, perm_matrix)
41 {
42  const octave_perm_matrix& v = dynamic_cast<const octave_perm_matrix&> (a);
43  return octave_value (v.perm_matrix_value ().transpose ());
44 }
45 
46 DEFBINOP_OP (mul, perm_matrix, perm_matrix, *)
47 
48 DEFBINOP (div, perm_matrix, perm_matrix)
49 {
50  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
51  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
52 
53  return (v1.perm_matrix_value () * v2.perm_matrix_value ().inverse ());
54 }
55 
56 DEFBINOP (ldiv, perm_matrix, perm_matrix)
57 {
58  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
59  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
60 
61  return (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value ());
62 }
63 
64 DEFBINOP (pow, perm_matrix, scalar)
65 {
66  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
67  const octave_scalar& v2 = dynamic_cast<const octave_scalar&> (a2);
68 
69  return xpow (v1.perm_matrix_value (), v2.scalar_value ());
70 }
71 
72 CONVDECL (perm_matrix_to_matrix)
73 {
74  const octave_perm_matrix& v = dynamic_cast<const octave_perm_matrix&> (a);
75 
76  return new octave_matrix (v.matrix_value ());
77 }
78 
79 void
81 {
84 
89 
92  perm_matrix_to_matrix);
93 }
PermMatrix inverse(void) const
Definition: PermMatrix.cc:114
PermMatrix transpose(void) const
Definition: PermMatrix.cc:101
virtual PermMatrix perm_matrix_value(void) const
Definition: ov-base.cc:683
double scalar_value(bool frc_str_conv=false) const
Definition: ov-ch-mat.h:105
PermMatrix perm_matrix_value(void) const
Definition: ov-perm.h:151
Matrix matrix_value(bool=false) const
Definition: ov-perm.cc:230
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
const octave_base_value & a2
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
void install_pm_pm_ops(octave::type_info &ti)
Definition: op-pm-pm.cc:80
#define DEFBINOP(name, t1, t2)
Definition: ops.h:230
#define DEFBINOP_OP(name, t1, t2, op)
Definition: ops.h:235
#define INSTALL_ASSIGNCONV_TI(ti, t1, t2, tr)
Definition: ops.h:73
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:55
#define INSTALL_WIDENOP_TI(ti, t1, t2, f)
Definition: ops.h:77
#define CONVDECL(name)
Definition: ops.h:168
#define DEFUNOP(name, t)
Definition: ops.h:179
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition: ops.h:47
static bool scalar(const dim_vector &dims)
Definition: ov-struct.cc:669
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1540
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1568
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1541
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1572
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1571
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1569
octave_value xpow(const SparseMatrix &a, double b)
Definition: sparse-xpow.cc:60
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:389