comparison src/OPERATORS/op-fpm-fpm.cc @ 8958:6ccc12cc65ef

implement raising a permutation matrix to integer power
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 11 Mar 2009 14:07:24 +0100
parents eb63fbe60fab
children
comparison
equal deleted inserted replaced
8957:360aa52b5942 8958:6ccc12cc65ef
28 #include "oct-obj.h" 28 #include "oct-obj.h"
29 #include "ov.h" 29 #include "ov.h"
30 #include "ov-perm.h" 30 #include "ov-perm.h"
31 #include "ov-flt-perm.h" 31 #include "ov-flt-perm.h"
32 #include "ov-flt-re-mat.h" 32 #include "ov-flt-re-mat.h"
33 #include "ov-float.h"
33 #include "ov-typeinfo.h" 34 #include "ov-typeinfo.h"
34 #include "ops.h" 35 #include "ops.h"
36 #include "xpow.h"
35 37
36 DEFUNOP (transpose, float_perm_matrix) 38 DEFUNOP (transpose, float_perm_matrix)
37 { 39 {
38 CAST_UNOP_ARG (const octave_float_perm_matrix&); 40 CAST_UNOP_ARG (const octave_float_perm_matrix&);
39 return octave_value (v.perm_matrix_value().transpose (), true); 41 return octave_value (v.perm_matrix_value().transpose (), true);
58 CAST_BINOP_ARGS (const octave_float_perm_matrix&, const octave_float_perm_matrix&); 60 CAST_BINOP_ARGS (const octave_float_perm_matrix&, const octave_float_perm_matrix&);
59 61
60 return octave_value (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value (), false); 62 return octave_value (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value (), false);
61 } 63 }
62 64
65 DEFBINOP (pow, float_perm_matrix, float_scalar)
66 {
67 CAST_BINOP_ARGS (const octave_float_perm_matrix&, const octave_float_scalar&);
68
69 return xpow (v1.perm_matrix_value (), v2.float_scalar_value ());
70 }
71
63 CONVDECL (float_perm_matrix_to_float_matrix) 72 CONVDECL (float_perm_matrix_to_float_matrix)
64 { 73 {
65 CAST_CONV_ARG (const octave_float_perm_matrix&); 74 CAST_CONV_ARG (const octave_float_perm_matrix&);
66 75
67 return new octave_float_matrix (v.float_matrix_value ()); 76 return new octave_float_matrix (v.float_matrix_value ());
81 INSTALL_UNOP (op_hermitian, octave_float_perm_matrix, transpose); 90 INSTALL_UNOP (op_hermitian, octave_float_perm_matrix, transpose);
82 91
83 INSTALL_BINOP (op_mul, octave_float_perm_matrix, octave_float_perm_matrix, mul); 92 INSTALL_BINOP (op_mul, octave_float_perm_matrix, octave_float_perm_matrix, mul);
84 INSTALL_BINOP (op_div, octave_float_perm_matrix, octave_float_perm_matrix, div); 93 INSTALL_BINOP (op_div, octave_float_perm_matrix, octave_float_perm_matrix, div);
85 INSTALL_BINOP (op_ldiv, octave_float_perm_matrix, octave_float_perm_matrix, ldiv); 94 INSTALL_BINOP (op_ldiv, octave_float_perm_matrix, octave_float_perm_matrix, ldiv);
95 INSTALL_BINOP (op_pow, octave_float_perm_matrix, octave_float_scalar, pow);
86 96
87 INSTALL_CONVOP (octave_float_perm_matrix, octave_float_matrix, float_perm_matrix_to_float_matrix); 97 INSTALL_CONVOP (octave_float_perm_matrix, octave_float_matrix, float_perm_matrix_to_float_matrix);
88 INSTALL_CONVOP (octave_float_perm_matrix, octave_perm_matrix, float_perm_matrix_to_perm_matrix); 98 INSTALL_CONVOP (octave_float_perm_matrix, octave_perm_matrix, float_perm_matrix_to_perm_matrix);
89 INSTALL_ASSIGNCONV (octave_float_perm_matrix, octave_float_matrix, octave_float_matrix); 99 INSTALL_ASSIGNCONV (octave_float_perm_matrix, octave_float_matrix, octave_float_matrix);
90 INSTALL_WIDENOP (octave_float_perm_matrix, octave_float_matrix, float_perm_matrix_to_float_matrix); 100 INSTALL_WIDENOP (octave_float_perm_matrix, octave_float_matrix, float_perm_matrix_to_float_matrix);