GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
op-pm-sm.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2009-2025 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-re-sparse.h"
38
40
41// permutation matrix by sparse matrix ops
42
43DEFBINOP (mul_pm_sm, perm_matrix, sparse_matrix)
44{
47
48 if (v2.rows () == 1 && v2.columns () == 1)
49 {
50 double d = v2.scalar_value ();
51
52 return octave_value (v1.sparse_matrix_value () * d);
53 }
54 else if (v1.rows () == 1 && v1.columns () == 1)
56 else
57 return v1.perm_matrix_value () * v2.sparse_matrix_value ();
58}
59
60DEFBINOP (ldiv_pm_sm, perm_matrix, sparse_matrix)
61{
64
65 return v1.perm_matrix_value ().inverse () * v2.sparse_matrix_value ();
66}
67
68// sparse matrix by diagonal matrix ops
69
70DEFBINOP (mul_sm_pm, sparse_matrix, perm_matrix)
71{
74
75 if (v1.rows () == 1 && v1.columns () == 1)
76 {
77 double d = v1.scalar_value ();
78
80 }
81 else if (v2.rows () == 1 && v2.columns () == 1)
82 return octave_value (v1.sparse_matrix_value ());
83 else
84 return v1.sparse_matrix_value () * v2.perm_matrix_value ();
85}
86
87DEFBINOP (div_sm_pm, sparse_matrix, perm_matrix)
88{
91
92 return v1.sparse_matrix_value () * v2.perm_matrix_value ().inverse ();
93}
94
95void
107
108OCTAVE_END_NAMESPACE(octave)
PermMatrix inverse() const
virtual SparseMatrix sparse_matrix_value(bool=false) const
Definition ov-base.cc:692
octave_idx_type rows() const
Definition ov-base.h:384
octave_idx_type columns() const
Definition ov-base.h:391
virtual PermMatrix perm_matrix_value() const
Definition ov-base.cc:739
double scalar_value(bool frc_str_conv=false) const
Definition ov-ch-mat.h:106
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
const octave_base_value & a2
const octave_char_matrix & v2
void install_pm_sm_ops(octave::type_info &ti)
Definition op-pm-sm.cc:96
#define DEFBINOP(name, t1, t2)
Definition ops.h:248
#define OCTAVE_CAST_BASE_VALUE(T, T_VAL, BASE_VAL)
Definition ops.h:52
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition ops.h:70
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition ov.h:1680
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition ov.h:1684
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition ov.h:1681