diff --git a/documentation.html b/documentation.html index 9767498..8d98c40 100644 --- a/documentation.html +++ b/documentation.html @@ -85,7 +85,7 @@
+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);