Mercurial > hg > octave-lojdl
changeset 7004:45d6cc5a0359
[project @ 2007-10-10 18:51:45 by jwe]
author | jwe |
---|---|
date | Wed, 10 Oct 2007 18:51:46 +0000 |
parents | 2980cb35270c |
children | 064f298f812f |
files | src/ChangeLog src/OPERATORS/op-sbm-sbm.cc src/ov-re-mat.cc |
diffstat | 3 files changed, 41 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2007-10-10 John W. Eaton <jwe@octave.org> + + * OPERATORS/op-sbm-sbm.cc (bool_matrix_to_double_matrix): + New conversion function. + (install_sbm_sbm_ops): Install it. + + * ov-re-mat.cc (double): Handle sparse as a special case. + 2007-10-10 Olli Saarela <Olli.Saarela@kcl.fi> * data.cc, debug.cc, dirfns.cc, error.cc, file-io.cc, help.cc,
--- a/src/OPERATORS/op-sbm-sbm.cc +++ b/src/OPERATORS/op-sbm-sbm.cc @@ -74,6 +74,15 @@ DEFASSIGNOP_FN (assign, sparse_bool_matrix, sparse_bool_matrix, assign) +CONVDECL (bool_matrix_to_double_matrix) +{ + CAST_CONV_ARG (const octave_sparse_bool_matrix&); + + return new octave_sparse_matrix (SparseMatrix (v.sparse_bool_matrix_value ())); +} + +DEFDBLCONVFN (, sparse_bool_matrix, bool_array) + void install_sbm_sbm_ops (void) { @@ -99,7 +108,10 @@ INSTALL_CATOP (octave_sparse_matrix, octave_sparse_bool_matrix, sm_sbm); INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_bool_matrix, - octave_sparse_bool_matrix, assign); + octave_sparse_bool_matrix, assign); + + INSTALL_CONVOP (octave_sparse_bool_matrix, octave_sparse_matrix, + bool_matrix_to_double_matrix); } /*
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -48,6 +48,7 @@ #include "ov-base-mat.cc" #include "ov-scalar.h" #include "ov-re-mat.h" +#include "ov-re-sparse.h" #include "ov-type-conv.h" #include "pr-output.h" #include "variables.h" @@ -653,7 +654,25 @@ Convert @var{x} to double precision type.\n\ @end deftypefn") { - OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar); + // The OCTAVE_TYPE_CONV_BODY3 macro declares retval, so they go + // inside their own scopes, and we don't declare retval here to + // avoid a shadowed declaration warning. + + if (args.length () == 1) + { + if (args(0).is_sparse_type ()) + { + OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_matrix, octave_scalar); + } + else + { + OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar); + } + } + else + print_usage (); + + return octave_value (); } /*