Mercurial > hg > octave-nkf
comparison liboctave/Sparse-op-defs.h @ 8198:5ac184c05811
additional AIX build fix
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Oct 2008 12:25:13 -0400 |
parents | b04109600a82 |
children | 25bc2d31e1bf |
comparison
equal
deleted
inserted
replaced
8197:4c85b8056d0b | 8198:5ac184c05811 |
---|---|
732 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API); | 732 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API); |
733 | 733 |
734 #define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API) \ | 734 #define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API) \ |
735 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \ | 735 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \ |
736 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API); | 736 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API); |
737 | |
738 // FIXME -- this macro duplicatest the bodies of the template | |
739 // functions defined in the SPARSE_SSM_CMP_OP and SPARSE_SMS_CMP_OP | |
740 // macros. | |
737 | 741 |
738 #define SPARSE_SMSM_CMP_OP(F, OP, M1, Z1, C1, M2, Z2, C2) \ | 742 #define SPARSE_SMSM_CMP_OP(F, OP, M1, Z1, C1, M2, Z2, C2) \ |
739 SparseBoolMatrix \ | 743 SparseBoolMatrix \ |
740 F (const M1& m1, const M2& m2) \ | 744 F (const M1& m1, const M2& m2) \ |
741 { \ | 745 { \ |
913 | 917 |
914 #define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API) \ | 918 #define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API) \ |
915 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \ | 919 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \ |
916 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API); | 920 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API); |
917 | 921 |
922 // FIXME -- this macro duplicatest the bodies of the template | |
923 // functions defined in the SPARSE_SSM_BOOL_OP and SPARSE_SMS_BOOL_OP | |
924 // macros. | |
925 | |
918 #define SPARSE_SMSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ | 926 #define SPARSE_SMSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ |
919 SparseBoolMatrix \ | 927 SparseBoolMatrix \ |
920 F (const M1& m1, const M2& m2) \ | 928 F (const M1& m1, const M2& m2) \ |
921 { \ | 929 { \ |
922 SparseBoolMatrix r; \ | 930 SparseBoolMatrix r; \ |
927 octave_idx_type m2_nr = m2.rows (); \ | 935 octave_idx_type m2_nr = m2.rows (); \ |
928 octave_idx_type m2_nc = m2.cols (); \ | 936 octave_idx_type m2_nc = m2.cols (); \ |
929 \ | 937 \ |
930 if (m1_nr == 1 && m1_nc == 1) \ | 938 if (m1_nr == 1 && m1_nc == 1) \ |
931 { \ | 939 { \ |
932 extern OCTAVE_API SparseBoolMatrix F (const double&, const M2&); \ | 940 if (m2_nr > 0 && m2_nc > 0) \ |
933 extern OCTAVE_API SparseBoolMatrix F (const Complex&, const M2&); \ | 941 { \ |
934 r = F (m1.elem(0,0), m2); \ | 942 if ((m1.elem(0,0) != LHS_ZERO) OP RHS_ZERO) \ |
943 { \ | |
944 r = SparseBoolMatrix (m2_nr, m2_nc, true); \ | |
945 for (octave_idx_type j = 0; j < m2_nc; j++) \ | |
946 for (octave_idx_type i = m2.cidx(j); i < m2.cidx(j+1); i++) \ | |
947 if (! ((m1.elem(0,0) != LHS_ZERO) OP (m2.data(i) != RHS_ZERO))) \ | |
948 r.data (m2.ridx (i) + j * m2_nr) = false; \ | |
949 r.maybe_compress (true); \ | |
950 } \ | |
951 else \ | |
952 { \ | |
953 r = SparseBoolMatrix (m2_nr, m2_nc, m2.nnz ()); \ | |
954 r.cidx (0) = static_cast<octave_idx_type> (0); \ | |
955 octave_idx_type nel = 0; \ | |
956 for (octave_idx_type j = 0; j < m2_nc; j++) \ | |
957 { \ | |
958 for (octave_idx_type i = m2.cidx(j); i < m2.cidx(j+1); i++) \ | |
959 if ((m1.elem(0,0) != LHS_ZERO) OP (m2.data(i) != RHS_ZERO)) \ | |
960 { \ | |
961 r.ridx (nel) = m2.ridx (i); \ | |
962 r.data (nel++) = true; \ | |
963 } \ | |
964 r.cidx (j + 1) = nel; \ | |
965 } \ | |
966 r.maybe_compress (false); \ | |
967 } \ | |
968 } \ | |
935 } \ | 969 } \ |
936 else if (m2_nr == 1 && m2_nc == 1) \ | 970 else if (m2_nr == 1 && m2_nc == 1) \ |
937 { \ | 971 { \ |
938 extern OCTAVE_API SparseBoolMatrix F (const M1&, const double&); \ | 972 if (m1_nr > 0 && m1_nc > 0) \ |
939 extern OCTAVE_API SparseBoolMatrix F (const M1&, const Complex&); \ | 973 { \ |
940 r = F (m1, m2.elem(0,0)); \ | 974 if (LHS_ZERO OP (m2.elem(0,0) != RHS_ZERO)) \ |
975 { \ | |
976 r = SparseBoolMatrix (m1_nr, m1_nc, true); \ | |
977 for (octave_idx_type j = 0; j < m1_nc; j++) \ | |
978 for (octave_idx_type i = m1.cidx(j); i < m1.cidx(j+1); i++) \ | |
979 if (! ((m1.data(i) != LHS_ZERO) OP (m2.elem(0,0) != RHS_ZERO))) \ | |
980 r.data (m1.ridx (i) + j * m1_nr) = false; \ | |
981 r.maybe_compress (true); \ | |
982 } \ | |
983 else \ | |
984 { \ | |
985 r = SparseBoolMatrix (m1_nr, m1_nc, m1.nnz ()); \ | |
986 r.cidx (0) = static_cast<octave_idx_type> (0); \ | |
987 octave_idx_type nel = 0; \ | |
988 for (octave_idx_type j = 0; j < m1_nc; j++) \ | |
989 { \ | |
990 for (octave_idx_type i = m1.cidx(j); i < m1.cidx(j+1); i++) \ | |
991 if ((m1.data(i) != LHS_ZERO) OP (m2.elem(0,0) != RHS_ZERO)) \ | |
992 { \ | |
993 r.ridx (nel) = m1.ridx (i); \ | |
994 r.data (nel++) = true; \ | |
995 } \ | |
996 r.cidx (j + 1) = nel; \ | |
997 } \ | |
998 r.maybe_compress (false); \ | |
999 } \ | |
1000 } \ | |
941 } \ | 1001 } \ |
942 else if (m1_nr == m2_nr && m1_nc == m2_nc) \ | 1002 else if (m1_nr == m2_nr && m1_nc == m2_nc) \ |
943 { \ | 1003 { \ |
944 if (m1_nr != 0 || m1_nc != 0) \ | 1004 if (m1_nr != 0 || m1_nc != 0) \ |
945 { \ | 1005 { \ |