13 #if defined(__TURBOC__)
31 const int& line_length);
50 cerr <<
"Error[" << __FILE__ <<
':' << __LINE__
51 <<
"]: column should be positive number.\n";
54 ifstream infile(filename);
57 cerr <<
"Error opening file " << filename <<
" in dmatrix constructor "
58 <<
"dmatrix::dmatrix(char * filename)\n";
74 cerr <<
" MAX_NUMBER_ROWS exceeded in "
75 " dmatrix::dmatrix(char * filename)\n";
81 while( sscanf(line,
"%s",field))
84 size_t length = strlen(line);
85 while (index < length)
89 while (c !=
' ' && c !=
',')
97 cerr <<
" MAX_NUMBER_COLUMNS exceeded in "
98 " dvector::dvector(char* filename)\n";
101 while (c ==
' ' || c ==
',')
104 if (index >= length)
break;
112 cerr <<
"Error -- not enough columns in line " << i
113 <<
"\n in dvector::dvector(char * filename, const int& column) "
122 cerr <<
"Error in dvector constructor There doesn't seem to be any data\n"
123 <<
"in file: " << filename
124 <<
" called in dvector::dvector(char * filename,const const& column)\n";
128 infile.seekg(0,ios::beg);
133 if ((
v =
new double[(
size_t)
size()]) == 0)
135 cerr <<
" Error trying to allocate memory for dvector\n";
138 #if defined(THREAD_SAFE)
139 if ( (
shape=
new ts_vector_shapex(1,nr,
v)) == NULL)
144 cerr <<
"Error trying to allocate memory for dvector\n";
149 cout <<
"Created a ncopies with address " << _farptr_tolong(&(
shape->
ncopies))
151 cout <<
"Created a dvector with address " << _farptr_tolong(
v) <<
"\n";
152 if (
sizeof(
int)==
sizeof(
char*))
154 #if (defined(__GNUC__) && defined(__i386)) || (defined(_MSC_VER) && defined(_M_IX86))
155 if ( (
unsigned)
v <
indexmin() *
sizeof(
double) )
157 if ((intptr_t)
v <
indexmin() *
sizeof(
double))
180 while( sscanf(line,
"%s",field))
183 size_t length = strlen(line);
184 while (index < length)
188 char c = line[index];
189 while (c !=
' ' && c !=
',')
191 field[field_index] = c;
197 field[field_index] =
'\0';
202 elem(i)=strtod(field,&err_ptr);
204 if (isalpha((
unsigned char)err_ptr[0]))
206 cerr <<
"Error decoding field " << filename
207 <<
" in dvector::dvector(char* filename) " <<
"\n";
208 cerr <<
"Error occurred in line " << i <<
" at field " << j <<
"\n";
209 cerr <<
"Offending characters start with "
213 << err_ptr[3] <<
"\n";
216 if (
elem(j) == HUGE_VAL ||
elem(j) == -HUGE_VAL)
218 cerr <<
"Overflow Error decoding field " << filename
219 <<
" in dvector::dvector(char * filename) " <<
"\n";
220 cerr <<
"Error occurred in line " << i <<
" at field " << j <<
"\n";
221 cerr <<
"Offending characters start with "
225 << err_ptr[3] <<
"\n";
231 cerr <<
" MAX_NUMBER_COLUMNS exceeded in "
232 " dmatrix::dmatrix(char * filename)\n";
235 while (c ==
' ' || c ==
',')
238 if (index >= length)
break;
double * v
pointer to the data
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
const int MAX_NUMBER_ROWS
dvector()
Construct a dvector without allocating memory.
const int MAX_LINE_LENGTH
int indexmin() const
Get minimum valid index.
const int MAX_FIELD_LENGTH
void denormalize_ptr(void *ptr, unsigned int byte_offset)
Description not yet available.
int get_non_blank_line(const ifstream &infile, char *&line, const int &line_length)
Description not yet available.
Array of integers(int) with indexes from index_min to indexmax.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
unsigned int ncopies
Copy counter to enable shallow copies.
unsigned int size() const
Get number of elements in array.
int index_min
minimum valid subscript
Holds "shape" information for vector objects.
vector_shapex * shape
pointer to vector "shape"
dvector column(const dmatrix &matrix, int j)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int index_max
maximum valid subscript
const int MAX_NUMBER_COLUMNS
size_t length(const adstring &t)
Returns the size of adstr.