# HG changeset patch # User jwe # Date 1192042306 0 # Node ID 45d6cc5a0359ad613bbb1db06c751f704097f1c7 # Parent 2980cb35270cd3070d8cdf54e2585edf5614fc0f [project @ 2007-10-10 18:51:45 by jwe] diff -r 2980cb35270c -r 45d6cc5a0359 src/ChangeLog --- a/src/ChangeLog Wed Oct 10 18:39:58 2007 +0000 +++ b/src/ChangeLog Wed Oct 10 18:51:46 2007 +0000 @@ -1,3 +1,11 @@ +2007-10-10 John W. Eaton + + * 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 * data.cc, debug.cc, dirfns.cc, error.cc, file-io.cc, help.cc, diff -r 2980cb35270c -r 45d6cc5a0359 src/OPERATORS/op-sbm-sbm.cc --- a/src/OPERATORS/op-sbm-sbm.cc Wed Oct 10 18:39:58 2007 +0000 +++ b/src/OPERATORS/op-sbm-sbm.cc Wed Oct 10 18:51:46 2007 +0000 @@ -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); } /* diff -r 2980cb35270c -r 45d6cc5a0359 src/ov-re-mat.cc --- a/src/ov-re-mat.cc Wed Oct 10 18:39:58 2007 +0000 +++ b/src/ov-re-mat.cc Wed Oct 10 18:51:46 2007 +0000 @@ -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 (); } /*