private void addPreviewMeasurementsToSum ( List < double [ ] > measurementsSum , Preview preview , int numEntriesPerPreview ) { List < double [ ] > previewMeasurements = preview . getData ( ) ; // add values for each measurement in each entry for ( int entryIdx = 0 ; entryIdx < numEntriesPerPreview ; entryIdx ++ ) { double [ ] previewEntry = previewMeasurements . get ( entryIdx ) ; double [ ] sumEntry ; if ( measurementsSum . size ( ) > entryIdx ) { sumEntry = measurementsSum . get ( entryIdx ) ; } else { // initialize sum entry sumEntry = new double [ previewEntry . length ] ; measurementsSum . add ( sumEntry ) ; } // first measurement is used for indexing // -> simply copy from first preview if ( sumEntry [ 0 ] == 0.0 ) { sumEntry [ 0 ] = previewEntry [ 0 ] ; } // add measurements of current entry for ( int measure = 1 ; measure < sumEntry . length ; measure ++ ) { sumEntry [ measure ] += previewEntry [ measure ] ; } } }
Add measurements from the given Preview to the overall sum .