SCM

SCM Repository

[matrix] Diff of /pkg/Matrix/src/sparseQR.c
ViewVC logotype

Diff of /pkg/Matrix/src/sparseQR.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3213, Tue Apr 18 20:14:20 2017 UTC revision 3221, Mon Aug 7 20:31:15 2017 UTC
# Line 72  Line 72 
72              UNPROTECT(1);              UNPROTECT(1);
73          }          }
74      }      }
75  }  } // sparseQR_Qmult
76    
77    
78  /**  /**
# Line 147  Line 147 
147  {  {
148      SEXP qslot = GET_SLOT(qr, install("q")), R_ = GET_SLOT(qr, install("R"));      SEXP qslot = GET_SLOT(qr, install("q")), R_ = GET_SLOT(qr, install("R"));
149      CSP R = AS_CSP__(R_);      CSP R = AS_CSP__(R_);
150        // FIXME: check  n_R, M (= R->m)   vs  n, m
151      INIT_sparseQR_(FALSE); // (y, ...)      int *q = INTEGER(qslot), lq = LENGTH(qslot), n_R = R->n; // = ncol(R)
152      // ans := R^{-1} Q' y ==>  rownames(ans) := rownames(R^{-1}) = colnames(R) :      INIT_sparseQR_(FALSE); // <- FALSE: no dimnames from V
153        // ans := R^{-1} Q' y ==>  rownames(ans) := rownames(R^{-1}) = colnames(R)
154      dnms = duplicate(GET_SLOT(R_, Matrix_DimNamesSym));      dnms = duplicate(GET_SLOT(R_, Matrix_DimNamesSym));
155        if(!isNull(VECTOR_ELT(dnms, 1))) { // need to correctly *permute* the colnames
156            SEXP cns = PROTECT(duplicate(VECTOR_ELT(dnms, 1)));
157            // *back* permute colnames from 'qslot' :
158            for(int j=0; j < lq; j++)
159                SET_STRING_ELT(VECTOR_ELT(dnms, 1), q[j], STRING_ELT(cns, j));
160            UNPROTECT(1);
161        }
162    
163        // rownames(ans) := colnames(ans)
164      SET_VECTOR_ELT(dnms, 0, VECTOR_ELT(dnms, 1));      SET_VECTOR_ELT(dnms, 0, VECTOR_ELT(dnms, 1));
165    
166      /* apply row permutation and multiply by Q' */      /* apply row permutation and multiply by Q' */
# Line 158  Line 168 
168                     INTEGER(GET_SLOT(qr, Matrix_pSym)), /* trans = */ TRUE,                     INTEGER(GET_SLOT(qr, Matrix_pSym)), /* trans = */ TRUE,
169                     ans);                     ans);
170    
171      double *ax = REAL(GET_SLOT(ans, Matrix_xSym));      double *ax = REAL(GET_SLOT(ans, Matrix_xSym)), *x;
   // FIXME: check  n_R, M (= R->m)   vs  n, m  
     int *q = INTEGER(qslot), lq = LENGTH(qslot), n_R = R->n; // = ncol(R)  
     double *x;  
172      if(lq) { C_or_Alloca_TO(x, M, double); }      if(lq) { C_or_Alloca_TO(x, M, double); }
173      for (int j = 0; j < n; j++) {      for (int j = 0; j < n; j++) {
174          double *aj = ax + j * M;          double *aj = ax + j * M;

Legend:
Removed from v.3213  
changed lines
  Added in v.3221

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge