Comments (9)
Well, eigs_sym only uses a triangle, right? so you could just do this, right?
##' @rdname eigs
##' @export
eigs.dsCMatrix <- function(A, k, which = "LM", opts = list(), ...)
{
if (! which %in% c("LM", "SM", "LR", "SR"))
stop('Symmetric matrices can only support `which %in% c("LM", "SM", "LR", "SR")`')
if (which == "LR") which <- "LA"
if (which == "SR") which <- "SA"
# I think you can just use it as a dgCMatrix without adding a mattype here
eigs_real_sym(A, nrow(A), k, which, sigma, opts, mattype = "sym_dgCMatrix",
extra_args = list(use_lower = A@uplo == "L"))
}
Also you are more than welcome to contribute. π
With pleasure! If above code is about correct, Iβll happily send a PR.
from rspectra.
I would do the following:
- Check if you can somehow coerce a
dgCMatrix
to adsCMatrix
while setting theuplo
slot and not copying the data - Check if that works if more than that triangle is filled in the
dgCmatrix
- Change the internal names
sym_dgCMatrix
βdsCMatrix
and thelower
parameter to use theuplo
slot instead - change the R methods so that
eigs.dgCMatrix
delegates toeigs_sym.dsCMatrix
ifisSymmetric(A)
and so on
from rspectra.
Yeah, adding new matrix classes should be a relatively easy task. However, the downside for these two is that they do not have a counterpart in the Eigen library. It may take some effort to implement all the matrix operations, but I'll gradually add them if I get some time. Also you are more than welcome to contribute. π
from rspectra.
The R code is good. What I mean is that the C++ part needs to correctly handle the dsCMatrix
object, whose internal structure may be different from dgCMatrix
.
from rspectra.
You could always use the function interface, right?
library(Matrix)
mat <- sparseMatrix(i = 1:2, j = c(2, 2), x = 1:2, dims = c(3, 3))
(mat2 <- forceSymmetric(mat))
RSpectra::eigs_sym(mat2, k = 1) # NOK
RSpectra::eigs_sym(function(x, args) as.vector(mat2 %*% x),
k = 1, n = nrow(mat2)) # OK
Would this be slower to do it like this?
from rspectra.
@yixuan look at the comment in the R code: I think itβs the exact same thing except for the uplo
property and the fact that only a triangle is specified. Which matches exactly your usage of sym_dgCMatrix
. (I think you could just rename that to dsCMatrix
)
@privefl as said: since I think that dsCMatrix
is exactly what @yixuan calls sym_dgCMatrix
(with an added uplo
attribute), itβs just much more elegant to directly use that.
from rspectra.
Great. I'll take a look later.
from rspectra.
I've checked the structure of dsCMatrix
and can confirm that it is compatible with dgCMatrix
. So, yes, go ahead and submit a PR. π
from rspectra.
Thanks for starting the PR, this will be very useful for a project I'm currently working on!
from rspectra.
Related Issues (20)
- Installation error on Ubuntu 18.04 HOT 5
- svds in version 0.13-1 vs 0.12-0 HOT 1
- Ubuntu 16.04 Intallation HOT 1
- Installation error on Ubuntu HOT 3
- Determinism HOT 6
- Unable to install dev version HOT 5
- how to control the cores used by svds HOT 2
- Unstable selection of eigenvalues and eigenvectors? HOT 5
- Error: TridiagEigen: eigen decomposition failed
- compilation warnings on ubuntu with gcc
- eigenvalues are incorrect with opts = list(center=TRUE scale=TRUE) HOT 4
- Choose the number of components dynamically
- Function interface for svds HOT 4
- eigs and eigs_sym have trouble converging for which = "SA" HOT 5
- generalized eigenvalues HOT 3
- Warm start in svds() HOT 12
- eigs_sym has negative eigenvalue HOT 12
- Installation error Ubuntu 16.04 HOT 2
- Error when installing: "internal compiler error: in predicate_mem_writes" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspectra.