Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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-typeinfo.h"
00031 #include "ops.h"
00032
00033 #include "ov-perm.h"
00034 #include "ov-cx-sparse.h"
00035
00036
00037
00038 DEFBINOP (mul_pm_scm, perm_matrix, sparse_complex_matrix)
00039 {
00040 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_sparse_complex_matrix&);
00041
00042 if (v2.rows() == 1 && v2.columns() == 1)
00043 {
00044 std::complex<double> d = v2.complex_value ();
00045
00046 return octave_value (v1.sparse_matrix_value () * d);
00047 }
00048 else if (v1.rows() == 1 && v1.columns() == 1)
00049 return octave_value (v2.sparse_complex_matrix_value ());
00050 else
00051 return v1.perm_matrix_value () * v2.sparse_complex_matrix_value ();
00052 }
00053
00054 DEFBINOP (ldiv_pm_scm, perm_matrix, sparse_complex_matrix)
00055 {
00056 CAST_BINOP_ARGS (const octave_perm_matrix&, const octave_sparse_complex_matrix&);
00057
00058 return v1.perm_matrix_value ().inverse () * v2.sparse_complex_matrix_value ();
00059 }
00060
00061
00062
00063 DEFBINOP (mul_scm_pm, sparse_complex_matrix, perm_matrix)
00064 {
00065 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_perm_matrix&);
00066
00067 if (v1.rows() == 1 && v1.columns() == 1)
00068 {
00069 std::complex<double> d = v1.scalar_value ();
00070
00071 return octave_value (d * v2.sparse_matrix_value ());
00072 }
00073 else if (v2.rows() == 1 && v2.columns() == 1)
00074 return octave_value (v1.sparse_complex_matrix_value ());
00075 else
00076 return v1.sparse_complex_matrix_value () * v2.perm_matrix_value ();
00077 }
00078
00079 DEFBINOP (div_scm_pm, sparse_complex_matrix, perm_matrix)
00080 {
00081 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_perm_matrix&);
00082
00083 return v1.sparse_complex_matrix_value () * v2.perm_matrix_value ().inverse ();
00084 }
00085
00086 void
00087 install_pm_scm_ops (void)
00088 {
00089 INSTALL_BINOP (op_mul, octave_perm_matrix, octave_sparse_complex_matrix,
00090 mul_pm_scm);
00091 INSTALL_BINOP (op_ldiv, octave_perm_matrix, octave_sparse_complex_matrix,
00092 ldiv_pm_scm);
00093 INSTALL_BINOP (op_mul, octave_sparse_complex_matrix, octave_perm_matrix,
00094 mul_scm_pm);
00095 INSTALL_BINOP (op_div, octave_sparse_complex_matrix, octave_perm_matrix,
00096 div_scm_pm);
00097 }