Mercurial > hg > octave-lyh
annotate libinterp/operators/op-pm-pm.cc @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | 2fc554ffbc28 |
children |
rev | line source |
---|---|
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 /* |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 2008-2012 Jaroslav Hajek |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 option) any later version. |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 for more details. |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 */ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
24 #include <config.h> |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 #endif |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 #include "gripes.h" |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 #include "oct-obj.h" |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 #include "ov.h" |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 #include "ov-perm.h" |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 #include "ov-re-mat.h" |
8958
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
32 #include "ov-scalar.h" |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 #include "ov-typeinfo.h" |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 #include "ops.h" |
8958
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
35 #include "xpow.h" |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 DEFUNOP (transpose, perm_matrix) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
38 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 CAST_UNOP_ARG (const octave_perm_matrix&); |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
40 return octave_value (v.perm_matrix_value ().transpose ()); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 DEFBINOP_OP (mul, perm_matrix, perm_matrix, *) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 DEFBINOP (div, perm_matrix, perm_matrix) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
48 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 return (v1.perm_matrix_value () * v2.perm_matrix_value ().inverse ()); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
52 DEFBINOP (ldiv, perm_matrix, perm_matrix) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
55 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 return (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value ()); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
57 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
58 |
8958
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
59 DEFBINOP (pow, perm_matrix, scalar) |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
60 { |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_scalar&); |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
62 |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
63 return xpow (v1.perm_matrix_value (), v2.scalar_value ()); |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 } |
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
65 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 CONVDECL (perm_matrix_to_matrix) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 CAST_CONV_ARG (const octave_perm_matrix&); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 return new octave_matrix (v.matrix_value ()); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
72 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
73 void |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
74 install_pm_pm_ops (void) |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
75 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
76 INSTALL_UNOP (op_transpose, octave_perm_matrix, transpose); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
77 INSTALL_UNOP (op_hermitian, octave_perm_matrix, transpose); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
78 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
79 INSTALL_BINOP (op_mul, octave_perm_matrix, octave_perm_matrix, mul); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
80 INSTALL_BINOP (op_div, octave_perm_matrix, octave_perm_matrix, div); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
81 INSTALL_BINOP (op_ldiv, octave_perm_matrix, octave_perm_matrix, ldiv); |
8958
6ccc12cc65ef
implement raising a permutation matrix to integer power
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
82 INSTALL_BINOP (op_pow, octave_perm_matrix, octave_scalar, pow); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 INSTALL_CONVOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 INSTALL_ASSIGNCONV (octave_perm_matrix, octave_matrix, octave_matrix); |
8453
9e1973f7709d
fix missing widening ops for diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
86 INSTALL_WIDENOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
87 } |