op-pm-pm.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2008-2012 Jaroslav Hajek
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include "gripes.h"
00028 #include "oct-obj.h"
00029 #include "ov.h"
00030 #include "ov-perm.h"
00031 #include "ov-re-mat.h"
00032 #include "ov-scalar.h"
00033 #include "ov-typeinfo.h"
00034 #include "ops.h"
00035 #include "xpow.h"
00036 
00037 DEFUNOP (transpose, perm_matrix)
00038 {
00039   CAST_UNOP_ARG (const octave_perm_matrix&);
00040   return octave_value (v.perm_matrix_value().transpose ());
00041 }
00042 
00043 DEFBINOP_OP (mul, perm_matrix, perm_matrix, *)
00044 
00045 DEFBINOP (div, perm_matrix, perm_matrix)
00046 {
00047   CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&);
00048 
00049   return (v1.perm_matrix_value () * v2.perm_matrix_value ().inverse ());
00050 }
00051 
00052 DEFBINOP (ldiv, perm_matrix, perm_matrix)
00053 {
00054   CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_perm_matrix&);
00055 
00056   return (v1.perm_matrix_value ().inverse () * v2.perm_matrix_value ());
00057 }
00058 
00059 DEFBINOP (pow, perm_matrix, scalar)
00060 {
00061   CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_scalar&);
00062 
00063   return xpow (v1.perm_matrix_value (), v2.scalar_value ());
00064 }
00065 
00066 CONVDECL (perm_matrix_to_matrix)
00067 {
00068   CAST_CONV_ARG (const octave_perm_matrix&);
00069 
00070   return new octave_matrix (v.matrix_value ());
00071 }
00072 
00073 void
00074 install_pm_pm_ops (void)
00075 {
00076   INSTALL_UNOP (op_transpose, octave_perm_matrix, transpose);
00077   INSTALL_UNOP (op_hermitian, octave_perm_matrix, transpose);
00078 
00079   INSTALL_BINOP (op_mul, octave_perm_matrix, octave_perm_matrix, mul);
00080   INSTALL_BINOP (op_div, octave_perm_matrix, octave_perm_matrix, div);
00081   INSTALL_BINOP (op_ldiv, octave_perm_matrix, octave_perm_matrix, ldiv);
00082   INSTALL_BINOP (op_pow, octave_perm_matrix, octave_scalar, pow);
00083 
00084   INSTALL_CONVOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix);
00085   INSTALL_ASSIGNCONV (octave_perm_matrix, octave_matrix, octave_matrix);
00086   INSTALL_WIDENOP (octave_perm_matrix, octave_matrix, perm_matrix_to_matrix);
00087 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines