26 #if defined (HAVE_CONFIG_H)
50 {
return x == 0 ||
x == 1; }
71 {
return x == 0 ||
x == 1; }
85 char *tmp =
new char [
len+1];
86 tmp = strcpy (tmp, s);
104 int grow_size = 1024;
105 int max_size = grow_size;
107 char *buf =
static_cast<char *
> (
std::malloc (max_size));
109 (*current_liboctave_error_handler) (
"octave_fgets: unable to malloc %d bytes", max_size);
116 if (std::fgets (bufptr, grow_size,
f))
120 if (
len == grow_size - 1)
122 int tmp = bufptr - buf + grow_size - 1;
124 max_size += grow_size;
125 auto tmpbuf =
static_cast<char *
> (std::realloc (buf, max_size));
129 (*current_liboctave_error_handler) (
"octave_fgets: unable to realloc %d bytes", max_size);
134 if (*(bufptr-1) ==
'\n')
140 else if (bufptr[
len-1] !=
'\n')
142 bufptr[
len++] =
'\n';
192 template <
typename T>
203 if (c1 ==
'n' || c1 ==
'N')
206 if (c2 ==
'f' || c2 ==
'F')
207 val = std::numeric_limits<T>::infinity ();
209 is.setstate (std::ios::failbit);
212 is.setstate (std::ios::failbit);
219 if (c1 ==
'a' || c1 ==
'A')
222 if (c2 ==
'n' || c2 ==
'N')
223 val = std::numeric_limits<T>::quiet_NaN ();
226 val = octave::numeric_limits<T>::NA ();
227 if (c2 != std::istream::traits_type::eof ())
230 is.clear (is.rdstate () & ~std::ios::failbit);
234 is.setstate (std::ios::failbit);
239 (*current_liboctave_error_handler)
240 (
"read_inf_nan_na: invalid character '%c'", c0);
248 template <
typename T>
256 std::streampos pos = is.tellg ();
275 if (c2 ==
'i' || c2 ==
'I' || c2 ==
'n' || c2 ==
'N')
276 val = read_inf_nan_na<T> (is, c2);
283 if (neg && ! is.fail ())
290 val = read_inf_nan_na<T> (is, c1);
299 std::ios::iostate status = is.rdstate ();
300 if (status & std::ios::failbit)
306 val = -std::numeric_limits<T>::infinity ();
308 val = std::numeric_limits<T>::infinity ();
309 is.clear (status & ~std::ios::failbit);
316 is.setstate (status);
323 template <
typename T>
330 std::complex<T> cx = 0.0;
339 re = octave_read_value<T> (is);
344 im = octave_read_value<T> (is);
348 cx = std::complex<T> (re, im);
350 is.setstate (std::ios::failbit);
355 is.setstate (std::ios::failbit);
360 cx = octave_read_value<double> (is);
368 return octave_read_fp_value<double> (is);
373 return octave_read_cx_fp_value<double> (is);
378 return octave_read_fp_value<float> (is);
383 return octave_read_cx_fp_value<float> (is);
394 os << (
d < 0 ?
"-Inf" :
"Inf");
417 os << (
d < 0 ?
"-Inf" :
"Inf");
charNDArray max(char d, const charNDArray &m)
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
std::complex< T > octave_read_cx_fp_value(std::istream &is)
bool xtoo_large_for_float(double x)
void octave_write_double(std::ostream &os, double d)
std::string octave_fgetl(FILE *f)
void octave_write_complex(std::ostream &os, const Complex &c)
bool xis_one_or_zero(double x)
void octave_write_float_complex(std::ostream &os, const FloatComplex &c)
double octave_read_fp_value(std::istream &is)
void octave_write_float(std::ostream &os, float d)
char * strsave(const char *s)
bool xis_int_or_inf_or_nan(double x)
std::string octave_fgets(FILE *f)
T read_inf_nan_na(std::istream &is, char c0)
OCTAVE_API double octave_read_value(std::istream &is)
std::complex< double > Complex
std::complex< float > FloatComplex
T::size_type strlen(const typename T::value_type *str)
octave_value::octave_value(const Array< char > &chm, char type) return retval