private double denseTensorInnerProduct ( DenseTensor other ) { double [ ] otherValues = other . values ; int length = values . length ; Preconditions . checkArgument ( otherValues . length == length ) ; double innerProduct = 0.0 ; for ( int i = 0 ; i < length ; i ++ ) { innerProduct += values [ i ] * otherValues [ i ] ; } return innerProduct ; }
Implementation of inner product where both tensors are dense and have the same dimensionality . These properties enable the inner product to be computed extremely quickly by iterating over both dense arrays of values .