Mercurial > hg > octave-nkf
annotate liboctave/lo-utils.h @ 11521:00fe5069b70e
update bootstrap scripts from gnulib sources
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 02:58:24 -0500 |
parents | e4e82740e9cd |
children | fd0a3ac60b0e |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 John W. Eaton |
1967 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1967 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1967 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_liboctave_utils_h) | |
25 #define octave_liboctave_utils_h 1 | |
26 | |
2926 | 27 #include <cstdio> |
28 | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
29 #include <iostream> |
2926 | 30 #include <string> |
31 | |
11512
e4e82740e9cd
prototype fixes for C language files
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
32 #include "lo-cutils.h" |
4130 | 33 #include "oct-cmplx.h" |
34 | |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
35 extern OCTAVE_API bool xis_int_or_inf_or_nan (double x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
36 extern OCTAVE_API bool xis_one_or_zero (double x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
37 extern OCTAVE_API bool xis_zero (double x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
38 extern OCTAVE_API bool xtoo_large_for_float (double x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
39 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
40 extern OCTAVE_API bool xis_int_or_inf_or_nan (float x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
41 extern OCTAVE_API bool xis_one_or_zero (float x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
42 extern OCTAVE_API bool xis_zero (float x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
43 extern OCTAVE_API bool xtoo_large_for_float (float x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
11006
diff
changeset
|
44 |
6108 | 45 extern OCTAVE_API char *strsave (const char *); |
2926 | 46 |
10180 | 47 extern OCTAVE_API void |
48 octave_putenv (const std::string&, const std::string&); | |
2926 | 49 |
6108 | 50 extern OCTAVE_API std::string octave_fgets (std::FILE *); |
51 extern OCTAVE_API std::string octave_fgetl (std::FILE *); | |
2926 | 52 |
6108 | 53 extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof); |
54 extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof); | |
3970 | 55 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
56 template <typename T> |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
57 T |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
58 octave_read_value (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
59 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
60 T retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
61 is >> retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
62 return retval; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
63 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
64 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
65 template <> OCTAVE_API double octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
66 template <> OCTAVE_API Complex octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
67 template <> OCTAVE_API float octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
68 template <> OCTAVE_API FloatComplex octave_read_value (std::istream& is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
69 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
70 // The next four functions are provided for backward compatibility. |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
71 inline double |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
72 octave_read_double (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
73 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
74 return octave_read_value<double> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
75 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
76 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
77 inline Complex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
78 octave_read_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
79 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
80 return octave_read_value<Complex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
81 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
82 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
83 inline float |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
84 octave_read_float (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
85 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
86 return octave_read_value<float> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
87 } |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
88 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
89 inline FloatComplex |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
90 octave_read_float_complex (std::istream& is) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
91 { |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
92 return octave_read_value<FloatComplex> (is); |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8950
diff
changeset
|
93 } |
4130 | 94 |
10180 | 95 extern OCTAVE_API void |
96 octave_write_double (std::ostream& os, double dval); | |
97 | |
98 extern OCTAVE_API void | |
99 octave_write_complex (std::ostream& os, const Complex& cval); | |
4130 | 100 |
10180 | 101 extern OCTAVE_API void |
102 octave_write_float (std::ostream& os, float dval); | |
103 | |
104 extern OCTAVE_API void | |
105 octave_write_float_complex (std::ostream& os, const FloatComplex& cval); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
106 |
1967 | 107 #endif |