js/morpheus.js
function () {
      var rowCounts = new Uint32Array(nrows);
      var columnCounts = new Uint32Array(ncols);
      for (var i = 0; i < nrows; i++) {
        var obj = matrix[i];
        if (obj.values != null) {
          // trim to size
          var values = new Uint16Array(obj.length);
          var indices = new Uint32Array(obj.length);
          values.set(obj.values.slice(0, obj.length));
          indices.set(obj.indices.slice(0, obj.length));
          matrix[i] = {values: values, indices: indices};
          rowCounts[i] = values.length;
          for (var j = 0; j < obj.length; j++) {
            columnCounts[indices[j]] += 1;
          }
        }
      }
      dataset = new morpheus.Dataset({
        rows: nrows, columns: ncols, name: morpheus.Util.getBaseFileName(morpheus.Util
          .getFileName(fileOrUrl)), array: matrix, dataType: dataType, defaultValue: 0
      });

      dataset.getRowMetadata().add('count>0').array = rowCounts;
      dataset.getColumnMetadata().add('count>0').array = columnCounts;
    }
function () {
      var rowCounts = new Uint32Array(nrows);
      var columnCounts = new Uint32Array(ncols);
      for (var i = 0; i < nrows; i++) {
        var obj = matrix[i];
        if (obj.values != null) {
          // trim to size
          var values = new Uint16Array(obj.length);
          var indices = new Uint32Array(obj.length);
          values.set(obj.values.slice(0, obj.length));
          indices.set(obj.indices.slice(0, obj.length));
          matrix[i] = {values: values, indices: indices};
          rowCounts[i] = values.length;
          for (var j = 0; j < obj.length; j++) {
            columnCounts[indices[j]] += 1;
          }
        }
      }
      dataset = new morpheus.Dataset({
        rows: nrows, columns: ncols, name: morpheus.Util.getBaseFileName(morpheus.Util
          .getFileName(fileOrUrl)), array: matrix, dataType: dataType, defaultValue: 0
      });

      dataset.getRowMetadata().add('count>0').array = rowCounts;
      dataset.getColumnMetadata().add('count>0').array = columnCounts;
    }
function ( ) { var rowCounts = new Uint32Array ( nrows ) ; var columnCounts = new Uint32Array ( ncols ) ; for ( var i = 0 ; i < nrows ; i ++ ) { var obj = matrix [ i ] ; if ( obj . values != null ) { // trim to size var values = new Uint16Array ( obj . length ) ; var indices = new Uint32Array ( obj . length ) ; values . set ( obj . values . slice ( 0 , obj . length ) ) ; indices . set ( obj . indices . slice ( 0 , obj . length ) ) ; matrix [ i ] = { values : values , indices : indices } ; rowCounts [ i ] = values . length ; for ( var j = 0 ; j < obj . length ; j ++ ) { columnCounts [ indices [ j ] ] += 1 ; } } } dataset = new morpheus . Dataset ( { rows : nrows , columns : ncols , name : morpheus . Util . getBaseFileName ( morpheus . Util . getFileName ( fileOrUrl ) ) , array : matrix , dataType : dataType , defaultValue : 0 } ) ; dataset . getRowMetadata ( ) . add ( 'count>0' ) . array = rowCounts ; dataset . getColumnMetadata ( ) . add ( 'count>0' ) . array = columnCounts ; }
for each row we store values and indices
for each row we store values and indices