diff --git a/documentation.html b/documentation.html index 9767498..8d98c40 100644 --- a/documentation.html +++ b/documentation.html @@ -85,7 +85,7 @@ epsilon2.220446049250313e-16 eqPointwise comparison x === y expPointwise Math.exp(x) -floorPoinwise Math.floor(x) +floorPointwise Math.floor(x) geqPointwise x>=y getBlockExtract a block from a matrix getDiagGet the diagonal of a matrix diff --git a/src/documentation.html b/src/documentation.html index 9767498..b1bc095 100644 --- a/src/documentation.html +++ b/src/documentation.html @@ -49,6 +49,7 @@ bnotBinary negation ~x borBinary or x|y bxorBinary xor x^y +ccsDiagCreate sparse diagonal matrix ccsDimDimensions of sparse matrix ccsDotSparse matrix-matrix product ccsFullConvert sparse to full @@ -58,6 +59,7 @@ ccsLUPSolveSolve Ax=b using LUP decomp ccsScatterScatter entries of sparse matrix ccsSparseConvert from full to sparse +ccsTransposeSparse matrix transpose ccsTSolveSolve upper/lower triangular system ccs<op>Supported ops include: add/div/mul/geq/etc... cLUCoordinate matrix LU decomposition @@ -838,6 +840,20 @@

Sparse linear algebra

IN> numeric.ccsDot(M,[[0,3],[0,1,2],x]) OUT> [[0,3],[0,1,2],[9,3,2]] +Create a sparse diangoal matrix +
+IN> SA = numeric.ccsDiag([1,2,3]);
+OUT> [[ 0, 1, 2, 3],
+      [ 0, 1, 2],
+      [ 1, 2, 3]]
+
+Tranpose a sparse matrix +
+IN> numeric.ccsTranspose(numeric.ccsScatter([[0,1,2],[2,1,0],[1,2,4]]));
+OUT> [[ 0, 1, 2, 3],
+      [ 2, 1, 0],
+      [ 1, 2, 4]]  
+
We provide an LU=PA decomposition:
 IN> A = [[0,5,10,15,20,25],
diff --git a/src/numeric.js b/src/numeric.js
index 537b68f..7a7b1b2 100644
--- a/src/numeric.js
+++ b/src/numeric.js
@@ -1600,6 +1600,16 @@ numeric.ccsFull = function ccsFull(A) {
     }
     return B;
 }
+numeric.ccsDiag = function ccsDiag(diag) {
+    var ij = [];
+    for( var i = 0; i < diag.length; ++i ) ij.push( i );
+    return numeric.ccsScatter( [ ij, ij, diag ] );
+}
+numeric.ccsTranspose = function ccsTranspose( A )
+{
+    var rows_cols_vals = numeric.ccsGather( A );
+    return numeric.ccsScatter( [ rows_cols_vals[1], rows_cols_vals[0], rows_cols_vals[2] ] );
+}
 numeric.ccsTSolve = function ccsTSolve(A,b,x,bj,xj) {
     var Ai = A[0], Aj = A[1], Av = A[2],m = Ai.length-1, max = Math.max,n=0;
     if(typeof bj === "undefined") x = numeric.rep([m],0);