Skip to contents

Log-Sum-Exp reduction for LazyTensor objects.

Usage

logsumexp(x, index, weight = NULL)

logsumexp_reduction(x, index, weight = NULL)

Arguments

x

a LazyTensor or a ComplexLazyTensor.

index

a character corresponding to the reduction dimension that should be either "i" or "j" to specify whether if the reduction is indexed by "i" or "j".

weight

an optional object (LazyTensor or ComplexLazyTensor) that specifies scalar or vector-valued weights. NULL by default and not used.

Value

a matrix corresponding to the Log-Sum-Exp reduction.

Details

If x is a LazyTensor or a ComplexLazyTensor, logsumexp(x, index, weight) will:

  • if index = "i", return the Log-Sum-Exp reduction of x over the i indexes;

  • if index = "j", return the Log-Sum-Exp reduction of x over the j indexes.

Note: Run browseVignettes("rkeops") to access the vignettes and find details about this function in the "RKeOps LazyTensor" vignette, at section "Reductions".

Author

Chloe Serre-Combe, Amelie Vernay

Examples

if (FALSE) {
x <- matrix(runif(150 * 3), 150, 3) 
x_i <- LazyTensor(x, index = 'i') 
y <- matrix(runif(100 * 3), 100, 3)
y_j <- LazyTensor(y, index = 'j')
w <- matrix(runif(100 * 3), 100, 3) # weight LazyTensor
w_j <- LazyTensor(w, index = 'j')

S_ij = sum((x_i - y_j)^2)                                           
logsumexp_xw <- logsumexp(S_ij, 'i', w_j) # logsumexp reduction 
                                          # over the 'i' indices
                                         
logsumexp_x <- logsumexp(S_ij, 'i')      # logsumexp reduction without
                                         # weight over the 'i' indices
}
if (FALSE) {
x <- matrix(runif(150 * 3), 150, 3) 
x_i <- LazyTensor(x, index = 'i') 
y <- matrix(runif(100 * 3), 100, 3)
y_j <- LazyTensor(y, index = 'j')
w <- matrix(runif(150 * 3), 150, 3) # weight LazyTensor
w_j <- LazyTensor(y, index = 'j')

S_ij = sum( (x_i - y_j)^2 )                                           
logsumexp_xw <- logsumexp_reduction(S_ij, 'i', w_j) # logsumexp reduction 
                                                    # over the 'i' indices
                                         
logsumexp_x <- logsumexp_reduction(S_ij, 'i')  # logsumexp reduction without
                                               # weight over the 'i' indices
}