CXXR (C++ R)
Utils.h
1 /*CXXR $Id: Utils.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  * Copyright (C) 1998-2005 The R Core Team
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU Lesser General Public License as published by
23  * the Free Software Foundation; either version 2.1 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU Lesser General Public License
32  * along with this program; if not, a copy is available at
33  * http://www.r-project.org/Licenses/
34  *
35  *
36  * Generally useful UTILITIES *NOT* relying on R internals (from Defn.h)
37  */
38 
39 #ifndef R_EXT_UTILS_H_
40 #define R_EXT_UTILS_H_
41 
42 #include <R_ext/Boolean.h>
43 #include <R_ext/Complex.h>
44 
45 #define revsort Rf_revsort
46 #define iPsort Rf_iPsort
47 #define rPsort Rf_rPsort
48 #define cPsort Rf_cPsort
49 #define IndexWidth Rf_IndexWidth
50 #define setIVector Rf_setIVector
51 #define setRVector Rf_setRVector
52 #define StringFalse Rf_StringFalse
53 #define StringTrue Rf_StringTrue
54 #define isBlankString Rf_isBlankString
55 #define hsv2rgb Rf_hsv2rgb
56 #define rgb2hsv Rf_rgb2hsv
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /* ../../main/sort.c : */
63 void R_isort(int*, int);
64 void R_rsort(double*, int);
65 void R_csort(Rcomplex*, int);
66 void rsort_with_index(double *, int *, int);
67 void revsort(double*, int*, int);/* reverse; sort i[] alongside */
68 void iPsort(int*, int, int);
69 void rPsort(double*, int, int);
70 void cPsort(Rcomplex*, int, int);
71 
72 /* ../../main/qsort.c : */
73 void R_qsort (double *v, int i, int j);
74 void R_qsort_I (double *v, int *I, int i, int j);
75 void R_qsort_int (int *iv, int i, int j);
76 void R_qsort_int_I(int *iv, int *I, int i, int j);
77 #ifdef R_RS_H
78 void F77_NAME(qsort4)(double *v, int *indx, int *ii, int *jj);
79 void F77_NAME(qsort3)(double *v, int *ii, int *jj);
80 #endif
81 
82 /* ../../main/printutils.c : */
83 int IndexWidth(int);
84 /* ../../main/util.c and others : */
85 const char *R_ExpandFileName(const char *);
86 void setIVector(int*, int, int);
87 void setRVector(double*, int, double);
88 Rboolean StringFalse(const char *);
89 Rboolean StringTrue(const char *);
90 Rboolean isBlankString(const char *);
91 
92 /* These two are guaranteed to use '.' as the decimal point,
93  and to accept "NA".
94  */
95 double R_atof(const char *str);
96 double R_strtod(const char *c, char **end);
97 
98 char *R_tmpnam(const char *prefix, const char *tempdir);
99 char *R_tmpnam2(const char *prefix, const char *tempdir, const char *fileext);
100 
101 void hsv2rgb(double h, double s, double v,
102  double *r, double *g, double *b);
103 void rgb2hsv(double r, double g, double b,
104  double *h, double *s, double *v);
105 
106 void R_CheckUserInterrupt(void);
107 void R_CheckStack(void);
108 
109 
110 /* ../../appl/interv.c: also in Applic.h */
111 int findInterval(double *xt, int n, double x,
112  Rboolean rightmost_closed, Rboolean all_inside, int ilo,
113  int *mflag);
114 #ifdef R_RS_H
115 int F77_SUB(interv)(double *xt, int *n, double *x,
116  Rboolean *rightmost_closed, Rboolean *all_inside,
117  int *ilo, int *mflag);
118 #endif
119 void find_interv_vec(double *xt, int *n, double *x, int *nx,
120  int *rightmost_closed, int *all_inside, int *indx);
121 
122 /* ../../appl/maxcol.c: also in Applic.h */
123 void R_max_col(double *matrix, int *nr, int *nc, int *maxes, int *ties_meth);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* R_EXT_UTILS_H_ */