Arithmetic operations between two FLQuant objects using the standars operators (`+`, `-`, `*`, `/`, `^`, see Arith) need all dimensions in both objects to match. This requirement is relaxed by using the percent version of those four: `

x %+% y

x %-% y

x %^% y

# S4 method for FLQuant,FLQuant
%*%(x, y)

# S4 method for FLQuant,FLQuant
%/%(e1, e2)

# S4 method for FLQuant,FLQuant
%+%(x, y)

# S4 method for FLQuant,FLQuant
%-%(x, y)

# S4 method for FLQuant,FLQuant
%^%(x, y)

# S4 method for FLPar,FLQuant
%*%(x, y)

# S4 method for FLPar,FLQuant
%/%(e1, e2)

# S4 method for FLPar,FLQuant
%+%(x, y)

# S4 method for FLPar,FLQuant
%-%(x, y)

# S4 method for FLPar,FLQuant
%^%(x, y)

# S4 method for FLQuant,FLPar
%*%(x, y)

# S4 method for FLQuant,FLPar
%/%(e1, e2)

# S4 method for FLQuant,FLPar
%+%(x, y)

# S4 method for FLQuant,FLPar
%-%(x, y)

# S4 method for FLQuant,FLPar
%^%(x, y)

# S4 method for FLPar,FLPar
%*%(x, y)

# S4 method for FLPar,FLPar
%+%(x, y)

# S4 method for FLPar,FLPar
%-%(x, y)

# S4 method for FLPar,FLPar
%/%(e1, e2)

# S4 method for FLPar,FLPar
%^%(x, y)

# S4 method for FLQuants,FLPar
/(e1, e2)

Details

If any of the objects is of length one in a dimensions where the other is longer, the dimensions will be extended and the element-by-element operation then conducted. Dimensions and dimnames of the output will be those of the larger object. See the examples to observe their behaviour.

Please note that this behaviour is present on the Arith methods for FLArray-derived classes but only on the 6th, `iter`, dimension.

The original use of the ` for FLQuant objects, but can be applied to the array inside them, as in the example below.

Methods for operations between an FLQuant and an FLPar object will match dimensions by names of dimnames, regardless of position.

Generic function

x

See also

FLQuant, matmult

Examples

a <- FLQuant(2, dim=c(3,3,2)) b <- FLQuant(3, dim=c(3,3,1)) # This should fail ## Not run: a * b a %*% b
#> An object of class "FLQuant" #> , , unit = 1, season = all, area = unique #> #> year #> quant 1 2 3 #> 1 6 6 6 #> 2 6 6 6 #> 3 6 6 6 #> #> , , unit = 2, season = all, area = unique #> #> year #> quant 1 2 3 #> 1 6 6 6 #> 2 6 6 6 #> 3 6 6 6 #> #> units: NA
a %+% b
#> An object of class "FLQuant" #> , , unit = 1, season = all, area = unique #> #> year #> quant 1 2 3 #> 1 5 5 5 #> 2 5 5 5 #> 3 5 5 5 #> #> , , unit = 2, season = all, area = unique #> #> year #> quant 1 2 3 #> 1 5 5 5 #> 2 5 5 5 #> 3 5 5 5 #> #> units: NA
# To use base's %*% vector product, apply it to a matrix from @.Data b@.Data[,,,,,] %*% 1:3
#> #> quant [,1] #> 1 18 #> 2 18 #> 3 18
# or b[,,drop=TRUE] %*% 1:3
#> #> quant [,1] #> 1 18 #> 2 18 #> 3 18
# FLPar vs. FLQuant works by dimnames' names flp <- FLPar(2, dimnames=list(params='a', year=2000:2005, iter=1)) flq <- FLQuant(3, dimnames=list(year=2000:2005)) flp %*% flq
#> An object of class "FLQuant" #> , , unit = unique, season = all, area = unique #> #> year #> quant 1 2 3 4 5 6 #> all 6 6 6 6 6 6 #> #> units: NA