diff liboctave/CSparse.cc @ 7269:3fade00a6ac7

[project @ 2007-12-07 19:26:20 by jwe]
author jwe
date Fri, 07 Dec 2007 19:26:21 +0000
parents daff886a8e2a
children 402168152bb9
line wrap: on
line diff
--- a/liboctave/CSparse.cc
+++ b/liboctave/CSparse.cc
@@ -7637,7 +7637,13 @@
 SparseComplexMatrix
 SparseComplexMatrix::prod (int dim) const
 {
-  SPARSE_REDUCTION_OP (SparseComplexMatrix, Complex, *=, 1.0, 1.0);
+  if ((rows() == 1 && dim == -1) || dim == 1)
+    return transpose (). prod (0). transpose();
+  else
+    {
+      SPARSE_REDUCTION_OP (SparseComplexMatrix, Complex, *=, 
+			   (cidx(j+1) - cidx(j) < nc ? 0.0 : 1.0), 1.0);
+    }
 }
 
 SparseComplexMatrix
@@ -7650,11 +7656,11 @@
 SparseComplexMatrix::sumsq (int dim) const
 {
 #define ROW_EXPR \
-  Complex d = elem (i, j); \
-  tmp [i] += d * conj (d)
+  Complex d = data (i); \
+  tmp [ridx(i)] += d * conj (d)
 
 #define COL_EXPR \
-  Complex d = elem (i, j); \
+  Complex d = data (i); \
   tmp [j] += d * conj (d)
 
   SPARSE_BASE_REDUCTION_OP (SparseComplexMatrix, Complex, ROW_EXPR,