GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-pm-scm.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2009-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-typeinfo.h"
34 #include "ops.h"
35 
36 #include "ov-perm.h"
37 #include "ov-cx-sparse.h"
38 
39 // permutation matrix by sparse matrix ops
40 
41 DEFBINOP (mul_pm_scm, perm_matrix, sparse_complex_matrix)
42 {
43  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
45  = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
46 
47  if (v2.rows () == 1 && v2.columns () == 1)
48  {
49  std::complex<double> d = v2.complex_value ();
50 
51  return octave_value (v1.sparse_matrix_value () * d);
52  }
53  else if (v1.rows () == 1 && v1.columns () == 1)
55  else
57 }
58 
59 DEFBINOP (ldiv_pm_scm, perm_matrix, sparse_complex_matrix)
60 {
61  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
63  = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
64 
66 }
67 
68 // sparse matrix by diagonal matrix ops
69 
70 DEFBINOP (mul_scm_pm, sparse_complex_matrix, perm_matrix)
71 {
73  = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
74  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
75 
76  if (v1.rows () == 1 && v1.columns () == 1)
77  {
78  std::complex<double> d = v1.scalar_value ();
79 
80  return octave_value (d * v2.sparse_matrix_value ());
81  }
82  else if (v2.rows () == 1 && v2.columns () == 1)
84  else
86 }
87 
88 DEFBINOP (div_scm_pm, sparse_complex_matrix, perm_matrix)
89 {
91  = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
92  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
93 
95 }
96 
97 void
99 {
101  mul_pm_scm);
103  ldiv_pm_scm);
105  mul_scm_pm);
107  div_scm_pm);
108 }
PermMatrix inverse(void) const
Definition: PermMatrix.cc:114
virtual SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-base.cc:636
octave_idx_type columns(void) const
Definition: ov-base.h:325
virtual PermMatrix perm_matrix_value(void) const
Definition: ov-base.cc:683
virtual SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-base.cc:642
octave_idx_type rows(void) const
Definition: ov-base.h:318
Complex complex_value(bool=false) const
Definition: ov-ch-mat.cc:127
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-perm.cc:213
PermMatrix perm_matrix_value(void) const
Definition: ov-perm.h:151
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-cx-sparse.h:125
double scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-sparse.h:110
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
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_scm_ops(octave::type_info &ti)
Definition: op-pm-scm.cc:98
#define DEFBINOP(name, t1, t2)
Definition: ops.h:230
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:55
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1568
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1572
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1569