Re: [R] writing spdiags function for R

2013-08-30 Thread moreno
I am posting here the brilliant solutions, gently provided by Prof JC Nash , to me; so that people struggling in the future with the same issue can find a way through. FYI, compared to the original Matlab implementation: 1) "it does not handle the case with more than one input, and 2) (m > n)

Re: [R] writing spdiags function for R

2013-08-26 Thread moreno
Dear R-list, l have been working on a translation of a matlab library into R, it took me a while but I am almost there to submit it to CRAN...however, for this library to be computationally competitive I need to solve an issue with the home-made R version of the spdiags.m function (an old issue co

Re: [R] writing spdiags function for R

2012-04-18 Thread Moreno I. Coco
Hi Ben, A couple of quick comments: the semicolons at the end of each line are unnecessary (they're harmless, but considered bad style -- most common in code of C and MATLAB coders yes, I know, just forgot to clean it up after translating :) You don't need to source("getband.R") inside

Re: [R] writing spdiags function for R

2012-04-16 Thread Ben Bolker
On 12-04-16 09:32 PM, Moreno I. Coco wrote: > Hi Ben, > > thank you soo much:) your code worked, and we > managed to halven computing time. > I am copying below the final version of the function, > if anybody is willing to use/improve it. > > thanks again, > > Moreno A couple of quick comment

Re: [R] writing spdiags function for R

2012-04-16 Thread Moreno I. Coco
Hi Ben, thank you soo much:) your code worked, and we managed to halven computing time. I am copying below the final version of the function, if anybody is willing to use/improve it. thanks again, Moreno ### spdiags = function(A){ re

Re: [R] writing spdiags function for R

2012-04-13 Thread Ben Bolker
Ben Bolker gmail.com> writes: > > I'm not quite sure how to do it, but I think you should look > at the ?band function in Matrix. In combination with diag() of a > suitably truncated matrix, you should be able to extract bands > of sparse matrices efficiently ... > getband <- function(A,k

Re: [R] writing spdiags function for R

2012-04-13 Thread Ben Bolker
Moreno I. Coco sms.ed.ac.uk> writes: [snip snip snip] > > So, I have written my own spdiags function (below); following > also a suggestion in an old, and perhaps unique post, about > this issue. > > It works only for square matrices (that's my need), however I > have a couple of issues, mai

[R] writing spdiags function for R

2012-04-12 Thread Moreno I. Coco
Dear R-list, I am in the process of translating a long function written in Matlab into R (mainly because I am a big of fan of R, and folks will not have to pay to use it :). In the translation of this function I got stack because they use spdiags, which, as far as I can tell it is not available i