SCM

SCM Repository

[matrix] Diff of /pkg/src/Mutils.h
ViewVC logotype

Diff of /pkg/src/Mutils.h

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

revision 1517, Wed Sep 6 13:34:03 2006 UTC revision 1736, Tue Jan 23 17:09:41 2007 UTC
# Line 46  Line 46 
46  SEXP set_factors(SEXP obj, SEXP val, char *nm);  SEXP set_factors(SEXP obj, SEXP val, char *nm);
47  SEXP dgCMatrix_set_Dim(SEXP x, int nrow);  SEXP dgCMatrix_set_Dim(SEXP x, int nrow);
48    
49  int csc_unsorted_columns(int ncol, const int p[], const int i[]);  /* int csc_unsorted_columns(int ncol, const int p[], const int i[]); */
50  void csc_sort_columns(int ncol, const int p[], int i[], double x[]);  /* void csc_sort_columns(int ncol, const int p[], int i[], double x[]); */
51  SEXP csc_check_column_sorting(SEXP A);  /* SEXP csc_check_column_sorting(SEXP A); */
52  SEXP Matrix_make_named(int TYP, char **names);  SEXP Matrix_make_named(int TYP, char **names);
53  SEXP check_scalar_string(SEXP sP, char *vals, char *nm);  SEXP check_scalar_string(SEXP sP, char *vals, char *nm);
54  double *packed_getDiag(double *dest, SEXP x);  double *packed_getDiag(double *dest, SEXP x);
# Line 79  Line 79 
79  #define PACKED_LENGTH(n)   ((n) * ((n) + 1))/2  #define PACKED_LENGTH(n)   ((n) * ((n) + 1))/2
80    
81  /* duplicate the slot with name given by sym from src to dest */  /* duplicate the slot with name given by sym from src to dest */
82    /* FIXME: is not yet used */
83  #define slot_dup(dest, src, sym)  SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))  #define slot_dup(dest, src, sym)  SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
84    
85    #define slot_nonNull_dup(dest, src, sym)                        \
86        if(GET_SLOT(src, sym) != R_NilValue)                        \
87            SET_SLOT(dest, sym, duplicate(GET_SLOT(src, sym)))
88    
89    /* TODO: Make this faster for the case where dimnames = list(NULL,NULL)
90     *       and hence don't have to be set ! */
91    #define SET_DimNames(dest, src) slot_dup(dest, src, Matrix_DimNamesSym)
92    
93    
94  #define uplo_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_uploSym), 0))  #define uplo_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_uploSym), 0))
95  #define diag_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0))  #define diag_P(_x_) CHAR(STRING_ELT(GET_SLOT(_x_, Matrix_diagSym), 0))
96  #define class_P(_x_) CHAR(asChar(getAttrib(_x_, R_ClassSymbol)))  #define class_P(_x_) CHAR(asChar(getAttrib(_x_, R_ClassSymbol)))
97    
98    /* should also work for "matrix" matrices: */
99    #define Real_KIND(_x_)  (IS_S4_OBJECT(_x_) ? Real_kind(_x_) : \
100                             (isReal(_x_) ? 0 : (isLogical(_x_) ? 1 : -1)))
101    
102    /* requires 'x' slot: */
103    #define Real_kind(_x_)  (isReal(GET_SLOT(_x_, Matrix_xSym)) ? 0 :       \
104                             (isLogical(GET_SLOT(_x_, Matrix_xSym)) ? 1 : -1))
105    
106    
107  /**  /**
108   * Check for valid length of a packed triangular array and return the   * Check for valid length of a packed triangular array and return the
109   * corresponding number of columns   * corresponding number of columns
# Line 157  Line 176 
176    
177  SEXP Matrix_expand_pointers(SEXP pP);  SEXP Matrix_expand_pointers(SEXP pP);
178    
 /* Move these to the lme4 sources */  
 SEXP alloc_dgeMatrix(int m, int n, SEXP rownms, SEXP colnms);  
 SEXP alloc_dpoMatrix(int n, char *uplo, SEXP rownms, SEXP colnms);  
 SEXP alloc_dtrMatrix(int n, char *uplo, char *diag, SEXP rownms, SEXP colnms);  
 SEXP alloc_dsCMatrix(int n, int nz, char *uplo, SEXP rownms, SEXP colnms);  
   
179  SEXP dup_mMatrix_as_dgeMatrix(SEXP A);  SEXP dup_mMatrix_as_dgeMatrix(SEXP A);
180    SEXP dup_mMatrix_as_geMatrix (SEXP A);
181    
182    SEXP new_dgeMatrix(int nrow, int ncol);
183    
184  static R_INLINE SEXP  static R_INLINE SEXP
185  mMatrix_as_dgeMatrix(SEXP A)  mMatrix_as_dgeMatrix(SEXP A)
# Line 171  Line 187 
187      return strcmp(class_P(A), "dgeMatrix") ? dup_mMatrix_as_dgeMatrix(A) : A;      return strcmp(class_P(A), "dgeMatrix") ? dup_mMatrix_as_dgeMatrix(A) : A;
188  }  }
189    
190    static R_INLINE SEXP
191    mMatrix_as_geMatrix(SEXP A)
192    {
193        return strcmp(class_P(A) + 1, "geMatrix") ? dup_mMatrix_as_geMatrix(A) : A;
194    }
195    
196  /**  /**
197   * Return the 0-based index of a string match in a vector of strings   * Return the 0-based index of a string match in a vector of strings
198   * terminated by an empty string.  Returns -1 for no match.   * terminated by an empty string.  Returns -1 for no match.

Legend:
Removed from v.1517  
changed lines
  Added in v.1736

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