GNU Octave  4.2.1
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-pm-scm.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2017 Jason Riedy
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 #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-typeinfo.h"
31 #include "ops.h"
32 
33 #include "ov-perm.h"
34 #include "ov-cx-sparse.h"
35 
36 // permutation matrix by sparse matrix ops
37 
38 DEFBINOP (mul_pm_scm, perm_matrix, sparse_complex_matrix)
39 {
40  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
42  = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
43 
44  if (v2.rows () == 1 && v2.columns () == 1)
45  {
46  std::complex<double> d = v2.complex_value ();
47 
48  return octave_value (v1.sparse_matrix_value () * d);
49  }
50  else if (v1.rows () == 1 && v1.columns () == 1)
52  else
54 }
55 
56 DEFBINOP (ldiv_pm_scm, perm_matrix, sparse_complex_matrix)
57 {
58  const octave_perm_matrix& v1 = dynamic_cast<const octave_perm_matrix&> (a1);
60  = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
61 
63 }
64 
65 // sparse matrix by diagonal matrix ops
66 
67 DEFBINOP (mul_scm_pm, sparse_complex_matrix, perm_matrix)
68 {
70  = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
71  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
72 
73  if (v1.rows () == 1 && v1.columns () == 1)
74  {
75  std::complex<double> d = v1.scalar_value ();
76 
77  return octave_value (d * v2.sparse_matrix_value ());
78  }
79  else if (v2.rows () == 1 && v2.columns () == 1)
81  else
83 }
84 
85 DEFBINOP (div_scm_pm, sparse_complex_matrix, perm_matrix)
86 {
88  = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
89  const octave_perm_matrix& v2 = dynamic_cast<const octave_perm_matrix&> (a2);
90 
92 }
93 
94 void
96 {
98  mul_pm_scm);
100  ldiv_pm_scm);
102  mul_scm_pm);
104  div_scm_pm);
105 }
#define DEFBINOP(name, t1, t2)
Definition: ops.h:223
octave_idx_type columns(void) const
Definition: ov-base.h:319
Complex complex_value(bool=false) const
PermMatrix perm_matrix_value(void) const
Definition: ov-perm.h:138
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-cx-sparse.h:125
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
const octave_base_value & a2
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1517
#define INSTALL_BINOP(op, t1, t2, f)
Definition: ops.h:48
PermMatrix inverse(void) const
Definition: PermMatrix.cc:123
double scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-sparse.h:110
void install_pm_scm_ops(void)
Definition: op-pm-scm.cc:95
const octave_char_matrix & v2
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1520
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1516
octave_idx_type rows(void) const
Definition: ov-base.h:312
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-perm.cc:210