Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cumsum() fixed for matrices

  • Loading branch information...
commit 3c03592ce2ff6423d6331c06db407828906ffd60 1 parent dda1dfd
@tushargupta51 tushargupta51 authored
Showing with 7 additions and 3 deletions.
  1. +1 −3 doc/md/vector.md
  2. +6 −0 src/vector.js
View
4 doc/md/vector.md
@@ -333,9 +333,7 @@ If callback is passed then will pass result as first argument.
If pass boolean true as first argument, then return cumulative sums of the matrix.
-**Note:** See [BUG #48](https://github.com/jstat/jstat/issues/48)
-
- jStat([[1,2],[3,4]]).cumsum( true ) === ...
+ jStat([[1,2],[3,4]]).cumsum( true ) === [[1,3],[3,7]]
And the two can be combined.
View
6 src/vector.js
@@ -93,6 +93,12 @@ jStat.extend({
// cumulative sum of an array
cumsum : function( arr ) {
+ // if arr is matrix, return as it is the desired cumulative matrix
+ if ( jStat.utils.isArray(arr[0]) )
+ {
+ return arr;
+ }
+
var len = arr.length,
sums = new Array( len ),
i = 1;
Please sign in to comment.
Something went wrong with that request. Please try again.