// Patch numeric to add a sparse matrix transpose routine.
numeric.ccsTranspose = function( A )
{
var rows_cols_vals = numeric.ccsGather( A );
// Swap the rows and cols.
return numeric.ccsScatter( [ rows_cols_vals[1], rows_cols_vals[0], rows_cols_vals[2] ] );
}
// Patch numeric to add a sparse matrix diagonal routine.
numeric.ccsDiag = function( diag )
{
var ij = [];
for( var i = 0; i < diag.length; ++i ) ij.push( i );
return numeric.ccsScatter( [ ij, ij, diag ] );
}
// Patch numeric to add a sparse matrix identity.
numeric.ccsIdentity = function( N )
{
return numeric.ccsDiag( numeric.rep( [N], 1. ) );
}
// Patch numeric to add a sparse matrix column sum.
// NOTE: There is no sparse matrix row sum, because it would have to first compute the transpose each time.
numeric.ccsSumColumn = function( A, col )
{
var sum = 0.;
for( var k = A[0][col]; k < A[0][col+1]; ++k ) sum += A[2][k];
return sum;
}
Hi Yotam,
Thanks for your emails. What you send looks good. I will try to do this by the holidays!
S
--
You received this message because you are subscribed to the Google Groups "numericjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numericjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.