annotate src/OPERATORS/op-pm-pm.cc @ 8920:eb63fbe60fab

update copyright notices
author John W. Eaton <jwe@octave.org>
date Sat, 07 Mar 2009 10:41:27 -0500
parents 9e1973f7709d
children 6ccc12cc65ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8453
diff changeset
3 Copyright (C) 2008, 2009 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-flt-perm.h"
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 #include "ov-re-mat.h"
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"
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 DEFUNOP (transpose, perm_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 CAST_UNOP_ARG (const octave_perm_matrix&);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 return octave_value (v.perm_matrix_value().transpose ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 }
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 DEFBINOP_OP (mul, perm_matrix, perm_matrix, *)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 DEFBINOP (div, perm_matrix, perm_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 return (v1.perm_matrix_value () * v2.perm_matrix_value ().inverse ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 }
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 DEFBINOP (ldiv, perm_matrix, perm_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 return (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 }
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 CONVDECL (perm_matrix_to_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
59 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
60 CAST_CONV_ARG (const octave_perm_matrix&);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62 return new octave_matrix (v.matrix_value ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65 CONVDECL (perm_matrix_to_float_perm_matrix)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67 CAST_CONV_ARG (const octave_perm_matrix&);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
68
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69 return new octave_float_perm_matrix (v.perm_matrix_value ());
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70 }
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 void
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73 install_pm_pm_ops (void)
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 INSTALL_UNOP (op_transpose, octave_perm_matrix, transpose);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76 INSTALL_UNOP (op_hermitian, octave_perm_matrix, transpose);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 INSTALL_BINOP (op_mul, octave_perm_matrix, octave_perm_matrix, mul);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 INSTALL_BINOP (op_div, octave_perm_matrix, octave_perm_matrix, div);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80 INSTALL_BINOP (op_ldiv, octave_perm_matrix, octave_perm_matrix, ldiv);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
82 INSTALL_CONVOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
83 INSTALL_CONVOP (octave_perm_matrix, octave_float_perm_matrix, perm_matrix_to_float_perm_matrix);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 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
85 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
86 }