Skip to contents
library(saferMatrix)


Datasets

mat1 <- matrix(c(0,0,0,0,0,0,0,0,0), ncol = 3)
mat2 <- matrix(c(1,1,1,2,Inf,5,9,8,9), ncol = 3)
mat3 <- matrix(c(1,1,1,2,NA,5,9,8,9), ncol = 3)
mat4 <- matrix(c(1,2), ncol = 1)
mat5 <- matrix(0, ncol = 1)


Datasets info

mat1
>      [,1] [,2] [,3]
> [1,]    0    0    0
> [2,]    0    0    0
> [3,]    0    0    0
mat2
>      [,1] [,2] [,3]
> [1,]    1    2    9
> [2,]    1  Inf    8
> [3,]    1    5    9
mat3
>      [,1] [,2] [,3]
> [1,]    1    2    9
> [2,]    1   NA    8
> [3,]    1    5    9
mat4
>      [,1]
> [1,]    1
> [2,]    2
mat5
>      [,1]
> [1,]    0


All the arguments

mat_inv(mat = mat1) # use the trick
>      [,1] [,2] [,3]
> [1,]    0    0    0
> [2,]    0    0    0
> [3,]    0    0    0


Error examples

# examples with errors because of Inf and NA
mat_inv(mat = mat2)
> Error: 
> 
> ================
> 
> ERROR IN mat_inv() OF THE saferMatrix PACKAGE
> mat ARGUMENT MUST BE A MATRIX WITHOUT Inf, -Inf OR NA
> 
> ================
mat_inv(mat = mat3)
> Error: 
> 
> ================
> 
> ERROR IN mat_inv()
> THE mat OBJECT CONTAINS NA WHILE NOT AUTHORIZED
> 
> ================

# example with error because not a square matrix
mat_inv(mat = mat4)
> Error: 
> 
> ================
> 
> ERROR IN mat_inv() OF THE saferMatrix PACKAGE
> mat ARGUMENT MUST BE A SQUARE MATRIX
> 
> ================

# example with error because cannot be a square matrix made of a single case of 0
mat_inv(mat = mat5) 
> Error: 
> 
> ================
> 
> ERROR IN mat_inv() OF THE saferMatrix PACKAGE
> mat ARGUMENT CANNOT BE A SQUARE MATRIX MADE OF A SINGLE CASE OF 0
> 
> ================