# all.equal-methods: Matrix Package Methods for Function all.equal() In Matrix: Sparse and Dense Matrix Classes and Methods

## Description

Methods for function `all.equal()` (from R package base) are defined for all `Matrix` classes.

## Methods

target = "Matrix", current = "Matrix"

\

target = "ANY", current = "Matrix"

\

target = "Matrix", current = "ANY"

these three methods are simply using `all.equal.numeric` directly and work via `as.vector()`.

There are more methods, notably also for `"sparseVector"`'s, see `showMethods("all.equal")`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10``` ```showMethods("all.equal") (A <- spMatrix(3,3, i= c(1:3,2:1), j=c(3:1,1:2), x = 1:5)) ex <- expand(lu. <- lu(A)) stopifnot( all.equal(as(A[lu.@p + 1L, lu.@q + 1L], "CsparseMatrix"), lu.@L %*% lu.@U), with(ex, all.equal(as(P %*% A %*% Q, "CsparseMatrix"), L %*% U)), with(ex, all.equal(as(A, "CsparseMatrix"), t(P) %*% L %*% U %*% t(Q)))) ```

### Example output

```Function: all.equal (package base)
target="abIndex", current="abIndex"
target="abIndex", current="numLike"
target="ANY", current="ANY"
target="ANY", current="Matrix"
target="ANY", current="sparseMatrix"
target="ANY", current="sparseVector"
target="Matrix", current="ANY"
target="Matrix", current="Matrix"
target="numLike", current="abIndex"
target="sparseMatrix", current="ANY"
target="sparseMatrix", current="sparseMatrix"
target="sparseMatrix", current="sparseVector"
target="sparseVector", current="ANY"
target="sparseVector", current="sparseMatrix"
target="sparseVector", current="sparseVector"

3 x 3 sparse Matrix of class "dgTMatrix"

[1,] . 5 1
[2,] 4 2 .
[3,] 3 . .
```

Matrix documentation built on June 11, 2021, 3 p.m.