Skip to content

1. add ccsDiag/ccsTranspose 2. fix typo #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<tr><td><tt>epsilon</tt><td>2.220446049250313e-16
<tr><td><tt>eq</tt><td>Pointwise comparison x === y
<tr><td><tt>exp</tt><td>Pointwise Math.exp(x)
<tr><td><tt>floor</tt><td>Poinwise Math.floor(x)
<tr><td><tt>floor</tt><td>Pointwise Math.floor(x)
<tr><td><tt>geq</tt><td>Pointwise x&gt;=y
<tr><td><tt>getBlock</tt><td>Extract a block from a matrix
<tr><td><tt>getDiag</tt><td>Get the diagonal of a matrix
Expand Down
16 changes: 16 additions & 0 deletions src/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<tr><td><tt>bnot</tt><td>Binary negation ~x
<tr><td><tt>bor</tt><td>Binary or x|y
<tr><td><tt>bxor</tt><td>Binary xor x^y
<tr><td><tt>ccsDiag</tt><td>Create sparse diagonal matrix
<tr><td><tt>ccsDim</tt><td>Dimensions of sparse matrix
<tr><td><tt>ccsDot</tt><td>Sparse matrix-matrix product
<tr><td><tt>ccsFull</tt><td>Convert sparse to full
Expand All @@ -58,6 +59,7 @@
<tr><td><tt>ccsLUPSolve</tt><td>Solve Ax=b using LUP decomp
<tr><td><tt>ccsScatter</tt><td>Scatter entries of sparse matrix
<tr><td><tt>ccsSparse</tt><td>Convert from full to sparse
<tr><td><tt>ccsTranspose</tt><td>Sparse matrix transpose
<tr><td><tt>ccsTSolve</tt><td>Solve upper/lower triangular system
<tr><td><tt>ccs&lt;op&gt;</td><td>Supported ops include: add/div/mul/geq/etc...
<tr><td><tt>cLU</tt><td>Coordinate matrix LU decomposition
Expand Down Expand Up @@ -838,6 +840,20 @@ <h1>Sparse linear algebra</h1>
IN> numeric.ccsDot(M,[[0,3],[0,1,2],x])
OUT> [[0,3],[0,1,2],[9,3,2]]
</pre>
Create a sparse diangoal matrix
<pre>
IN> SA = numeric.ccsDiag([1,2,3]);
OUT> [[ 0, 1, 2, 3],
[ 0, 1, 2],
[ 1, 2, 3]]
</pre>
Tranpose a sparse matrix
<pre>
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]]
</pre>
We provide an LU=PA decomposition:
<pre>
IN> A = [[0,5,10,15,20,25],
Expand Down
10 changes: 10 additions & 0 deletions src/numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down