private void simpleIncrement ( TensorBase other , double multiplier ) { Preconditions . checkArgument ( Arrays . equals ( other . getDimensionNumbers ( ) , getDimensionNumbers ( ) ) ) ; if ( other instanceof DenseTensorBase ) { double [ ] otherTensorValues = ( ( DenseTensorBase ) other ) . values ; Preconditions . checkArgument ( otherTensorValues . length == values . length ) ; int length = values . length ; for ( int i = 0 ; i < length ; i ++ ) { values [ i ] += otherTensorValues [ i ] * multiplier ; } } else { int otherSize = other . size ( ) ; for ( int i = 0 ; i < otherSize ; i ++ ) { long keyNum = other . indexToKeyNum ( i ) ; double value = other . getByIndex ( i ) ; values [ keyNumToIndex ( keyNum ) ] += value * multiplier ; } } }
Increment algorithm for the case where both tensors have the same set of dimensions .