# HG changeset patch # User John W. Eaton # Date 1223483113 14400 # Node ID 5ac184c0581168c9c627fead187057dcf1d3bfb8 # Parent 4c85b8056d0bc57d795fa5e9f88787ca45a1db9f additional AIX build fix diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2008-10-08 John W. Eaton + + * Sparse-op-defs.h (SPARSE_SMSM_BOOL_OPS): Duplicate code for scalar + sparse arguments rather than rely on extern function. + 2008-10-08 Jaroslav Hajek * oct-inttypes.h (octave_base_int::compute_threshold): Return diff --git a/liboctave/Sparse-op-defs.h b/liboctave/Sparse-op-defs.h --- a/liboctave/Sparse-op-defs.h +++ b/liboctave/Sparse-op-defs.h @@ -735,6 +735,10 @@ SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \ SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API); +// FIXME -- this macro duplicatest the bodies of the template +// functions defined in the SPARSE_SSM_CMP_OP and SPARSE_SMS_CMP_OP +// macros. + #define SPARSE_SMSM_CMP_OP(F, OP, M1, Z1, C1, M2, Z2, C2) \ SparseBoolMatrix \ F (const M1& m1, const M2& m2) \ @@ -915,6 +919,10 @@ SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \ SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API); +// FIXME -- this macro duplicatest the bodies of the template +// functions defined in the SPARSE_SSM_BOOL_OP and SPARSE_SMS_BOOL_OP +// macros. + #define SPARSE_SMSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ SparseBoolMatrix \ F (const M1& m1, const M2& m2) \ @@ -929,15 +937,67 @@ \ if (m1_nr == 1 && m1_nc == 1) \ { \ - extern OCTAVE_API SparseBoolMatrix F (const double&, const M2&); \ - extern OCTAVE_API SparseBoolMatrix F (const Complex&, const M2&); \ - r = F (m1.elem(0,0), m2); \ + if (m2_nr > 0 && m2_nc > 0) \ + { \ + if ((m1.elem(0,0) != LHS_ZERO) OP RHS_ZERO) \ + { \ + r = SparseBoolMatrix (m2_nr, m2_nc, true); \ + for (octave_idx_type j = 0; j < m2_nc; j++) \ + for (octave_idx_type i = m2.cidx(j); i < m2.cidx(j+1); i++) \ + if (! ((m1.elem(0,0) != LHS_ZERO) OP (m2.data(i) != RHS_ZERO))) \ + r.data (m2.ridx (i) + j * m2_nr) = false; \ + r.maybe_compress (true); \ + } \ + else \ + { \ + r = SparseBoolMatrix (m2_nr, m2_nc, m2.nnz ()); \ + r.cidx (0) = static_cast (0); \ + octave_idx_type nel = 0; \ + for (octave_idx_type j = 0; j < m2_nc; j++) \ + { \ + for (octave_idx_type i = m2.cidx(j); i < m2.cidx(j+1); i++) \ + if ((m1.elem(0,0) != LHS_ZERO) OP (m2.data(i) != RHS_ZERO)) \ + { \ + r.ridx (nel) = m2.ridx (i); \ + r.data (nel++) = true; \ + } \ + r.cidx (j + 1) = nel; \ + } \ + r.maybe_compress (false); \ + } \ + } \ } \ else if (m2_nr == 1 && m2_nc == 1) \ { \ - extern OCTAVE_API SparseBoolMatrix F (const M1&, const double&); \ - extern OCTAVE_API SparseBoolMatrix F (const M1&, const Complex&); \ - r = F (m1, m2.elem(0,0)); \ + if (m1_nr > 0 && m1_nc > 0) \ + { \ + if (LHS_ZERO OP (m2.elem(0,0) != RHS_ZERO)) \ + { \ + r = SparseBoolMatrix (m1_nr, m1_nc, true); \ + for (octave_idx_type j = 0; j < m1_nc; j++) \ + for (octave_idx_type i = m1.cidx(j); i < m1.cidx(j+1); i++) \ + if (! ((m1.data(i) != LHS_ZERO) OP (m2.elem(0,0) != RHS_ZERO))) \ + r.data (m1.ridx (i) + j * m1_nr) = false; \ + r.maybe_compress (true); \ + } \ + else \ + { \ + r = SparseBoolMatrix (m1_nr, m1_nc, m1.nnz ()); \ + r.cidx (0) = static_cast (0); \ + octave_idx_type nel = 0; \ + for (octave_idx_type j = 0; j < m1_nc; j++) \ + { \ + for (octave_idx_type i = m1.cidx(j); i < m1.cidx(j+1); i++) \ + if ((m1.data(i) != LHS_ZERO) OP (m2.elem(0,0) != RHS_ZERO)) \ + { \ + r.ridx (nel) = m1.ridx (i); \ + r.data (nel++) = true; \ + } \ + r.cidx (j + 1) = nel; \ + } \ + r.maybe_compress (false); \ + } \ + } \ } \ else if (m1_nr == m2_nr && m1_nc == m2_nc) \ { \