tropicalsparse.add: Addition With or Without Storage Techniques

Description Usage Arguments Details Value See Also Examples

Description

tropicalsparse.add function adds the provided inputs in Tropical Algebra based on type of Tropical Algebra.

Usage

1
tropicalsparse.add(A, B, store = NULL, algebraType)

Arguments

A

is matrix or vector.

B

is matrix or vector.

store

is storage technique.

algebraType

is string input that can be minplus or maxplus.

Details

The compulsory inputs of the function tropicalsparse.add are A, B and algebraType while the remaining input is optional that is store. The inputs A and B can be matrix/matrix, matrix/vector, vector/matrix and vector/vector otherwise the function generates an error. For A and B, the order of the input does not matter. It can be in any of the following way: the first input of the function is matrix and second input is a vector. Similarly, vise versa. store can be coo, csc and csr for applying following storage techniques respectively: Coordinate-Wise, Compressed Sparse Row, Compressed Sparse Column. This input is case sensitive. If the store input is other than the specified storage techniques then the function generates an error. The input algebraType is used to specify type of Tropical Algebra. This can be minplus or maxplus. For more details about algebraType, see detail section of check.infinityM or check.infinityV. tropicalsparse.storage function is used to apply storage technique depends upon the input given. If store input is not specified then the functionality will be performed without using any storage technique.

Value

Addition of A and B in Tropical Algebra.

See Also

tropicalsparse.mul, tropicalsparse.storage

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
a <- matrix(data = c(2, Inf, Inf, 0, Inf, Inf, Inf, 10, Inf),
nrow = 3, ncol = 3, byrow = TRUE)

b <- matrix(data = c(Inf, Inf, 4, Inf, -0.3, Inf, Inf, 2, Inf),
nrow = 3, ncol = 3, byrow = TRUE)

tropicalsparse.add(a, b, 'csr', 'minplus')

#     [,1] [,2]  [,3]
# [1,]    2  Inf    4
# [2,]    0 -0.3  Inf
# [3,]  Inf  2.0  Inf

# also

a <- matrix(data = c(5, -Inf, -Inf, -Inf, -Inf, -Inf, -Inf, 10, 2),
nrow = 3, ncol = 3, byrow = TRUE)

b <- matrix(data = c(-Inf, -Inf, 3, -Inf, -0.5, -Inf, 1.1, -Inf, -Inf),
nrow = 3, ncol = 3, byrow = TRUE)

tropicalsparse.add(a, b, 'coo', 'maxplus')

#      [,1] [,2] [,3]
# [1,]  5.0 -Inf    3
# [2,] -Inf -0.5 -Inf
# [3,]  1.1 10.0    2

# also

a <- matrix(data = c(2, Inf, Inf, 0, Inf, Inf, Inf, 2, Inf),
nrow = 3, ncol = 3, byrow = TRUE)

b <- c(Inf, 0, 10)

tropicalsparse.add(a, b, algebraType = 'minplus')

#      [,1] [,2] [,3]
# [1,]    2  Inf  Inf
# [2,]    0    0    0
# [3,]   10    2   10

tropicalSparse documentation built on May 1, 2019, 8:02 p.m.