[Scipy-svn] r4416 - trunk/scipy/sparse/sparsetools

scipy-svn@scip... scipy-svn@scip...
Sat Jun 7 03:13:06 CDT 2008


Author: wnbell
Date: 2008-06-07 03:13:02 -0500 (Sat, 07 Jun 2008)
New Revision: 4416

Modified:
   trunk/scipy/sparse/sparsetools/coo.h
Log:
added coo_matvec


Modified: trunk/scipy/sparse/sparsetools/coo.h
===================================================================
--- trunk/scipy/sparse/sparsetools/coo.h	2008-06-06 06:54:44 UTC (rev 4415)
+++ trunk/scipy/sparse/sparsetools/coo.h	2008-06-07 08:13:02 UTC (rev 4416)
@@ -116,5 +116,37 @@
 }
 
 
+/*
+ * Compute Y += A*X for COO matrix A and dense vectors X,Y
+ *
+ *
+ * Input Arguments:
+ *   I  nnz           - number of nonzeros in A
+ *   I  Ai[nnz]       - row indices
+ *   I  Aj[nnz]       - column indices
+ *   T  Ax[nnz]       - nonzero values
+ *   T  Xx[n_col]     - input vector
+ *
+ * Output Arguments:
+ *   T  Yx[n_row]     - output vector
+ *
+ * Notes:
+ *   Output array Yx must be preallocated
+ *
+ *   Complexity: Linear.  Specifically O(nnz(A))
+ * 
+ */
+template <class I, class T>
+void coo_matvec(const I nnz,
+	            const I Ai[], 
+	            const I Aj[], 
+	            const T Ax[],
+	            const T Xx[],
+	                  T Yx[])
+{
+    for(I n = 0; n < nnz; n++){
+        Yx[Ai[n]] += Ax[n] * Xx[Aj[n]];
+    }
+}
 
 #endif



More information about the Scipy-svn mailing list