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 1555, Wed Sep 13 14:47:28 2006 UTC revision 1736, Tue Jan 23 17:09:41 2007 UTC
# 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 :       \  #define Real_kind(_x_)  (isReal(GET_SLOT(_x_, Matrix_xSym)) ? 0 :       \
104                           (isLogical(GET_SLOT(_x_, Matrix_xSym)) ? 1 :   \                           (isLogical(GET_SLOT(_x_, Matrix_xSym)) ? 1 : -1))
                           -1))  
105    
106    
107  /**  /**
# Line 163  Line 177 
177  SEXP Matrix_expand_pointers(SEXP pP);  SEXP Matrix_expand_pointers(SEXP pP);
178    
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 170  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.1555  
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