Mercurial > octave
annotate libinterp/corefcn/sparse-xpow.cc @ 31235:b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
* sparse-xpow.cc: Use space between function name and '(' in sparse-xpow.cc.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 20 Sep 2022 14:43:56 -0700 |
parents | a1318deb4584 |
children | e88a07dec498 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3 // Copyright (C) 1998-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
5164 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
5164 | 28 #endif |
29 | |
30 #include <cassert> | |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
31 |
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
32 #include <limits> |
5164 | 33 |
34 #include "Array-util.h" | |
35 #include "oct-cmplx.h" | |
36 #include "quit.h" | |
37 | |
38 #include "error.h" | |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
39 #include "ovl.h" |
5164 | 40 #include "utils.h" |
41 | |
42 #include "dSparse.h" | |
43 #include "CSparse.h" | |
44 #include "ov-re-sparse.h" | |
45 #include "ov-cx-sparse.h" | |
46 #include "sparse-xpow.h" | |
47 | |
29990
b839c36fd106
move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
48 OCTAVE_NAMESPACE_BEGIN |
b839c36fd106
move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
49 |
31226
44cf6bbeeca9
sparse-xpow.cc: Change return type from int to bool for internal function
Arun Giridhar <arungiridhar@gmail.com>
parents:
31225
diff
changeset
|
50 static inline bool |
5164 | 51 xisint (double x) |
52 { | |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
53 return (octave::math::x_nint (x) == x |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
54 && ((x >= 0 && x < std::numeric_limits<int>::max ()) |
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
55 || (x <= 0 && x > std::numeric_limits<int>::min ()))); |
5164 | 56 } |
57 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
58 // Safer pow functions. Only two make sense for sparse matrices, the |
5164 | 59 // others should all promote to full matrices. |
60 | |
61 octave_value | |
62 xpow (const SparseMatrix& a, double b) | |
63 { | |
64 octave_value retval; | |
65 | |
5275 | 66 octave_idx_type nr = a.rows (); |
67 octave_idx_type nc = a.cols (); | |
5164 | 68 |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
69 if (nr == 0 || nc == 0) |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
70 return SparseMatrix (); |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
71 |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
72 // If we are here, A is not empty ==> A needs to be square. |
31231
a026fb2be108
sparse-xpow.cc: Return empty matrix for empty input (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31227
diff
changeset
|
73 if (nr != nc) |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
74 error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
75 |
28144
c31c9eaa1f28
sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
76 if (! xisint (b)) |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
77 error ("use full(a) ^ full(b)"); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
78 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
79 int btmp = static_cast<int> (b); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
80 if (btmp == 0) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
81 { |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
82 SparseMatrix tmp = SparseMatrix (nr, nr, nr); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
83 for (octave_idx_type i = 0; i < nr; i++) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
84 { |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
85 tmp.data (i) = 1.0; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
86 tmp.ridx (i) = i; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
87 } |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
88 for (octave_idx_type i = 0; i < nr + 1; i++) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
89 tmp.cidx (i) = i; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
90 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
91 retval = tmp; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
92 } |
5164 | 93 else |
94 { | |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
95 SparseMatrix atmp; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
96 if (btmp < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
97 { |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
98 btmp = -btmp; |
5164 | 99 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
100 octave_idx_type info; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
101 double rcond = 0.0; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
102 MatrixType mattyp (a); |
5164 | 103 |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
104 // FIXME: This causes an error if the input sparse matrix is all-zeros. |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
105 // That behavior is inconsistent with A ^ b when A is a full all-zeros |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
106 // matrix, which just returns Inf of the same size with a warning. |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
107 atmp = a.inverse (mattyp, info, rcond, 1); |
5164 | 108 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
109 if (info == -1) |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
110 warning ("inverse: matrix singular to machine precision, rcond = %g", rcond); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
111 } |
5164 | 112 else |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
113 atmp = a; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
114 |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
115 if (atmp.nnz () == 0) // Fast return for all-zeros matrix |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
116 return atmp; |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
117 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
118 SparseMatrix result (atmp); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
119 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
120 btmp--; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
121 |
31224
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
122 // There are two approaches to the actual exponentiation. |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
123 // Exponentiation by squaring uses only a logarithmic number |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
124 // of multiplications but the matrices it multiplies tend to be dense |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
125 // towards the end. |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
126 // Linear multiplication uses a linear number of multiplications |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
127 // but one of the matrices it uses will be as sparse as the original |
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
128 // matrix. |
31224
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
129 // |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
130 // The time to multiply fixed-size matrices is strongly affected by their |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
131 // sparsity. Denser matrices take much longer to multiply together. |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
132 // See this URL for a worked-through example: |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
133 // https://octave.discourse.group/t/3216/4 |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
134 // |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
135 // The tradeoff is between many fast multiplications or a few slow ones. |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
136 // |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
137 // Large exponents favor the squaring technique, and sparse matrices |
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
138 // favor linear multiplication. |
31224
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
139 // |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
140 // We calculate a threshold based on the sparsity of the input |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
141 // and use squaring for exponents larger than that. |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
142 // |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
143 // FIXME: Improve this threshold calculation. |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
144 |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
145 uint64_t sparsity = atmp.numel () / atmp.nnz (); // reciprocal of density |
31227
0dec459a4064
sparse-xpow.cc: Performance tweak for threshold selection
Arun Giridhar <arungiridhar@gmail.com>
parents:
31226
diff
changeset
|
146 int threshold = (sparsity >= 1000) ? 40 |
0dec459a4064
sparse-xpow.cc: Performance tweak for threshold selection
Arun Giridhar <arungiridhar@gmail.com>
parents:
31226
diff
changeset
|
147 : (sparsity >= 100) ? 20 |
31224
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
148 : 3; |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
149 |
31224
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
150 if (btmp > threshold) // use squaring technique |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
151 { |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
152 while (btmp > 0) |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
153 { |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
154 if (btmp & 1) |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
155 result = result * atmp; |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
156 |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
157 btmp >>= 1; |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
158 |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
159 if (btmp > 0) |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
160 atmp = atmp * atmp; |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
161 } |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
162 } |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
163 else // use linear multiplication |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
164 { |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
165 for (int i = 0; i < btmp; i++) |
45984c799215
sparse-xpow.cc: Use faster multiplication technique based on input matrix sparsity
Arun Giridhar <arungiridhar@gmail.com>
parents:
30564
diff
changeset
|
166 result = result * atmp; |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
167 } |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
168 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
169 retval = result; |
5164 | 170 } |
171 | |
172 return retval; | |
173 } | |
174 | |
175 octave_value | |
176 xpow (const SparseComplexMatrix& a, double b) | |
177 { | |
178 octave_value retval; | |
179 | |
5275 | 180 octave_idx_type nr = a.rows (); |
181 octave_idx_type nc = a.cols (); | |
5164 | 182 |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
183 if (nr == 0 || nc == 0) |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
184 return SparseMatrix (); |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
185 |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
186 // If we are here, A is not empty ==> A needs to be square. |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
187 if (nr != nc) |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
188 error ("for A^b, A must be a square matrix. Use .^ for elementwise power."); |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
189 |
28144
c31c9eaa1f28
sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
190 if (! xisint (b)) |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
191 error ("use full(a) ^ full(b)"); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
192 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
193 int btmp = static_cast<int> (b); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
194 if (btmp == 0) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
195 { |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
196 SparseMatrix tmp = SparseMatrix (nr, nr, nr); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
197 for (octave_idx_type i = 0; i < nr; i++) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
198 { |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
199 tmp.data (i) = 1.0; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
200 tmp.ridx (i) = i; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
201 } |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
202 for (octave_idx_type i = 0; i < nr + 1; i++) |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
203 tmp.cidx (i) = i; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
204 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
205 retval = tmp; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
206 } |
5164 | 207 else |
208 { | |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
209 SparseComplexMatrix atmp; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
210 if (btmp < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
211 { |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
212 btmp = -btmp; |
5164 | 213 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
214 octave_idx_type info; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
215 double rcond = 0.0; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
216 MatrixType mattyp (a); |
5164 | 217 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
218 atmp = a.inverse (mattyp, info, rcond, 1); |
5164 | 219 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
220 if (info == -1) |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
221 warning ("inverse: matrix singular to machine precision, rcond = %g", rcond); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
222 } |
5164 | 223 else |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
224 atmp = a; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
225 |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
226 if (atmp.nnz () == 0) // Fast return for all-zeros matrix |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
227 return atmp; |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
228 |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
229 SparseComplexMatrix result (atmp); |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
230 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
231 btmp--; |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
232 |
31225
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
233 // Select multiplication sequence based on sparsity of atmp. |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
234 // See the long comment in xpow (const SparseMatrix& a, double b) |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
235 // for more details. |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
236 // |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
237 // FIXME: Improve this threshold calculation. |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
238 |
31235
b542b88ad3b6
maint: Use space between function name and '(' in sparse-xpow.cc.
Rik <rik@octave.org>
parents:
31234
diff
changeset
|
239 uint64_t sparsity = atmp.numel () / atmp.nnz (); // reciprocal of density |
31227
0dec459a4064
sparse-xpow.cc: Performance tweak for threshold selection
Arun Giridhar <arungiridhar@gmail.com>
parents:
31226
diff
changeset
|
240 int threshold = (sparsity >= 1000) ? 40 |
0dec459a4064
sparse-xpow.cc: Performance tweak for threshold selection
Arun Giridhar <arungiridhar@gmail.com>
parents:
31226
diff
changeset
|
241 : (sparsity >= 100) ? 20 |
31225
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
242 : 3; |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
243 |
31225
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
244 if (btmp > threshold) // use squaring technique |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
245 { |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
246 while (btmp > 0) |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
247 { |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
248 if (btmp & 1) |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
249 result = result * atmp; |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
250 |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
251 btmp >>= 1; |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
252 |
31225
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
253 if (btmp > 0) |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
254 atmp = atmp * atmp; |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
255 } |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
256 } |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
257 else // use linear multiplication |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
258 { |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
259 for (int i = 0; i < btmp; i++) |
3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
Arun Giridhar <arungiridhar@gmail.com>
parents:
31224
diff
changeset
|
260 result = result * atmp; |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
261 } |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
262 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
263 retval = result; |
5164 | 264 } |
265 | |
266 return retval; | |
267 } | |
268 | |
269 // Safer pow functions that work elementwise for matrices. | |
270 // | |
271 // op2 \ op1: s m cs cm | |
272 // +-- +---+---+----+----+ | |
273 // scalar | | * | 3 | * | 9 | | |
274 // +---+---+----+----+ | |
275 // matrix | 1 | 4 | 7 | 10 | | |
276 // +---+---+----+----+ | |
277 // complex_scalar | * | 5 | * | 11 | | |
278 // +---+---+----+----+ | |
279 // complex_matrix | 2 | 6 | 8 | 12 | | |
280 // +---+---+----+----+ | |
281 // | |
282 // * -> not needed. | |
283 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17749
diff
changeset
|
284 // FIXME: these functions need to be fixed so that things |
5164 | 285 // like |
286 // | |
287 // a = -1; b = [ 0, 0.5, 1 ]; r = a .^ b | |
288 // | |
289 // and | |
290 // | |
291 // a = -1; b = [ 0, 0.5, 1 ]; for i = 1:3, r(i) = a .^ b(i), end | |
292 // | |
293 // produce identical results. Also, it would be nice if -1^0.5 | |
294 // produced a pure imaginary result instead of a complex number with a | |
295 // small real part. But perhaps that's really a problem with the math | |
296 // library... | |
297 | |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
298 // Handle special case of scalar-sparse-matrix .^ sparse-matrix. |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
299 // Forwarding to the scalar elem_xpow function and then converting the |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
300 // result back to a sparse matrix is a bit wasteful but it does not |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
301 // seem worth the effort to optimize -- how often does this case come up |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
302 // in practice? |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
303 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21121
diff
changeset
|
304 template <typename S, typename SM> |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
305 inline octave_value |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
306 scalar_xpow (const S& a, const SM& b) |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
307 { |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
308 octave_value val = elem_xpow (a, b); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
309 |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
310 if (val.iscomplex ()) |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
311 return SparseComplexMatrix (val.complex_matrix_value ()); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
312 else |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
313 return SparseMatrix (val.matrix_value ()); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
314 } |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
315 |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
316 /* |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
317 %!assert (sparse (2) .^ [3, 4], sparse ([8, 16])) |
22470
9d4cb0cf9cd2
maint: tag xtests and tests that fail on some systems with bug numbers
Mike Miller <mtmiller@octave.org>
parents:
22407
diff
changeset
|
318 %!assert <47775> (sparse (2i) .^ [3, 4], sparse ([-0-8i, 16])) |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
319 |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
320 %!test <*63080> |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
321 %! Z = sparse ([]); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
322 %! A = sparse (zeros (0, 2)); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
323 %! B = sparse (zeros (2, 0)); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
324 %! assert (Z ^ 1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
325 %! assert (Z ^ 0, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
326 %! assert (Z ^ -1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
327 %! assert (A ^ 1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
328 %! assert (A ^ 0, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
329 %! assert (A ^ -1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
330 %! assert (B ^ 1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
331 %! assert (B ^ 0, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
332 %! assert (B ^ -1, Z); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
333 |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
334 %!test <*63080> |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
335 %! A = sparse (zeros (2, 2)); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
336 %! assert (A ^ 1, A); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
337 %! assert (A ^ 0, sparse (eye (2, 2))); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
338 |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
339 %!test <63080> |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
340 %! A = sparse (zeros (2, 2)); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
341 %! assert (A ^ -1, sparse (inf (2, 2))); |
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
342 |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
343 */ |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
344 |
5164 | 345 // -*- 1 -*- |
346 octave_value | |
347 elem_xpow (double a, const SparseMatrix& b) | |
348 { | |
349 octave_value retval; | |
350 | |
5275 | 351 octave_idx_type nr = b.rows (); |
352 octave_idx_type nc = b.cols (); | |
5164 | 353 |
354 double d1, d2; | |
355 | |
356 if (a < 0.0 && ! b.all_integers (d1, d2)) | |
357 { | |
358 Complex atmp (a); | |
359 ComplexMatrix result (nr, nc); | |
360 | |
5275 | 361 for (octave_idx_type j = 0; j < nc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
362 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
363 for (octave_idx_type i = 0; i < nr; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
364 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
365 octave_quit (); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29990
diff
changeset
|
366 result(i, j) = std::pow (atmp, b(i, j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
367 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
368 } |
5164 | 369 |
370 retval = result; | |
371 } | |
372 else | |
373 { | |
374 Matrix result (nr, nc); | |
375 | |
5275 | 376 for (octave_idx_type j = 0; j < nc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
377 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
378 for (octave_idx_type i = 0; i < nr; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
379 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
380 octave_quit (); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29990
diff
changeset
|
381 result(i, j) = std::pow (a, b(i, j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
382 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
383 } |
5164 | 384 |
385 retval = result; | |
386 } | |
387 | |
388 return retval; | |
389 } | |
390 | |
391 // -*- 2 -*- | |
392 octave_value | |
393 elem_xpow (double a, const SparseComplexMatrix& b) | |
394 { | |
5275 | 395 octave_idx_type nr = b.rows (); |
396 octave_idx_type nc = b.cols (); | |
5164 | 397 |
398 Complex atmp (a); | |
399 ComplexMatrix result (nr, nc); | |
400 | |
5275 | 401 for (octave_idx_type j = 0; j < nc; j++) |
5164 | 402 { |
5275 | 403 for (octave_idx_type i = 0; i < nr; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
404 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
405 octave_quit (); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29990
diff
changeset
|
406 result(i, j) = std::pow (atmp, b(i, j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
407 } |
5164 | 408 } |
409 | |
410 return result; | |
411 } | |
412 | |
413 // -*- 3 -*- | |
414 octave_value | |
415 elem_xpow (const SparseMatrix& a, double b) | |
416 { | |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
417 // FIXME: What should a .^ 0 give? Matlab gives a |
5164 | 418 // sparse matrix with same structure as a, which is strictly |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
419 // incorrect. Keep compatibility. |
5164 | 420 |
421 octave_value retval; | |
422 | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10315
diff
changeset
|
423 octave_idx_type nz = a.nnz (); |
5164 | 424 |
425 if (b <= 0.0) | |
426 { | |
5275 | 427 octave_idx_type nr = a.rows (); |
428 octave_idx_type nc = a.cols (); | |
5164 | 429 |
28144
c31c9eaa1f28
sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
430 if (! xisint (b) && a.any_element_is_negative ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
431 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
432 ComplexMatrix result (nr, nc, Complex (std::pow (0.0, b))); |
5164 | 433 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17749
diff
changeset
|
434 // FIXME: avoid apparent GNU libm bug by |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
435 // converting A and B to complex instead of just A. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
436 Complex btmp (b); |
5164 | 437 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
438 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
439 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
440 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
441 octave_quit (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
442 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
443 Complex atmp (a.data (i)); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
444 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
445 result(a.ridx (i), j) = std::pow (atmp, btmp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
446 } |
5164 | 447 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
448 retval = octave_value (result); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
449 } |
5164 | 450 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
451 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
452 Matrix result (nr, nc, (std::pow (0.0, b))); |
5164 | 453 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
454 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
455 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
456 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
457 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
458 result(a.ridx (i), j) = std::pow (a.data (i), b); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
459 } |
5164 | 460 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
461 retval = octave_value (result); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
462 } |
5164 | 463 } |
28144
c31c9eaa1f28
sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
464 else if (! xisint (b) && a.any_element_is_negative ()) |
5164 | 465 { |
466 SparseComplexMatrix result (a); | |
467 | |
5275 | 468 for (octave_idx_type i = 0; i < nz; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
469 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
470 octave_quit (); |
5164 | 471 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17749
diff
changeset
|
472 // FIXME: avoid apparent GNU libm bug by |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
473 // converting A and B to complex instead of just A. |
5164 | 474 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
475 Complex atmp (a.data (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
476 Complex btmp (b); |
5164 | 477 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
478 result.data (i) = std::pow (atmp, btmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
479 } |
5164 | 480 |
481 result.maybe_compress (true); | |
482 | |
483 retval = result; | |
484 } | |
485 else | |
486 { | |
487 SparseMatrix result (a); | |
488 | |
5275 | 489 for (octave_idx_type i = 0; i < nz; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
490 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
491 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
492 result.data (i) = std::pow (a.data (i), b); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
493 } |
5164 | 494 |
495 result.maybe_compress (true); | |
496 | |
497 retval = result; | |
498 } | |
499 | |
500 return retval; | |
501 } | |
502 | |
503 // -*- 4 -*- | |
504 octave_value | |
505 elem_xpow (const SparseMatrix& a, const SparseMatrix& b) | |
506 { | |
507 octave_value retval; | |
508 | |
5275 | 509 octave_idx_type nr = a.rows (); |
510 octave_idx_type nc = a.cols (); | |
5164 | 511 |
5275 | 512 octave_idx_type b_nr = b.rows (); |
513 octave_idx_type b_nc = b.cols (); | |
5164 | 514 |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
515 if (a.numel () == 1 && b.numel () > 1) |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
516 return scalar_xpow (a(0), b); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
517 |
5164 | 518 if (nr != b_nr || nc != b_nc) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
519 octave::err_nonconformant ("operator .^", nr, nc, b_nr, b_nc); |
5164 | 520 |
521 int convert_to_complex = 0; | |
5275 | 522 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
523 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
5164 | 524 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
525 if (a.data(i) < 0.0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
526 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
527 double btmp = b (a.ridx (i), j); |
28144
c31c9eaa1f28
sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
528 if (! xisint (btmp)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
529 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
530 convert_to_complex = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
531 goto done; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
532 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
533 } |
5164 | 534 } |
535 | |
536 done: | |
537 | |
5953 | 538 // This is a dumb operator for sparse matrices anyway, and there is |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
539 // no sensible way to handle the 0.^0 versus the 0.^x cases. Therefore |
5953 | 540 // allocate a full matrix filled for the 0.^0 case and shrink it later |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
541 // as needed. |
5164 | 542 |
543 if (convert_to_complex) | |
544 { | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
545 SparseComplexMatrix complex_result (nr, nc, Complex (1.0, 0.0)); |
5164 | 546 |
5275 | 547 for (octave_idx_type j = 0; j < nc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
548 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
549 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
550 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
551 octave_quit (); |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
552 complex_result.xelem (a.ridx (i), j) |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
553 = std::pow (Complex (a.data (i)), Complex (b(a.ridx (i), j))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
554 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
555 } |
5953 | 556 complex_result.maybe_compress (true); |
5164 | 557 retval = complex_result; |
558 } | |
559 else | |
560 { | |
5953 | 561 SparseMatrix result (nr, nc, 1.0); |
5164 | 562 |
5275 | 563 for (octave_idx_type j = 0; j < nc; j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
564 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
565 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
566 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
567 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
568 result.xelem (a.ridx (i), j) = std::pow (a.data (i), |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
569 b(a.ridx (i), j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
570 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
571 } |
5953 | 572 result.maybe_compress (true); |
5164 | 573 retval = result; |
574 } | |
575 | |
576 return retval; | |
577 } | |
578 | |
579 // -*- 5 -*- | |
580 octave_value | |
581 elem_xpow (const SparseMatrix& a, const Complex& b) | |
582 { | |
583 octave_value retval; | |
584 | |
585 if (b == 0.0) | |
586 // Can this case ever happen, due to automatic retyping with maybe_mutate? | |
587 retval = octave_value (NDArray (a.dims (), 1)); | |
588 else | |
589 { | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10315
diff
changeset
|
590 octave_idx_type nz = a.nnz (); |
5164 | 591 SparseComplexMatrix result (a); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
592 |
5275 | 593 for (octave_idx_type i = 0; i < nz; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
594 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
595 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
596 result.data (i) = std::pow (Complex (a.data (i)), b); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
597 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
598 |
5164 | 599 result.maybe_compress (true); |
600 | |
601 retval = result; | |
602 } | |
603 | |
604 return retval; | |
605 } | |
606 | |
607 // -*- 6 -*- | |
608 octave_value | |
609 elem_xpow (const SparseMatrix& a, const SparseComplexMatrix& b) | |
610 { | |
5275 | 611 octave_idx_type nr = a.rows (); |
612 octave_idx_type nc = a.cols (); | |
5164 | 613 |
5275 | 614 octave_idx_type b_nr = b.rows (); |
615 octave_idx_type b_nc = b.cols (); | |
5164 | 616 |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
617 if (a.numel () == 1 && b.numel () > 1) |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
618 return scalar_xpow (a(0), b); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
619 |
5164 | 620 if (nr != b_nr || nc != b_nc) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
621 octave::err_nonconformant ("operator .^", nr, nc, b_nr, b_nc); |
5164 | 622 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
623 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); |
5275 | 624 for (octave_idx_type j = 0; j < nc; j++) |
5164 | 625 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
626 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
627 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
628 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
629 result.xelem (a.ridx(i), j) = std::pow (a.data (i), b(a.ridx (i), j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
630 } |
5164 | 631 } |
632 | |
5953 | 633 result.maybe_compress (true); |
5164 | 634 |
635 return result; | |
636 } | |
637 | |
638 // -*- 7 -*- | |
639 octave_value | |
640 elem_xpow (const Complex& a, const SparseMatrix& b) | |
641 { | |
5275 | 642 octave_idx_type nr = b.rows (); |
643 octave_idx_type nc = b.cols (); | |
5164 | 644 |
645 ComplexMatrix result (nr, nc); | |
646 | |
5275 | 647 for (octave_idx_type j = 0; j < nc; j++) |
5164 | 648 { |
5275 | 649 for (octave_idx_type i = 0; i < nr; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
650 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
651 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
652 double btmp = b (i, j); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
653 if (xisint (btmp)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
654 result (i, j) = std::pow (a, static_cast<int> (btmp)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
655 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
656 result (i, j) = std::pow (a, btmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
657 } |
5164 | 658 } |
659 | |
660 return result; | |
661 } | |
662 | |
663 // -*- 8 -*- | |
664 octave_value | |
665 elem_xpow (const Complex& a, const SparseComplexMatrix& b) | |
666 { | |
5275 | 667 octave_idx_type nr = b.rows (); |
668 octave_idx_type nc = b.cols (); | |
5164 | 669 |
670 ComplexMatrix result (nr, nc); | |
5275 | 671 for (octave_idx_type j = 0; j < nc; j++) |
672 for (octave_idx_type i = 0; i < nr; i++) | |
5164 | 673 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
674 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
675 result (i, j) = std::pow (a, b (i, j)); |
5164 | 676 } |
677 | |
678 return result; | |
679 } | |
680 | |
681 // -*- 9 -*- | |
682 octave_value | |
683 elem_xpow (const SparseComplexMatrix& a, double b) | |
684 { | |
685 octave_value retval; | |
686 | |
687 if (b <= 0) | |
688 { | |
5275 | 689 octave_idx_type nr = a.rows (); |
690 octave_idx_type nc = a.cols (); | |
5164 | 691 |
5953 | 692 ComplexMatrix result (nr, nc, Complex (std::pow (0.0, b))); |
5164 | 693 |
694 if (xisint (b)) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
695 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
696 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
697 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
698 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
699 octave_quit (); |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
700 result (a.ridx (i), j) |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
701 = std::pow (a.data (i), static_cast<int> (b)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
702 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
703 } |
5164 | 704 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
705 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
706 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
707 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
708 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
709 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
710 result (a.ridx (i), j) = std::pow (a.data (i), b); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
711 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
712 } |
5164 | 713 |
714 retval = result; | |
715 } | |
716 else | |
717 { | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10315
diff
changeset
|
718 octave_idx_type nz = a.nnz (); |
5164 | 719 |
720 SparseComplexMatrix result (a); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
721 |
5164 | 722 if (xisint (b)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
723 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
724 for (octave_idx_type i = 0; i < nz; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
725 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
726 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
727 result.data (i) = std::pow (a.data (i), static_cast<int> (b)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
728 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
729 } |
5164 | 730 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
731 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
732 for (octave_idx_type i = 0; i < nz; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
733 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
734 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
735 result.data (i) = std::pow (a.data (i), b); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
736 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
737 } |
5164 | 738 |
739 result.maybe_compress (true); | |
740 | |
741 retval = result; | |
742 } | |
743 | |
744 return retval; | |
745 } | |
746 | |
747 // -*- 10 -*- | |
748 octave_value | |
749 elem_xpow (const SparseComplexMatrix& a, const SparseMatrix& b) | |
750 { | |
5275 | 751 octave_idx_type nr = a.rows (); |
752 octave_idx_type nc = a.cols (); | |
5164 | 753 |
5275 | 754 octave_idx_type b_nr = b.rows (); |
755 octave_idx_type b_nc = b.cols (); | |
5164 | 756 |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
757 if (a.numel () == 1 && b.numel () > 1) |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
758 return scalar_xpow (a(0), b); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
759 |
5164 | 760 if (nr != b_nr || nc != b_nc) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
761 octave::err_nonconformant ("operator .^", nr, nc, b_nr, b_nc); |
5164 | 762 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
763 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); |
5275 | 764 for (octave_idx_type j = 0; j < nc; j++) |
5164 | 765 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
766 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
767 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
768 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
769 double btmp = b(a.ridx (i), j); |
5164 | 770 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
771 if (xisint (btmp)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
772 result.xelem (a.ridx (i), j) = std::pow (a.data (i), |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
773 static_cast<int> (btmp)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
774 else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
775 result.xelem (a.ridx (i), j) = std::pow (a.data (i), btmp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
776 } |
5164 | 777 } |
778 | |
5953 | 779 result.maybe_compress (true); |
5164 | 780 |
781 return result; | |
782 } | |
783 | |
784 // -*- 11 -*- | |
785 octave_value | |
786 elem_xpow (const SparseComplexMatrix& a, const Complex& b) | |
787 { | |
788 octave_value retval; | |
789 | |
790 if (b == 0.0) | |
791 // Can this case ever happen, due to automatic retyping with maybe_mutate? | |
792 retval = octave_value (NDArray (a.dims (), 1)); | |
793 else | |
794 { | |
795 | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10315
diff
changeset
|
796 octave_idx_type nz = a.nnz (); |
5164 | 797 |
798 SparseComplexMatrix result (a); | |
799 | |
5275 | 800 for (octave_idx_type i = 0; i < nz; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
801 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
802 octave_quit (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
803 result.data (i) = std::pow (a.data (i), b); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
804 } |
5164 | 805 |
806 result.maybe_compress (true); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
807 |
5164 | 808 retval = result; |
809 } | |
810 | |
811 return retval; | |
812 } | |
813 | |
814 // -*- 12 -*- | |
815 octave_value | |
816 elem_xpow (const SparseComplexMatrix& a, const SparseComplexMatrix& b) | |
817 { | |
5275 | 818 octave_idx_type nr = a.rows (); |
819 octave_idx_type nc = a.cols (); | |
5164 | 820 |
5275 | 821 octave_idx_type b_nr = b.rows (); |
822 octave_idx_type b_nc = b.cols (); | |
5164 | 823 |
15282
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
824 if (a.numel () == 1 && b.numel () > 1) |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
825 return scalar_xpow (a(0), b); |
06ce57277bfb
handle scalar-sparse-matrix .^ matrix ops
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
826 |
5164 | 827 if (nr != b_nr || nc != b_nc) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
828 octave::err_nonconformant ("operator .^", nr, nc, b_nr, b_nc); |
5164 | 829 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
830 SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
831 for (octave_idx_type j = 0; j < nc; j++) |
5164 | 832 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
833 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
834 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
835 octave_quit (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17749
diff
changeset
|
836 result.xelem (a.ridx (i), j) = std::pow (a.data (i), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17749
diff
changeset
|
837 b(a.ridx (i), j)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
838 } |
5164 | 839 } |
840 result.maybe_compress (true); | |
841 | |
842 return result; | |
843 } | |
29990
b839c36fd106
move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
844 |
31234
a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31231
diff
changeset
|
845 |
29990
b839c36fd106
move sparse xdiv and xpow operator functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
846 OCTAVE_NAMESPACE_END |