Mercurial > hg > octave-nkf
changeset 5631:7171d19706df
[project @ 2006-02-22 20:15:06 by dbateman]
author | dbateman |
---|---|
date | Wed, 22 Feb 2006 20:16:00 +0000 |
parents | 512d0d11ae39 |
children | 6e9a14b3c299 |
files | src/ChangeLog src/DLD-FUNCTIONS/__glpk__.cc src/DLD-FUNCTIONS/ccolamd.cc src/DLD-FUNCTIONS/colamd.cc src/DLD-FUNCTIONS/matrix_type.cc src/DLD-FUNCTIONS/sparse.cc src/DLD-FUNCTIONS/splu.cc src/ov-base-sparse.h src/ov-base.h src/ov.h src/pt-mat.cc |
diffstat | 11 files changed, 60 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2006-02-20 David Bateman <dbateman@free.fr> + * ov.h (virtual bool is_sparse_type (bool)): New virtual function + * ov-base.h (bool is_sparse_type (bool)): New function + * ov-base-sparse.h (bool is_sparse_type (bool)): New function + * DLD-FUNCTIONS/ccolamd.cc, DLD-FUNCTION/colamd.cc, + DLD-FUNCTIONS/__glpk__.cc, DLD-FUNCTIONS/splu.cc, + DLD-FUNCTIONS/sparse.cc, DLD-FUNCTIONS/matrix_type.cc, pt-mat.cc: + Replace us of 'arg.class_name () == "sparse"' with + 'arg.is_sparse_type ()' + +2006-02-20 David Bateman <dbateman@free.fr> + * pt-mat.cc (class tm_row_const): Add any_sparse bool variable. (tm_row_const::tm_row_const_rep::do_init_element): Initialize any_sparse variable if any matrice is sparse.
--- a/src/DLD-FUNCTIONS/__glpk__.cc +++ b/src/DLD-FUNCTIONS/__glpk__.cc @@ -450,37 +450,7 @@ //-- 2nd Input. A matrix containing the constraints coefficients. // If matrix A is NOT a sparse matrix - if( args(1).class_name () != "sparse") - { - Matrix A (args(1).matrix_value ()); // get the matrix - - if (error_state) - { - error ("__glpk__: invalid value of A"); - return retval; - } - - mrowsA = A.rows (); - rn.resize (mrowsA*mrowsc+1); - cn.resize (mrowsA*mrowsc+1); - a.resize (mrowsA*mrowsc+1, 0.0); - - for (int i = 0; i < mrowsA; i++) - { - for (int j = 0; j < mrowsc; j++) - { - if (A(i,j) != 0) - { - nz++; - rn(nz) = i + 1; - cn(nz) = j + 1; - a(nz) = A(i,j); - } - } - } - - } - else + if (args(1).is_sparse_type ()) { SparseMatrix A = args(1).sparse_matrix_value (); // get the sparse matrix @@ -512,6 +482,36 @@ a(nz) = A.data(i); } } + else + { + Matrix A (args(1).matrix_value ()); // get the matrix + + if (error_state) + { + error ("__glpk__: invalid value of A"); + return retval; + } + + mrowsA = A.rows (); + rn.resize (mrowsA*mrowsc+1); + cn.resize (mrowsA*mrowsc+1); + a.resize (mrowsA*mrowsc+1, 0.0); + + for (int i = 0; i < mrowsA; i++) + { + for (int j = 0; j < mrowsc; j++) + { + if (A(i,j) != 0) + { + nz++; + rn(nz) = i + 1; + cn(nz) = j + 1; + a(nz) = A(i,j); + } + } + } + + } //-- 3rd Input. A column array containing the right-hand side value // for each constraint in the constraint matrix.
--- a/src/DLD-FUNCTIONS/ccolamd.cc +++ b/src/DLD-FUNCTIONS/ccolamd.cc @@ -211,7 +211,7 @@ SparseComplexMatrix scm; SparseMatrix sm; - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) { @@ -447,7 +447,7 @@ SparseMatrix sm; SparseComplexMatrix scm; - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) {
--- a/src/DLD-FUNCTIONS/colamd.cc +++ b/src/DLD-FUNCTIONS/colamd.cc @@ -330,7 +330,7 @@ SparseComplexMatrix scm; SparseMatrix sm; - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) { @@ -539,7 +539,7 @@ SparseMatrix sm; SparseComplexMatrix scm; - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) { @@ -664,7 +664,7 @@ SparseMatrix sm; SparseComplexMatrix scm; - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) {
--- a/src/DLD-FUNCTIONS/matrix_type.cc +++ b/src/DLD-FUNCTIONS/matrix_type.cc @@ -104,7 +104,7 @@ error ("matrix_type: incorrect number of arguments"); else { - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (nargin == 1) {
--- a/src/DLD-FUNCTIONS/sparse.cc +++ b/src/DLD-FUNCTIONS/sparse.cc @@ -41,7 +41,7 @@ static bool is_sparse (const octave_value& arg) { - return (arg.class_name () == "sparse"); + return (arg.is_sparse_type ()); } DEFUN_DLD (issparse, args, , @@ -385,7 +385,7 @@ return retval; } - if (args(0).class_name () == "sparse") + if (args(0).is_sparse_type ()) { if (args(0).type_name () == "sparse matrix") retval = args(0).matrix_value (); @@ -563,7 +563,7 @@ octave_value arg = args(0); - if (arg.class_name () == "sparse") + if (arg.is_sparse_type ()) { if (arg.type_name () == "sparse matrix") retval = sparse_find (args(0).sparse_matrix_value ());
--- a/src/DLD-FUNCTIONS/splu.cc +++ b/src/DLD-FUNCTIONS/splu.cc @@ -99,7 +99,7 @@ for (int k = 1; k < nargin; k++) { - if (args(k).class_name () == "sparse") + if (args(k).is_sparse_type ()) { SparseMatrix tmp = args (k).sparse_matrix_value ();
--- a/src/ov-base-sparse.h +++ b/src/ov-base-sparse.h @@ -126,6 +126,8 @@ bool is_numeric_type (void) const { return true; } + bool is_sparse_type (void) const { return true; } + bool is_defined (void) const { return true; } bool is_constant (void) const { return true; }
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -163,6 +163,8 @@ bool is_numeric_type (void) const { return false; } + bool is_sparse_type (void) const { return false; } + bool valid_as_scalar_index (void) const { return false; } bool valid_as_zero_index (void) const { return false; }