comparison 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
comparison
equal deleted inserted replaced
7268:47e4ebac1bfa 7269:3fade00a6ac7
7635 } 7635 }
7636 7636
7637 SparseComplexMatrix 7637 SparseComplexMatrix
7638 SparseComplexMatrix::prod (int dim) const 7638 SparseComplexMatrix::prod (int dim) const
7639 { 7639 {
7640 SPARSE_REDUCTION_OP (SparseComplexMatrix, Complex, *=, 1.0, 1.0); 7640 if ((rows() == 1 && dim == -1) || dim == 1)
7641 return transpose (). prod (0). transpose();
7642 else
7643 {
7644 SPARSE_REDUCTION_OP (SparseComplexMatrix, Complex, *=,
7645 (cidx(j+1) - cidx(j) < nc ? 0.0 : 1.0), 1.0);
7646 }
7641 } 7647 }
7642 7648
7643 SparseComplexMatrix 7649 SparseComplexMatrix
7644 SparseComplexMatrix::sum (int dim) const 7650 SparseComplexMatrix::sum (int dim) const
7645 { 7651 {
7648 7654
7649 SparseComplexMatrix 7655 SparseComplexMatrix
7650 SparseComplexMatrix::sumsq (int dim) const 7656 SparseComplexMatrix::sumsq (int dim) const
7651 { 7657 {
7652 #define ROW_EXPR \ 7658 #define ROW_EXPR \
7653 Complex d = elem (i, j); \ 7659 Complex d = data (i); \
7654 tmp [i] += d * conj (d) 7660 tmp [ridx(i)] += d * conj (d)
7655 7661
7656 #define COL_EXPR \ 7662 #define COL_EXPR \
7657 Complex d = elem (i, j); \ 7663 Complex d = data (i); \
7658 tmp [j] += d * conj (d) 7664 tmp [j] += d * conj (d)
7659 7665
7660 SPARSE_BASE_REDUCTION_OP (SparseComplexMatrix, Complex, ROW_EXPR, 7666 SPARSE_BASE_REDUCTION_OP (SparseComplexMatrix, Complex, ROW_EXPR,
7661 COL_EXPR, 0.0, 0.0); 7667 COL_EXPR, 0.0, 0.0);
7662 7668