Skip to content

Commit ac7fe93

Browse files
committed
Fix NAMESPACE and doc for R CMD Check
1 parent e108962 commit ac7fe93

5 files changed

Lines changed: 142 additions & 0 deletions

File tree

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
S3method(svds,sparseLRMatrix)
44
export(sparseLRMatrix)
55
export(svds)
6+
exportMethods(dim)
67
import(Matrix)
8+
import(methods)
79
importFrom(RSpectra,svds)

R/object.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#' @import Matrix
2+
#' @import methods
23
NULL
34

45
#' Sparse plus low rank matrix
@@ -14,6 +15,26 @@ NULL
1415
#' @slot U Matrix.
1516
#' @slot V Matrix.
1617
#'
18+
#' @examples
19+
#'
20+
#' set.seed(528491)
21+
#'
22+
#' n <- 50
23+
#' m <- 40
24+
#' k <- 3
25+
#'
26+
#' A <- rsparsematrix(n, m, 0.1)
27+
#'
28+
#' U <- Matrix(rnorm(n * k), nrow = n, ncol = k)
29+
#' V <- Matrix(rnorm(m * k), nrow = m, ncol = k)
30+
#'
31+
#' # construct the matrix, which represents A + U %*% t(V)
32+
#' X <- sparseLRMatrix(sparse = A, U = U, V = V)
33+
#'
34+
#' dim(X)
35+
#'
36+
#' s <- svds(X, 5) # efficient
37+
#'
1738
setClass(
1839
Class = "sparseLRMatrix",
1940
# contains = "Matrix",
@@ -29,7 +50,17 @@ setClass(
2950
)
3051
)
3152

53+
#' Create a sparse plus low rank matrix
54+
#'
55+
#' @param sparse sparseMatrix.
56+
#' @param U Matrix.
57+
#' @param V Matrix.
58+
#'
59+
#' @return A [sparseLRMatrix-class] S4 object.
60+
#'
61+
#' @inherit sparseLRMatrix-class examples
3262
#' @export
63+
#'
3364
sparseLRMatrix <- function(sparse, U, V) {
3465
methods::new(
3566
Class = "sparseLRMatrix",
@@ -55,6 +86,14 @@ setValidity("sparseLRMatrix", function(object) {
5586
TRUE
5687
})
5788

89+
#' Check the dimension of a sparseLRMatrix
90+
#'
91+
#' @param x A [sparseLRMatrix-class] object.
92+
#'
93+
#' @return Dimension of `x`.
94+
#' @export
95+
#' @inherit sparseLRMatrix-class examples
96+
#'
5897
setMethod("dim", "sparseLRMatrix", function(x) dim(x@sparse))
5998

6099
Ax <- function(x, A) {

man/dim-sparseLRMatrix-method.Rd

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sparseLRMatrix-class.Rd

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sparseLRMatrix.Rd

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)